nobl9/sloctl

sloctl does not resolve to environment variables SLOCTL_CLIENT_ID SLOCTL_CLIENT_SECRET when running as root in version 0.0.87

heshamelsherif97 opened this issue · 7 comments

Steps to reproduce

As root user

export SLOCTL_CLIENT_ID="xxxx"
export SLOCTL_CLIENT_SECRET="xxxx"
sloctl get slos

Results in error

No context was set in the current configuration file.
At least one context must be provided and set as default in the current configuration file.
Run 'sloctl config add-context' or indicate the path to the file using '--config' flag.
Sloctl also accepts configuration via environmental variables, set 'SLOCTL_CLIENT_ID' and 'SLOCTL_CLIENT_SECRET'.
Visit sloctl documentation for more details: https://docs.nobl9.com/sloctl-user-guide.

Error: context "default" is not present in the config file /root/.config/nobl9/config.toml

hey @heshamelsherif97 :) First of all, why are you running sloctl from root user? Are you sure the envs you exported are available in the root namespace?

I checked, and we've got a bug there, which breaks this workflow, I'll be fixing this and let you know once the new version is published.
For a temporary fix, if you don't want to operate on the config.toml file you can create a dummy config.toml with the following contents:

[Contexts]
  [Contexts.default]

@nieomylnieja
Using docker as well reproduces the issue on my side running

docker run -e SLOCTL_CLIENT_ID="xxxxx" -e SLOCTL_CLIENT_SECRET="xxxx"  nobl9/sloctl:latest get slos

results

No context was set in the current configuration file.
At least one context must be provided and set as default in the current configuration file.
Run 'sloctl config add-context' or indicate the path to the file using '--config' flag.
Sloctl also accepts configuration via environmental variables, set 'SLOCTL_CLIENT_ID' and 'SLOCTL_CLIENT_SECRET'.
Visit sloctl documentation for more details: https://docs.nobl9.com/sloctl-user-guide.

Error: context "default" is not present in the config file /.config/nobl9/config.toml

@heshamelsherif97 the new version which should fix the issues you've encountered is here: https://github.com/nobl9/sloctl/releases/tag/v0.0.88 :)
For now you have to slightly modify the command to make it work on no config file setup:

docker run -e SLOCTL_CLIENT_ID="xxxxx" -e SLOCTL_CLIENT_SECRET="xxxx"  nobl9/sloctl:latest get slos --no-config-file

I'll update the example in this repo too.

Appendix: the v0.0.89 version completely fixes the issue, you can run the example command without problems now. Let me know If this solves your issues!

Thanks a lot @nieomylnieja Works now

glad to hear that and sorry for the inconvenience!