Skip to content

commands/operator-sdk: change defintion of operator-sdk new#23

Merged
fanminshi merged 1 commit intooperator-framework:masterfrom
fanminshi:command_new_change
Feb 20, 2018
Merged

commands/operator-sdk: change defintion of operator-sdk new#23
fanminshi merged 1 commit intooperator-framework:masterfrom
fanminshi:command_new_change

Conversation

@fanminshi
Copy link
Copy Markdown
Contributor

@fanminshi fanminshi commented Feb 20, 2018

new now requires flags --api-group and --api-kind because providing defaults to those value are not useful; hence un-useful defaults shouldn't be defaults.

@fanminshi
Copy link
Copy Markdown
Contributor Author

cc/ @hasbro17 @hongchaodeng @xiang90

Comment thread commands/operator-sdk/cmd/new.go Outdated
// newCmd represents the new command
var newCmd = &cobra.Command{
Use: "new [options] <project-name>",
Use: "new <project-name> <api-group> <kind>",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Based on initial feedback, most members of the group like to have flags to indicate the meeting of the last two params. Let's make apigroup and kind flags.

@fanminshi
Copy link
Copy Markdown
Contributor Author

fanminshi commented Feb 20, 2018

based on private discussion, we are going to have operator-sdk new [project-name] --api-group --kind and make --api-group and --kind required flags.

Comment thread commands/operator-sdk/cmd/new.go Outdated
$ operator-sdk new play
generates a skeletal play application in $GOPATH/src/github.com/example.com/play.
$ mkdir $GOPATH/src/github.com/example.com/app-operator
$ cd $GOPATH/src/github.com/example.com/app-operator
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

See the workflow: https://github.com/coreos/operator-sdk#creating-a-new-project

It is:

cd $GOPATH/src/github.com/example.com/
 operator-sdk new app-operator
cd app-operator

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good catch on this one!

@fanminshi
Copy link
Copy Markdown
Contributor Author

all fixed. PTAL

@fanminshi
Copy link
Copy Markdown
Contributor Author

manual test:

$ ./operator-sdk new
Error: Required flag(s) "api-group", "kind" have/has not been set
Usage:
  operator-sdk new [options] <project-name> [flags]

Flags:
      --api-group string   Kubernetes API Group and has a format of $GROUP_NAME/$VERSION (e.g app.example.com/v1alpha1)
  -h, --help               help for new
      --kind string        Kubernetes CustomResourceDefintion kind. (e.g AppService)

Required flag(s) "api-group", "kind" have/has not been set

@hongchaodeng
Copy link
Copy Markdown
Contributor

Usage:
operator-sdk new [options] [flags]

operator-sdk new <project-name> [required-flags] [options]

@hongchaodeng
Copy link
Copy Markdown
Contributor

LGTM after nit

@fanminshi
Copy link
Copy Markdown
Contributor Author

the best i can do is operator-sdk new <project-name> [required-flags] [flags] the latter [flags] is added by cobra; so i have no control of it.

new now requires flags --api-group and --api-kind
@hongchaodeng
Copy link
Copy Markdown
Contributor

Sounds good

@fanminshi
Copy link
Copy Markdown
Contributor Author

fanminshi commented Feb 20, 2018

final output:

$ ./operator-sdk new -h
The operator-sdk new command creates a new operator application and
	generates a default directory layout based on the input <project-name>.

	<project-name> is the project name of the new operator. (e.g app-operator)

	--api-group and --kind are required flags to generate the new operator application.

	For example,
	$ mkdir $GOPATH/src/github.com/example.com/
	$ cd $GOPATH/src/github.com/example.com/
	$ operator-sdk new app-operator --api-group=app.example.com --kind=AppService
	generates a skeletal app-operator application in $GOPATH/src/github.com/example.com/app-operator.

Usage:
  operator-sdk new <project-name> [required-flags] [flags]

Flags:
      --api-group string   Kubernetes API Group and has a format of $GROUP_NAME/$VERSION (e.g app.example.com/v1alpha1)
  -h, --help               help for new
      --kind string        Kubernetes CustomResourceDefintion kind. (e.g AppService)

@fanminshi fanminshi merged commit 3f02ae0 into operator-framework:master Feb 20, 2018
@hongchaodeng hongchaodeng deleted the command_new_change branch February 20, 2018 21:01
@fanminshi fanminshi mentioned this pull request Feb 20, 2018
21 tasks
m1kola pushed a commit to m1kola/operator-sdk that referenced this pull request Jun 7, 2024
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.

2 participants