Declarative application specifications for Fission (#422)

This change enables users to have declarative specifications for Fission resources. Users can specify their "app" in a set of spec files, and use a new fission CLI command to "apply" these specs to a running cluster.

The new "spec" CLI also includes archiving of local source files, and a file watcher that re-builds archives and uploads them on file changes, and a package build watcher that waits for package builds on the CLI. 

A "--spec" option is also added to "function create", and will be added to other resources in future changes.  This option causes a YAML to be outputted to the specs directory instead of the resource being created on the cluster.

The CLI "fission spec --help" outputs usage information.
This commit is contained in:
Soam Vasani
2018-02-05 21:58:44 -08:00
committed by GitHub
parent 6af13e7e29
commit 07c7b759d2
26 changed files with 2013 additions and 85 deletions
+17 -1
View File
@@ -112,6 +112,14 @@ func fnCreate(c *cli.Context) error {
fatal("Need --name argument.")
}
// user wants a spec, create a yaml file with package and function
spec := false
specFile := ""
if c.Bool("spec") {
spec = true
specFile = fmt.Sprintf("function-%v.yaml", fnName)
}
fnList, err := client.FunctionList()
checkErr(err, "get function list")
// check function existence before creating package
@@ -182,7 +190,7 @@ func fnCreate(c *cli.Context) error {
buildcmd := c.String("buildcmd")
// create new package
pkgMetadata = createPackage(client, envName, srcArchiveName, deployArchiveName, buildcmd)
pkgMetadata = createPackage(client, envName, srcArchiveName, deployArchiveName, buildcmd, specFile)
}
//TODO Warn user about resources at fn level overriding the env resources
@@ -241,6 +249,14 @@ func fnCreate(c *cli.Context) error {
function.Spec.ConfigMaps = append(function.Spec.ConfigMaps, newCfgMap)
}
// if we're writing a spec, don't create the function
if spec {
err = specSave(*function, specFile)
checkErr(err, "create function spec")
return nil
}
_, err = client.FunctionCreate(function)
checkErr(err, "create function")