Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Offer easier access to trait list #1220

Merged
merged 1 commit into from
Jan 24, 2020

Conversation

jamesnetherton
Copy link
Contributor

fixes #1203

Added a new command to list traits and their various config options.

Describe all traits:

kamel describe trait

Describe the prometheus trait:

kamel describe trait prometheus

I've hidden this from users based on the assumption that they can already get at this info via shell completion. Hence the output is in JSON, so that it's easy for tooling to parse / filter.

@bfitzpat Here's an example of the output. Hope that's along the lines of what you need.

[
  {
    "name": "prometheus",
    "platform": false,
    "profiles": [
      "Kubernetes",
      "Knative",
      "OpenShift"
    ],
    "properties": [
      {
        "name": "enabled",
        "type": "bool",
        "default": false
      },
      {
        "name": "port",
        "type": "int"
      },
      {
        "name": "service-monitor",
        "type": "bool"
      },
      {
        "name": "service-monitor-labels",
        "type": "string"
      }
    ]
  }
]

Release Note

NONE

@astefanutti
Copy link
Member

astefanutti commented Jan 22, 2020

Just thinking out loud, as describe is generally meant to describe remote resources, and to be somehow consistent with Kubernetes CLI, would something like kamel help trait prometheus -o yaml be preferable?

It could also provide a nice way to get trait documentation from the CLI with kamel help trait prometheus, and possibly support kamel help trait --all, to fill the gap of missing traits help from the kamel CLI, while it's an important part of it.

@jamesnetherton
Copy link
Contributor Author

I did wonder whether describe was the best place for it.

Happy to move it and have it as a general help command with -o & --all args if that improves the UX. I guess logically it is a help command so it makes sense to have it there.

@bfitzpat
Copy link
Contributor

I think this looks great and whether we go with describe or help, provides what we're looking for. My concern with help is that help is usually meant for the user, whereas this information isn't really something the user can consume in this format and describe might be far enough off the beaten path to avoid user confusion.

JSON is perfect and we can just combine the root 'name' with the property 'name' to show the user what all is available. It's a long list of available traits, but I'm hoping we can cache the initial trait json from the cli in the tooling to make it a bit quicker to process.

But yes -- this should work well. Thank you!

@astefanutti
Copy link
Member

@bfitzpat in kubectl CLI, commands can have an output option that can be set to output human readable information, the default, printed in the TTY or JSON and Yaml for processing.

@bfitzpat
Copy link
Contributor

@astefanutti That would be a great way to handle this then -- offering both something user-friendly and tooling-friendly.

@jamesnetherton
Copy link
Contributor Author

Pushed some changes to support kamel help trait along with the additional args we discussed.

Copy link
Member

@astefanutti astefanutti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@astefanutti astefanutti merged commit 89f3a29 into apache:master Jan 24, 2020
@jamesnetherton jamesnetherton deleted the describe-trait branch January 24, 2020 15:36
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.

Offer easier access to trait list
4 participants