Add builder manager support (#308)

This change orchestrates function builds.

Environments (in v2) define a builder image, just like they do a runtime image. The builder image contains a build script that's invoked with source and deployment paths (as env vars).

The buildermgr watches for environments with build images defined, and creates build deployments and services.

Functions can define source and deployment. Buildermgr watches for functions with source code (and build status == pending) and invokes the environment's builder when appropriate. It captures logs from the build and sets the build status (success/failure) and build lots into the PackageStatus.
This commit is contained in:
Ta-Ching Chen
2017-09-25 07:53:09 -07:00
committed by Soam Vasani
parent a720377f3c
commit e587eca08f
40 changed files with 1827 additions and 176 deletions
+20 -6
View File
@@ -18,7 +18,6 @@ package main
import (
"fmt"
"log"
"os"
"text/tabwriter"
@@ -42,12 +41,22 @@ func envCreate(c *cli.Context) error {
fatal("Need an image, use --image.")
}
envVersion := c.Int("version")
envBuilderImg := c.String("builder")
envBuildCmd := c.String("buildcmd")
if len(envBuilderImg) > 0 && len(envBuildCmd) == 0 {
log.Printf("No build command is specified, use the default build command.")
envBuildCmd = "build"
if len(envBuilderImg) > 0 {
envVersion = 2
if len(envBuildCmd) == 0 {
envBuildCmd = "build"
}
}
// Environment API interface version is not specified and
// builder image is empty, set default interface version
if envVersion == 0 {
fmt.Println("Use default environment v1 API interface")
envVersion = 1
}
env := &tpr.Environment{
@@ -56,7 +65,7 @@ func envCreate(c *cli.Context) error {
Namespace: api.NamespaceDefault,
},
Spec: fission.EnvironmentSpec{
Version: 1,
Version: envVersion,
Runtime: fission.Runtime{
Image: envImg,
},
@@ -121,6 +130,11 @@ func envUpdate(c *cli.Context) error {
if len(envImg) > 0 {
env.Spec.Runtime.Image = envImg
}
if env.Spec.Version == 1 && (len(envBuilderImg) > 0 || len(envBuildCmd) > 0) {
fatal("Environment v1 API interface doesn't supported environment builder.")
}
if len(envBuilderImg) > 0 {
env.Spec.Builder.Image = envBuilderImg
}