chris-peterson / pwsh-gitlab

:computer: PowerShell module for GitLab
MIT License
22 stars 10 forks source link

New Feature Discussion: using a persistent config file #11

Closed CaseyMacPherson closed 3 years ago

CaseyMacPherson commented 3 years ago

What is the feeling about introducing a persistent configuration file for individuals that have multiple gitlab systems.

possibly using ~/.gitlabcli/config.yml

Associated commands that should be created to facilitate

The one concern is that this requires an external package powershell-yaml. If that's a concern, then JSON format will work as well. I've included both examples below

Example configurations

YAML

ActiveSite: gitlab.com
gitlab.com:
  - ApiToken: xyz12345
gitlab.mygitlabinstance:
  - ApiToken: "8fhs63"

JSON

{
  "ActiveSite": "gitlab.com",
  "gitlab.com": {
    "ApiToken": "xyz12345"
  },
  "gitlab.mygitlabinstance": {
    "ApiToken": "8fhs63"
  }
}

Cli Output

YAML

> $config=Get-Content ./config.yml | ConvertFrom-Yaml
> $config.ActiveSite
gitlab.com

> $config[$config.ActiveSite].ApiToken
8fhs63

JSON

$config = Get-Content ./config.json | ConvertFrom-Json -AsHashTable
> $config.ActiveSite
gitlab.com

> $config[$config.ActiveSite].ApiToken
8fhs63
chris-peterson commented 3 years ago

Right now, I have a personal machine that I use to dev against gitlab.com and a work machine that I use to dev against a private installation. But it would be nice to be able to switch profiles rather than machines :)

CaseyMacPherson commented 3 years ago

After a little more consideration I'd like to change 2 items

  1. config key ActiveSite to DefaultSite
  2. Set-GitlabSystem to Set-GitlabDefaultSystem
chris-peterson commented 3 years ago

Resolved by #13