operator-sdk: add operator-sdk new command with descriptions#15
operator-sdk: add operator-sdk new command with descriptions#15hongchaodeng merged 2 commits intooperator-framework:masterfrom fanminshi:add_operatorSDK_commands_interface
Conversation
|
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
Error: new command needs 2 arguments.help cc/ @hongchaodeng @hasbro17 for code review. |
| @@ -0,0 +1,38 @@ | |||
|
|
|||
| # Gopkg.toml example | |||
There was a problem hiding this comment.
Remove these comments
| ExitBadArgs = 128 | ||
| ) | ||
|
|
||
| func ExitWithError(code int, err error) { |
| ) | ||
|
|
||
| const ( | ||
| ExitBadArgs = 128 |
| "github.com/coreos/operator-sdk/cmd" | ||
| ) | ||
|
|
||
| func main() { |
There was a problem hiding this comment.
Put this into cmd/operator-sdk/?
There was a problem hiding this comment.
the cobra way seen from https://github.com/spf13/cobra is:
▾ appName/
▾ cmd/
add.go
your.go
commands.go
here.go
main.go
There was a problem hiding this comment.
We can also do operator-sdk/operator-sdk/cmd, but that look a bit weird.
There was a problem hiding this comment.
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/.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
the etcd benchmark tool is has a good file structure for defining commands. https://github.com/coreos/etcd/tree/master/tools/benchmark
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| // newCmd represents the new command |
There was a problem hiding this comment.
Put this into cmd/operator-sdk/new.go
| 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") |
There was a problem hiding this comment.
Kubernetes Resource Kind. (we might add aggregated API server support so that the resource will not be a CRD )
| // 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", |
There was a problem hiding this comment.
we should always call sdk sdk rather than framework. the less terminologies we use the better
|
all fixed PTAL! cc/ @hongchaodeng @xiang90 |
|
lgtm |
add initial command file structure and defines the interface for the
operator-sdk newcommand.