diff --git a/sami-cli/cmd/deploy.go b/sami-cli/cmd/deploy.go new file mode 100644 index 0000000..5d45f88 --- /dev/null +++ b/sami-cli/cmd/deploy.go @@ -0,0 +1,36 @@ +package cmd + +import ( + "errors" + "fmt" + + "github.com/spf13/cobra" +) + +//NewDeployCommand create new cobra command for the init command +func NewDeployCommand() *cobra.Command { + command := &cobra.Command{ + Use: "deploy -f ", + Short: "deloy your service by given the deployment sami file", + Long: `deloy your service by given the deployment sami file + + example: sami deploy -f / +`, + Args: cobra.ExactArgs(1), + Run: func(cmd *cobra.Command, args []string) { + deployFolder := args[0] + + if err := deployCommand(deployFolder); err != nil { + fmt.Printf("Error: %s\n", err) + return + } + }, + } + + return command +} + +func deployCommand(deployFolder string) error { + // will add the deployment process here... + return errors.New("") +} diff --git a/sami-cli/cmd/sami.go b/sami-cli/cmd/sami.go new file mode 100644 index 0000000..07ec5a0 --- /dev/null +++ b/sami-cli/cmd/sami.go @@ -0,0 +1,27 @@ +package cmd + +import ( + "github.com/spf13/cobra" +) + +//NewCommand returns a new sami cobra command +func NewCommand() *cobra.Command { + var samiCommand = &cobra.Command{ + Use: "sami", + Short: "sami helps you deploy your services to any target machine", + Long: `sami helps you deploy your services to any target machine`, + } + + // deploy + // samiCommand.AddCommand(NewDeployCommand()) + + // logs + // samiCommand.AddCommand(NewLogsCommand()) + + // oob + // samiCommand.AddCommand(NewOobCommand()) + + // status + // samiCommand.AddCommand(NewStatusCommand()) + return samiCommand +} diff --git a/sami-cli/fixtures/bad-sami.yml b/sami-cli/fixtures/bad-sami.yml new file mode 100644 index 0000000..99264f7 --- /dev/null +++ b/sami-cli/fixtures/bad-sami.yml @@ -0,0 +1,12 @@ + + +service_name: "camerdevs" +type: "swarm" + +files: + - ./stack.yaml + +oob: + - update-image: + file: "./stack.yaml" + zigzag: 1 diff --git a/sami-cli/fixtures/good-sami.yml b/sami-cli/fixtures/good-sami.yml new file mode 100644 index 0000000..8212fa2 --- /dev/null +++ b/sami-cli/fixtures/good-sami.yml @@ -0,0 +1,12 @@ +version: v1beta + + +service_name: "camerdevs" +type: "swarm" +files: + - ./stack.yaml + +oob: + - update-image: + file: "./stack.yaml" + path: ".services.frontend.image" diff --git a/sami-cli/go.mod b/sami-cli/go.mod new file mode 100644 index 0000000..48d1dd3 --- /dev/null +++ b/sami-cli/go.mod @@ -0,0 +1,10 @@ +module github.com/osscameroon/sami + +go 1.17 + +require github.com/spf13/cobra v1.4.0 + +require ( + github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect +) diff --git a/sami-cli/go.sum b/sami-cli/go.sum new file mode 100644 index 0000000..0dd8697 --- /dev/null +++ b/sami-cli/go.sum @@ -0,0 +1,10 @@ +github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/spf13/cobra v1.4.0 h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q= +github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= diff --git a/sami-cli/main.go b/sami-cli/main.go new file mode 100644 index 0000000..287d431 --- /dev/null +++ b/sami-cli/main.go @@ -0,0 +1,20 @@ +package main + +import ( + "os" + + "github.com/osscameroon/sami/sami-cli/cmd" +) + +var version = "0.0.0+dev" + +func main() { + command := cmd.NewCommand() + + err := command.Execute() + if err != nil { + os.Exit(1) + } + + os.Exit(0) +}