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

[Feature] chainsaw explain command #1022

Open
1 task done
chipzoller opened this issue Mar 3, 2024 · 3 comments
Open
1 task done

[Feature] chainsaw explain command #1022

chipzoller opened this issue Mar 3, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@chipzoller
Copy link
Contributor

chipzoller commented Mar 3, 2024

Problem Statement

Chainsaw is growing more complex and capable with more resources as well as more complexity to each resource. It's becoming more difficult to remember the structure of each field especially as more are being added in this early phase of growth. Flipping over to either other examples or the website isn't a great experience as these things can be incomplete and involve switching between workspaces.

Solution Description

Add an explain command just like kubectl explain which allows users to interactively (and recursively) describe and explain API resources.

chainsaw explain test.spec: explain the Test resource under the spec struct. All fields have complete descriptions.
chainsaw explain test.spec --recursive: Similar to the above but with a recursive tree structure for all fields underneath.

See an example of this for kubectl:

$ kubectl explain poddisruptionbudget.spec --recursive
GROUP:      policy
KIND:       PodDisruptionBudget
VERSION:    v1

FIELD: spec <PodDisruptionBudgetSpec>

DESCRIPTION:
    Specification of the desired behavior of the PodDisruptionBudget.
    PodDisruptionBudgetSpec is a description of a PodDisruptionBudget.

FIELDS:
  maxUnavailable        <IntOrString>
  minAvailable  <IntOrString>
  selector      <LabelSelector>
    matchExpressions    <[]LabelSelectorRequirement>
      key       <string> -required-
      operator  <string> -required-
      values    <[]string>
    matchLabels <map[string]string>
  unhealthyPodEvictionPolicy    <string>

Alternatives

JSON schemas are ok but they're clunky and, require either adding a CRD to a cluster or adding a line to a file, and are IDE specific.

Additional Context

$ kubectl explain --help
Describe fields and structure of various resources.

 This command describes the fields associated with each supported API resource. Fields are identified via a simple
JSONPath identifier:

        <type>.<fieldName>[.<fieldName>]

 Information about each field is retrieved from the server in OpenAPI format.

Use "kubectl api-resources" for a complete list of supported resources.

Examples:
  # Get the documentation of the resource and its fields
  kubectl explain pods

  # Get all the fields in the resource
  kubectl explain pods --recursive

  # Get the explanation for deployment in supported api versions
  kubectl explain deployments --api-version=apps/v1

  # Get the documentation of a specific field of a resource
  kubectl explain pods.spec.containers

  # Get the documentation of resources in different format
  kubectl explain deployment --output=plaintext-openapiv2

Options:
    --api-version='':
        Use given api-version (group/version) of the resource.

    --output='plaintext':
        Format in which to render the schema. Valid values are: (plaintext, plaintext-openapiv2).

    --recursive=false:
        When true, print the name of all the fields recursively. Otherwise, print the available fields with their
        description.

Usage:
  kubectl explain TYPE [--recursive=FALSE|TRUE] [--api-version=api-version-group]
[--output=plaintext|plaintext-openapiv2] [options]

Use "kubectl options" for a list of global command-line options (applies to all commands).

Slack discussion

No response

Research

  • I have searched other issues in this repository and mine is not recorded.
@chipzoller chipzoller added the enhancement New feature or request label Mar 3, 2024
@chipzoller chipzoller changed the title [Feature] chainsaw explain [Feature] chainsaw explain command Mar 3, 2024
@eddycharly eddycharly added the good first issue Good for newcomers label Mar 3, 2024
@eddycharly
Copy link
Member

adding a line to a file

This sounds like a reasonable effort :)

@chipzoller
Copy link
Contributor Author

If it's too difficult for you I understand 😉

@eddycharly
Copy link
Member

Let's see if someone wants to give it a try 🤞
It's not high priority but would be good to have if we can.

@eddycharly eddycharly removed the good first issue Good for newcomers label Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants