Allow to set deployment config uid during initialization (#1249)
This commit is contained in:
@@ -272,11 +272,12 @@ func NewCliApp() *cli.App {
|
|||||||
// specs
|
// specs
|
||||||
specDirFlag := cli.StringFlag{Name: "specdir", Usage: "Directory to store specs, defaults to ./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"}
|
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"}
|
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"}
|
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"}
|
specDeleteFlag := cli.BoolFlag{Name: "delete", Usage: "Allow apply to delete resources that no longer exist in the specification"}
|
||||||
specSubCommands := []cli.Command{
|
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: "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: "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},
|
{Name: "destroy", Usage: "Delete all Fission resources in the app specification", Flags: []cli.Flag{specDirFlag}, Action: specDestroy},
|
||||||
|
|||||||
@@ -168,6 +168,11 @@ func specInit(c *cli.Context) error {
|
|||||||
name = util.KubifyName(basename)
|
name = util.KubifyName(basename)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deployID := c.String("deployid")
|
||||||
|
if len(deployID) == 0 {
|
||||||
|
deployID = uuid.NewV4().String()
|
||||||
|
}
|
||||||
|
|
||||||
// Create spec dir
|
// Create spec dir
|
||||||
fmt.Printf("Creating fission spec directory '%v'\n", specDir)
|
fmt.Printf("Creating fission spec directory '%v'\n", specDir)
|
||||||
err := os.MkdirAll(specDir, 0755)
|
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
|
// 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
|
// us to be idempotent, as well as to delete resources when their specs are
|
||||||
// removed.
|
// removed.
|
||||||
UID: uuid.NewV4().String(),
|
UID: deployID,
|
||||||
}
|
}
|
||||||
err = writeDeploymentConfig(specDir, &dc)
|
err = writeDeploymentConfig(specDir, &dc)
|
||||||
util.CheckErr(err, "write deployment config")
|
util.CheckErr(err, "write deployment config")
|
||||||
|
|||||||
Reference in New Issue
Block a user