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: stencil cli for namespace and schema #97

Merged
merged 9 commits into from
Jan 28, 2022

Conversation

ishanarya0
Copy link
Member

@ishanarya0 ishanarya0 commented Jan 22, 2022

Proposed features

A. Namespace

  • stencil namespace list
  • stencil namespace create
  • stencil namespace get
  • stencil namespace update
  • stencil namespace delete

B. Schema

  • stencil schema list
  • stencil schema create
  • stencil schema get
  • stencil schema update
  • stencil schema delete
  • stencil schema version

cmd/schema.go Outdated
"group:core": "true",
},
RunE: func(cmd *cobra.Command, args []string) error {
s := term.Spin("Fetching schema list")
Copy link
Member

Choose a reason for hiding this comment

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

@ishanarya0 There is a slight change in this API for the spinner. Check guardian for reference. Also we can avoid label since this is only action and we are not changing any state.

cmd/schema.go Outdated Show resolved Hide resolved
cmd/schema.go Outdated
Short: "list all schemas",
Args: cobra.ExactArgs(1),
Example: heredoc.Doc(`
$ stencil schema list <schema-id>
Copy link
Member

Choose a reason for hiding this comment

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

let's replace schema-id with namespace-id

Copy link
Member

Choose a reason for hiding this comment

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

This should be a flag right. If not provided it list schemas across all namespaces.

Copy link
Member Author

Choose a reason for hiding this comment

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

Need API support for that. Currently, it returns no schemas if namespace-id is not given.

cmd/schema.go Show resolved Hide resolved
cmd.Flags().StringVar(&host, "host", "", "stencil host address eg: localhost:8000")
cmd.MarkFlagRequired("host")

cmd.Flags().Int32VarP(&version, "version", "v", 0, "particular version to be deleted")
Copy link
Member

Choose a reason for hiding this comment

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

any reason why version is flag, instead of args?
namespace and schema names are args. We should ideally put version also as args.

Copy link
Member

Choose a reason for hiding this comment

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

@harikrishnakanchi Version is just a filter for a given schema. the major entity is a schema, hence the flag

Copy link
Member

Choose a reason for hiding this comment

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

I mean we can still make version as optional with args as well. If version is omitted, then it retrieves latest version data.
This command structure would be better

stencil schema get <namespace-id> <schema-id> <version> -m

Copy link
Member

Choose a reason for hiding this comment

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

More than one org in cli is bad practice. I would recommend following.

stencil schema get  <schema-id> -n <namespace> -v <version> -m  -o <output format>

This takes schema-id as org as we are getting schema everything else is a modifier.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this looks good. Changing every cmd to take a max of one arg.

cmd/schema.go Outdated
Short: "version(s) of all schemas",
Args: cobra.ExactArgs(2),
Example: heredoc.Doc(`
$ stencil schema list <namespace-id> <schema-id>
Copy link
Member

Choose a reason for hiding this comment

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

example should be corrected to stencil schema version <namespace-id> <schema-id>

@ishanarya0
Copy link
Member Author

Changes -

  1. namespace update cmd -> made description flag mandatory
  2. schema list cmd -> typo fixed in example to namespace-id & zero schemas message added
  3. schema create cmd -> format and comp flags to be made optional, this needs some API changes? @harikrishnakanchi
  4. schema version cmd -> typecasting fixed
  5. schema get cmd -> to allow only to write the schema in an output file using the output flag

cmd/schema.go Outdated
cmd.MarkFlagRequired("host")

cmd.Flags().Int32VarP(&version, "version", "v", 0, "version of the schema")
cmd.MarkFlagRequired("host")
Copy link
Member

Choose a reason for hiding this comment

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

redundant. host flag already marked as required.

cmd/schema.go Outdated
cmd.MarkFlagRequired("host")

cmd.Flags().BoolVarP(&metadata, "metadata", "m", false, "set this flag to get metadata")
cmd.MarkFlagRequired("host")
Copy link
Member

Choose a reason for hiding this comment

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

redundant. Host flag already marked as required. this can be removed.

@h4rikris h4rikris merged commit 32d8a70 into raystack:master Jan 28, 2022
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.

None yet

3 participants