apigee / registry

The Registry API allows teams to track and manage machine-readable descriptions of APIs.
https://apigee.github.io/registry
Apache License 2.0
148 stars 33 forks source link

Configurations are read inconsistently in registry tool command implementations #1231

Closed timburks closed 1 year ago

timburks commented 1 year ago

Unfortunately #1230 didn't fully fix #1228.

This now works:

$ registry --config /tmp/apiz config list
registry.address = apiz.timbx.me:443
registry.insecure = false
registry.project = catalog
token-source = echo "ok"

Your active configuration is: "/tmp/apiz".

But this doesn't:

$ registry --config /tmp/apiz get projects
Usage:
...
Error: open /home/tim/.config/registry/apiz: no such file or directory
Run 'registry --help' for usage.

I can't explain why one of these commands should be getting its configuration differently from the other, but I observe that registry config list calls config.ActiveRaw() here and registry get projects calls connection.ActiveConfig() here.

Looking further, I see that config.ActiveRaw() is only used by the registry config subcommands and registry auth print-token, and all the others use connection.ActiveConfig().

@theganyo do you know why we have two ways of doing this? Is there something to watch out for in merging them?

theganyo commented 1 year ago

IIRC, ActiveRaw() returns exactly the contents of the config whereas ActiveConfig() returns a resolved set of vars that can include params and env var overrides.

timburks commented 1 year ago

Another suspicious thing that I see is that connection.ActiveConfig() just directly reads the configuration instead of using config.ActiveRaw() or config.Active() (I think this is what it should be calling).