diff --git a/pkg/fission-cli/main.go b/pkg/fission-cli/main.go index 4eed3f57..df5b7ce1 100644 --- a/pkg/fission-cli/main.go +++ b/pkg/fission-cli/main.go @@ -272,11 +272,12 @@ func NewCliApp() *cli.App { // specs specDirFlag := cli.StringFlag{Name: "specdir", Usage: "Directory to store specs, defaults to ./specs"} specNameFlag := cli.StringFlag{Name: "name", Usage: "(optional) Name for the app, applied to resources as a Kubernetes annotation"} + specDeployIDFlag := cli.StringFlag{Name: "deployid, id", Usage: "(optional) Deployment ID for the spec deployment config"} specWaitFlag := cli.BoolFlag{Name: "wait", Usage: "Wait for package builds"} specWatchFlag := cli.BoolFlag{Name: "watch", Usage: "Watch local files for change, and re-apply specs as necessary"} specDeleteFlag := cli.BoolFlag{Name: "delete", Usage: "Allow apply to delete resources that no longer exist in the specification"} specSubCommands := []cli.Command{ - {Name: "init", Usage: "Create an initial declarative app specification", Flags: []cli.Flag{specDirFlag, specNameFlag}, Action: specInit}, + {Name: "init", Usage: "Create an initial declarative app specification", Flags: []cli.Flag{specDirFlag, specNameFlag, specDeployIDFlag}, Action: specInit}, {Name: "validate", Usage: "Validate Fission app specification", Flags: []cli.Flag{specDirFlag}, Action: specValidate}, {Name: "apply", Usage: "Create, update, or delete Fission resources from app specification", Flags: []cli.Flag{specDirFlag, specDeleteFlag, specWaitFlag, specWatchFlag}, Action: specApply}, {Name: "destroy", Usage: "Delete all Fission resources in the app specification", Flags: []cli.Flag{specDirFlag}, Action: specDestroy}, diff --git a/pkg/fission-cli/spec.go b/pkg/fission-cli/spec.go index ce40cddc..ec9ef25a 100644 --- a/pkg/fission-cli/spec.go +++ b/pkg/fission-cli/spec.go @@ -168,6 +168,11 @@ func specInit(c *cli.Context) error { name = util.KubifyName(basename) } + deployID := c.String("deployid") + if len(deployID) == 0 { + deployID = uuid.NewV4().String() + } + // Create spec dir fmt.Printf("Creating fission spec directory '%v'\n", specDir) err := os.MkdirAll(specDir, 0755) @@ -190,7 +195,7 @@ func specInit(c *cli.Context) error { // All resources will be annotated with the UID when they're created. This allows // us to be idempotent, as well as to delete resources when their specs are // removed. - UID: uuid.NewV4().String(), + UID: deployID, } err = writeDeploymentConfig(specDir, &dc) util.CheckErr(err, "write deployment config")