Skip to content

Add support for --output flags in config show#199

Merged
amstuta merged 5 commits into
ovh:mainfrom
FrostByte0x:fix/config-output-options
Jul 2, 2026
Merged

Add support for --output flags in config show#199
amstuta merged 5 commits into
ovh:mainfrom
FrostByte0x:fix/config-output-options

Conversation

@FrostByte0x

@FrostByte0x FrostByte0x commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Description

Add support for output as json to config show

Fixes #196

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

As I was not sure if using a specific display option is by design for the config, this change may not be necessary to the project.

Checklist:

  • My code follows the style guidelines of this project
  • I have commented my code
  • I ran go mod tidy
  • I have added tests that prove my fix is effective or that my feature works

Changes

Current version

./ovhcloud config show -o json
┌─────────┬────────────────────┬─────────────────────┐
│ section │        key         │        value        │
├─────────┼────────────────────┼─────────────────────┤
│ default │                    │                     │
│         │ endpoint           │ ovh-eu              │
│ ovh-eu  │                    │                     │
│         │ application_key    │ aaaaaaaaaaaaa       │
│         │ application_secret │ xxxxxxxxxxxxxxx     │
│         │ consumer_key       │ yyyyyyyyyyyyyyyyyyy │
└─────────┴────────────────────┴─────────────────────┘

Updated

./ovhcloud config show -o json
{
  "default": {
    "endpoint": "ovh-eu"
  },
  "ovh-eu": {
    "application_key": "aaaaaaaaaaaaa",
    "application_secret": "xxxxxxxxxxxxxxx",
    "consumer_key": "yyyyyyyyyyyyyyyyyyy"
  }
}

@FrostByte0x FrostByte0x requested a review from a team as a code owner June 14, 2026 18:22
Signed-off-by: FrostByte0x <marcellin.penicaud@gmail.com>
@FrostByte0x FrostByte0x force-pushed the fix/config-output-options branch from 1f434de to c184a35 Compare June 14, 2026 19:09
@amstuta

amstuta commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Thank you for your PR @FrostByte0x ! Could you just move the code you made into function RenderConfigTable ?

After that, all good to merge :)

Signed-off-by: FrostByte0x <271714451+FrostByte0x@users.noreply.github.com>
Signed-off-by: FrostByte0x <271714451+FrostByte0x@users.noreply.github.com>
@FrostByte0x FrostByte0x force-pushed the fix/config-output-options branch from ec40cc0 to dd951b6 Compare June 30, 2026 09:36
@FrostByte0x

Copy link
Copy Markdown
Contributor Author

Done @amstuta, please let me know if this is what you expected. Now the RenderConfigTable takes as input the output format, and if any flag is passed using -output {json|yaml|etc..}, then the fix will run instead of rendering the table.

Small update: I've moved the code block at the top of the function to not execute the Table logic.

Couple of things I've noticed:

  • the same command exists in the WASM build, which I assume is for the cloud shell. We may need to bring it there as well if relevant.
  • the two blocks of code that handle the data are similar. We could transform the ini as a slice of map[string]any and just use RenderTable, the tradeoff probably being that we lose the custom table setup in RenderConfigTable so it's not done for now. This may be incorrect, as I am not familiar with the project structure and how the rendering is handled.

Cheers!

@amstuta

amstuta commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Thanks @FrostByte0x ! Could you check the build that is failing ?

You're right regarding the two points you mention, but I think we'll leave the code as-is for now as the WASM code to manage the config will probably be re-written soon ;)

@FrostByte0x

Copy link
Copy Markdown
Contributor Author

Done @amstuta

I brought the same code to it. I also noticed that the cloud shell doesn't have config section, I assume it is just hidden to the user of the cloud shell
image

Signed-off-by: FrostByte0x <271714451+FrostByte0x@users.noreply.github.com>
Signed-off-by: FrostByte0x <271714451+FrostByte0x@users.noreply.github.com>
@FrostByte0x FrostByte0x force-pushed the fix/config-output-options branch from 7ca34cf to 396ca3c Compare July 2, 2026 07:12
@amstuta

amstuta commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Indeed, in fact right now there is nothing you can configure on the cloudshell because authentication is managed automatically, and there is no implementation made to store the preferences. It will be implemented at some point :)

@amstuta amstuta merged commit 6f26eff into ovh:main Jul 2, 2026
4 checks passed
@FrostByte0x FrostByte0x deleted the fix/config-output-options branch July 2, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: "ovhcloud config show --output json" is not JSON

2 participants