Skip to content

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

Open
FrostByte0x wants to merge 4 commits into
ovh:mainfrom
FrostByte0x:fix/config-output-options
Open

Add support for --output flags in config show#199
FrostByte0x wants to merge 4 commits into
ovh:mainfrom
FrostByte0x:fix/config-output-options

Conversation

@FrostByte0x

@FrostByte0x FrostByte0x commented Jun 14, 2026

Copy link
Copy Markdown

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
Signed-off-by: FrostByte0x <271714451+FrostByte0x@users.noreply.github.com>
@FrostByte0x

Copy link
Copy Markdown
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!

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