Skip to content

operator-sdk: add operator-sdk new command with descriptions#15

Merged
hongchaodeng merged 2 commits intooperator-framework:masterfrom
fanminshi:add_operatorSDK_commands_interface
Feb 16, 2018
Merged

operator-sdk: add operator-sdk new command with descriptions#15
hongchaodeng merged 2 commits intooperator-framework:masterfrom
fanminshi:add_operatorSDK_commands_interface

Conversation

@fanminshi
Copy link
Copy Markdown
Contributor

add initial command file structure and defines the interface for the operator-sdk new command.

@fanminshi fanminshi mentioned this pull request Feb 15, 2018
21 tasks
@fanminshi
Copy link
Copy Markdown
Contributor Author

fanminshi commented Feb 15, 2018

Manual test:

operator-sdk top view:

$ ./operator-sdk
A framework for building operator with ease

Usage:
  operator-sdk [command]

Available Commands:
  help        Help about any command
  new         Creates a new operator application

Flags:
  -h, --help   help for operator-sdk

operator-sdk new with no arguments:

$ ./operator-sdk new
Error: new command needs 2 arguments.

help operator-sdk new:

$ ./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>.

	If none of options are specified, the operator-sdk defaults
	Kubernetes api group to <project-name>.example.com/v1
	and Kubernetes kind to <project-name>Service.

	For example,
	$ mkdir $GOPATH/src/github.com/example.com/play
	$ cd $GOPATH/src/github.com/example.com/play
	$ operator-sdk new play
	generates a skeletal play application in $GOPATH/src/github.com/example.com/play.

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

Flags:
      --api-group string   Kubernetes API group. e.g play.example.com/v1
  -h, --help               help for new
      --kind string        Kubernetes CRD kind. e.g PlayService

cc/ @hongchaodeng @hasbro17 for code review.

Comment thread Gopkg.toml Outdated
@@ -0,0 +1,38 @@

# Gopkg.toml example
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.

Remove these comments

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.

will remove!

Comment thread cmd/error.go
ExitBadArgs = 128
)

func ExitWithError(code int, err error) {
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.

doc

Comment thread cmd/error.go
)

const (
ExitBadArgs = 128
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.

doc

Comment thread main.go
"github.com/coreos/operator-sdk/cmd"
)

func main() {
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.

Put this into cmd/operator-sdk/?

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.

the cobra way seen from https://github.com/spf13/cobra is:

▾ appName/
    ▾ cmd/
        add.go
        your.go
        commands.go
        here.go
      main.go

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.

We can also do operator-sdk/operator-sdk/cmd, but that look a bit weird.

Copy link
Copy Markdown
Contributor

@hongchaodeng hongchaodeng Feb 16, 2018

Choose a reason for hiding this comment

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

Just cmd/operator-sdk/.

The cobra way is one repo for one thing. We aren't following that. For more package stuff, put them into pkg/cmd/operator-sdk/.

Copy link
Copy Markdown
Contributor Author

@fanminshi fanminshi Feb 16, 2018

Choose a reason for hiding this comment

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

how about this?

cmd/operator-sdk/
▾ cmd/
        add.go
        your.go
        commands.go
        here.go
      main.go

or

The following allows us to add additionally command under the commands pkg which seems an intuitive approach.

commands/operator-sdk/
▾ cmd/
        add.go
        your.go
        commands.go
        here.go
      main.go

Copy link
Copy Markdown
Contributor Author

@fanminshi fanminshi Feb 16, 2018

Choose a reason for hiding this comment

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

the etcd benchmark tool is has a good file structure for defining commands. https://github.com/coreos/etcd/tree/master/tools/benchmark

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.

Sounds good!

Comment thread cmd/new.go
"github.com/spf13/cobra"
)

// newCmd represents the new command
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.

Put this into cmd/operator-sdk/new.go

Comment thread cmd/new.go Outdated
func init() {
RootCmd.AddCommand(newCmd)
newCmd.Flags().StringVar(&apiGroup, "api-group", "", "Kubernetes API group. e.g play.example.com/v1")
newCmd.Flags().StringVar(&kind, "kind", "", "Kubernetes CRD kind. e.g PlayService")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Kubernetes Resource Kind. (we might add aggregated API server support so that the resource will not be a CRD )

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.

kk

Comment thread cmd/root.go Outdated
// This represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
Use: "operator-sdk",
Short: "A framework for building operator with ease",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

we should always call sdk sdk rather than framework. the less terminologies we use the better

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.

sounds good!

@fanminshi
Copy link
Copy Markdown
Contributor Author

all fixed PTAL! cc/ @hongchaodeng @xiang90

@hongchaodeng
Copy link
Copy Markdown
Contributor

lgtm

@hongchaodeng hongchaodeng merged commit c247f13 into operator-framework:master Feb 16, 2018
@hongchaodeng hongchaodeng deleted the add_operatorSDK_commands_interface branch February 16, 2018 21:22
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.

3 participants