resources

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package resources holds simple functions for synthesizing child resources from a Source.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildName

func BuildName(source *v1alpha1.Source) string

BuildName gets the name of a Build for a Source.

Example
source := &v1alpha1.Source{}
source.Name = "my-source"

fmt.Println(BuildName(source))
Output:

my-source

func MakeBuild

func MakeBuild(source *v1alpha1.Source) (*build.Build, error)

MakeBuild creates a Build for a Source.

Example
source := &v1alpha1.Source{}
source.Name = "my-source"
source.Namespace = "my-namespace"
source.Spec.ServiceAccount = "some-account"
source.Spec.BuildpackBuild.Source = "some-source"
source.Spec.BuildpackBuild.Image = "gcr.io/image:123"
source.Spec.BuildpackBuild.Stack = "gcr.io/kf-releases/run:latest"
source.Spec.BuildpackBuild.BuildpackBuilder = "some-buildpack-builder"
source.Spec.BuildpackBuild.Env = []corev1.EnvVar{
	{
		Name:  "some",
		Value: "variable",
	},
}

build, err := MakeBuild(source)
if err != nil {
	panic(err)
}

fmt.Println("Name:", BuildName(source))
fmt.Println("Label Count:", len(build.Labels))
fmt.Println("Managed By:", build.Labels[managedByLabel])
fmt.Println("Service Account:", build.Spec.ServiceAccountName)
fmt.Println("Arg Count:", len(build.Spec.Template.Arguments))
fmt.Println("Output Image:", v1alpha1.GetBuildArg(build, v1alpha1.BuildArgImage))
fmt.Println("Env:", build.Spec.Template.Env[0].Name, "=", build.Spec.Template.Env[0].Value)
fmt.Println("Stack:", v1alpha1.GetBuildArg(build, v1alpha1.BuildArgBuildpackRunImage))
Output:

Name: my-source
Label Count: 1
Managed By: kf
Service Account: some-account
Arg Count: 4
Output Image: gcr.io/image:123
Env: some = variable
Stack: gcr.io/kf-releases/run:latest

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL