cnoe-io / idpbuilder

Spin up a complete internal developer platform with only Docker required as a dependency.
https://cloud-native.slack.com/archives/C05TN9WFN5S
Apache License 2.0
197 stars 59 forks source link

show and save config details for idpBuilder #114

Open nimakaviani opened 11 months ago

nimakaviani commented 11 months ago

The idpbuilder should allow its users to see and use configuration details for the deployed core technologies.

I am proposing we create a new command idpbuilder config that would do the following:

$ idpbuilder config
# pretty prints configuration details for all endpoints

$ idpbuilder config -o json
# prints configuration details for all endpoints in json
{
  "argocd": {
    "url": "https://argocd.cnoe.localtest.me:8433",
    "username": "USERNAME",
    "password": "PASSWORD"
  },
  "gitea": {
    "url": "https://gitea.cnoe.localtest.me:8443",
    "username": "USERNAME",
    "password": "PASSWORD"
  },
  "backstage": {
    "url": "https://backstage.cnoe.localtest.me:8443",
    "username": "USERNAME",
    "password": "PASSWORD"
  }
}

specially given that the core set of idp tools are going to be small (Argo CD, Gitea, Backstage), a complete json list is probably very helpful to extract data from.

$ idpbuilder config gitea 
$ idpbuilder config argocd
... 

should print the config for a given tool and -o json should be available on them too. (output only)

$ idpbuilder config gitea -o json
{
  "url": "https://gitea.cnoe.localtest.me:8443",
  "username": "USERNAME",
  "password": "PASSWORD"
}

Given the above, I think --save can save the config details for CLI use.

For gitea it is rather straightforward, as it needs to populate a local git config with the following info

[credential "https://gitea.cnoe.localtest.me:8443/"]
        username = [USERNAME]
        password = [PASSWORD]
[http "https://gitea.cnoe.localtest.me:8443/"]
        sslVerify = false

For Argo CD, idpbuilder config argocd --save should make the credentials available to the argocd CLI.

For Backstage, it will probably be a noop.

/cc @cmollinard @nabuskey @blakeromano

cmoulliard commented 11 months ago

a complete json list is probably very helpful to extract data from.

I prefer to show such output as a table by default

cmoulliard commented 11 months ago

For Argo CD, idpbuilder config argocd --save should make the credentials available to the argocd CLI.

the config file of argocd is a bit different as it should get a token after issuying argocd login -->

cat /Users/cmoullia/.config/argocd/config
contexts:
- name: argocd.cnoe.localtest.me:8443
  server: argocd.cnoe.localtest.me:8443
  user: argocd.cnoe.localtest.me:8443
current-context: argocd.cnoe.localtest.me:8443
servers:
- grpc-web: true
- grpc-web-root-path: ""
  insecure: true
  server: argocd.cnoe.localtest.me:8443
users:
- auth-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhcmdvY2QiLCJzdWIiOiJhZG1pbjpsb2dpbiIsImV4cCI6MTcwMjczNzQ5NiwibmJmIjoxNzAyNjUxMDk2LCJpYXQiOjE3MDI2NTEwOTYsImp0aSI6IjQ4ZDRlOTczLWYzMGQtNGEwYS1hMjAyLTdhNTBmMmNmMDM1MyJ9.OhUSeNaJ3Dt6oArtKXnmUIptefiKP3iJlY3LxPE-BlM
  name: argocd.cnoe.localtest.me:8443
cmoulliard commented 11 months ago

For gitea it is rather straightforward, as it needs to populate a local git config with the following info

The local .git/config is specific to the repository cloned and not use credentials ...

cat .git/config
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = https://gitea.cnoe.localtest.me:8443/giteaAdmin/idpbuilder-localdev-backstage.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
    remote = origin
    merge = refs/heads/main
nabuskey commented 11 months ago

idpbuilder config gitea|backstage|argocd sounds like you are trying to configure these core packages, not printing endpoint information.

For the idpbuilder config, are we going to be supporting export/import idpbuilder configuration as well? Like ArgoCD configuration, Gitea configuration etc. We touched on this stuff here: https://github.com/cnoe-io/idpbuilder/issues/58#issuecomment-1787587975

We should come up with a command scheme for supporting both.

--save doesn't make sense to me. Something like idpbuilder export config git|argocd ? We should print them to stdout but not write to a file. I definitely do not want mess up users' git config. If users want to write them to a file, they can use shell redirect.

nimakaviani commented 11 months ago

It comes down to how we support CRUD

if idpbuilder config is a read of configs, then in the same vein, idpbuilder config gitea should also be a read of gitea config. This could print both though, ie how to connect and what the configuration params for gitea or other tools are, something like the following

{
  "connection": {
    "url": "https://gitea.cnoe.localtest.me:8443",
    "username": "USERNAME",
    "password": "PASSWORD"
  },
  "config": {
    "database": {
      "DB_TYPE": "sqlite3"
    },
    "session": {
      "PROVIDER": "memory"
    },
    "cache": {
      "ADAPTER": "memory"
    },
    "queue": {
      "TYPE": "level"
    },
    "server": {
      "DOMAIN": "gitea.cnoe.localtest.me",
      "ROOT_URL": "http://gitea.cnoe.localtest.me:8880"
    }
  }
}

idpbuilder config gitea import|export|save (connection|config) should be extended based on the same logic. whether or not we make import|export|save as flags or subcommands is open to suggestion, but I generally prefer for the subcommands to stop at a depth of 3.

nimakaviani commented 11 months ago

The local .git/config is specific to the repository cloned and not use credentials ...

I dont think so. the config that I shared earlier works for me. Also more examples here: https://git-scm.com/docs/git-config#EXAMPLES