Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 159 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[[constraint]]
name = "github.com/sirupsen/logrus"
version = "1.0.4"

[[constraint]]
name = "github.com/spf13/cobra"
version = "0.0.1"

[[constraint]]
branch = "master"
name = "k8s.io/apimachinery"

[[constraint]]
name = "k8s.io/client-go"
version = "6.0.0"
13 changes: 0 additions & 13 deletions cmd/operator-sdk/main.go

This file was deleted.

17 changes: 17 additions & 0 deletions commands/operator-sdk/cmd/error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cmd

import (
"fmt"
"os"
)

const (
// ExitBadArgs is the exit error code for bad arguments.
ExitBadArgs = 128
)

// ExitWithError prints out an error code and an error string to stderr.
func ExitWithError(code int, err error) {
fmt.Fprintln(os.Stderr, "Error:", err)
os.Exit(code)
}
50 changes: 50 additions & 0 deletions commands/operator-sdk/cmd/new.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

// newCmd represents the new command
var newCmd = &cobra.Command{
Use: "new [options] <project-name>",
Short: "Creates a new operator application",
Long: `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 resource 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.
`,
Run: newFunc,
}

var (
apiGroup string
kind string
)

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 Resource Kind. e.g PlayService")
}

func newFunc(cmd *cobra.Command, args []string) {
if len(args) != 1 {
ExitWithError(ExitBadArgs, fmt.Errorf("new command needs 1 arguments."))
}
parse(args)
// TODO: add generation logic.
}

func parse(args []string) {
// TODO: parse args.
}
9 changes: 9 additions & 0 deletions commands/operator-sdk/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package cmd

import "github.com/spf13/cobra"

// This represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
Use: "operator-sdk",
Short: "A sdk for building operator with ease",
}
15 changes: 15 additions & 0 deletions commands/operator-sdk/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package main

import (
"fmt"
"os"

"github.com/coreos/operator-sdk/commands/operator-sdk/cmd"
)

func main() {
if err := cmd.RootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(-1)
}
}