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: 20 Imported by: 0

Documentation

Overview

Package resources holds simple functions for synthesizing child resources from an App.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildpackBuildImageDestination

func BuildpackBuildImageDestination(app *v1alpha1.App, space *v1alpha1.Space) string

BuildpackBuildImageDestination gets the image name for an application build.

Example
app := &v1alpha1.App{}
app.Name = "myapp"
app.Namespace = "myspace"
app.Spec.Source.UpdateRequests = 0xfacade

space := &v1alpha1.Space{}
space.Spec.BuildpackBuild.ContainerRegistry = "gcr.io/my-project"

fmt.Println(BuildpackBuildImageDestination(app, space))
Output:

gcr.io/my-project/app_myspace_myapp:facade
Example (NoRegistry)
app := &v1alpha1.App{}
app.Name = "myapp"
app.Namespace = "myspace"
app.Spec.Source.UpdateRequests = 0xfacade

fmt.Println(BuildpackBuildImageDestination(app, &v1alpha1.Space{}))
Output:

app_myspace_myapp:facade

func KfInjectedEnvSecretName

func KfInjectedEnvSecretName(app *v1alpha1.App) string

KfInjectedEnvSecretName gets the name of the secret for the given application.

Example
app := &v1alpha1.App{}
app.Name = "my-app"
space := &v1alpha1.Space{}
space.Name = "my-space"

fmt.Println(KfInjectedEnvSecretName(app))
Output:

kf-injected-envs-my-app

func KnativeServiceName

func KnativeServiceName(app *v1alpha1.App) string

KnativeServiceName gets the name of a Knative Service given the route.

func MakeKfInjectedEnvSecret

func MakeKfInjectedEnvSecret(app *v1alpha1.App, space *v1alpha1.Space, serviceBindings []servicecatalogv1beta1.ServiceBinding, systemEnvInjector cfutil.SystemEnvInjector) (*v1.Secret, error)

MakeKfInjectedEnvSecret creates a Secret containing the env vars for the given application.

func MakeKnativeService

func MakeKnativeService(
	app *v1alpha1.App,
	space *v1alpha1.Space,
) (*serving.Service, error)

MakeKnativeService creates a KnativeService from an app definition.

func MakeRouteAppLabels

func MakeRouteAppLabels(app *v1alpha1.App) map[string]string

MakeRouteAppLabels creates Labels that can be used to lookup the Route for the app.

func MakeRouteAppSelector

func MakeRouteAppSelector(app *v1alpha1.App) labels.Selector

MakeRouteAppSelector creates a labels.Selector for listing all the Routes for the given App.

func MakeRouteLabels

func MakeRouteLabels(spec v1alpha1.RouteSpecFields) map[string]string

MakeRouteLabels creates Labels that can be used to tie a Route to a VirtualService.

Example
l := MakeRouteLabels(v1alpha1.RouteSpecFields{
	Hostname: "some-hostname",
	Domain:   "some-domain",
	Path:     "/some/path",
})

fmt.Println("Managed by:", l[v1alpha1.ManagedByLabel])
fmt.Println("Component Label:", l[v1alpha1.ComponentLabel])
fmt.Println("Route Hostname:", l[v1alpha1.RouteHostname])
fmt.Println("Route Domain:", l[v1alpha1.RouteDomain])
fmt.Println("Route Path (base-36):", l[v1alpha1.RoutePath])
fmt.Printf("Number of Keys: %d\n", len(l))
Output:

Managed by: kf
Component Label: route
Route Hostname: some-hostname
Route Domain: some-domain
Route Path (base-36): 2uusd3k2mp26d
Number of Keys: 5

func MakeRouteSelector

func MakeRouteSelector(spec v1alpha1.RouteSpecFields) labels.Selector

MakeRouteSelector creates a labels.Selector for listing all the corresponding Routes.

func MakeRouteSelectorNoPath

func MakeRouteSelectorNoPath(spec v1alpha1.RouteSpecFields) labels.Selector

MakeRouteSelector creates a labels.Selector for listing all the corresponding Routes excluding Path.

func MakeRoutes

func MakeRoutes(
	app *v1alpha1.App,
	space *v1alpha1.Space,
) (
	[]v1alpha1.Route,
	[]v1alpha1.RouteClaim,
	error,
)

MakeRoutes creates a Route for the given application.

func MakeServiceBindingAppSelector

func MakeServiceBindingAppSelector(appName string) labels.Selector

MakeServiceBindingAppSelector creates a labels.Selector for listing all the Service Bindings for the given App.

func MakeServiceBindingLabels

func MakeServiceBindingLabels(app *v1alpha1.App, binding *v1alpha1.AppSpecServiceBinding) map[string]string

MakeServiceBindingLabels creates labels that can be used to tie a source to a build.

Example
app := &v1alpha1.App{}
app.Name = "my-app"
binding := &v1alpha1.AppSpecServiceBinding{
	Instance:    "my-service",
	BindingName: "cool-binding",
}
app.Spec.ServiceBindings = []v1alpha1.AppSpecServiceBinding{*binding}

labels := MakeServiceBindingLabels(app, binding)
describe.Labels(os.Stdout, labels)
Output:

app.kubernetes.io/component=cool-binding
app.kubernetes.io/managed-by=kf
app.kubernetes.io/name=my-app

func MakeServiceBindingName

func MakeServiceBindingName(app *v1alpha1.App, binding *v1alpha1.AppSpecServiceBinding) string
Example
app := &v1alpha1.App{}
app.Name = "my-app"
binding := &v1alpha1.AppSpecServiceBinding{
	Instance:    "my-service",
	BindingName: "a-cool-binding",
}
app.Spec.ServiceBindings = []v1alpha1.AppSpecServiceBinding{*binding}

fmt.Println(MakeServiceBindingName(app, binding))
Output:

kf-binding-my-app-a-cool-binding

func MakeServiceBindings

func MakeServiceBindings(app *v1alpha1.App) ([]servicecatalogv1beta1.ServiceBinding, error)

func MakeSource

func MakeSource(app *v1alpha1.App, space *v1alpha1.Space) (*v1alpha1.Source, error)

MakeSource creates a source for the given application.

func MakeSourceName

func MakeSourceName(app *v1alpha1.App) string

MakeSourceName creates the name of an Application's source.

func UnionMaps

func UnionMaps(maps ...map[string]string) map[string]string

UnionMaps is similar to github.com/knative/serving/pkg/resources however it takes multiple maps instead of only 2.

Example
x := map[string]string{"a": "1", "b": "x", "c": "x"}
y := map[string]string{"a": "1", "b": "2", "c": "3"}
z := map[string]string{"a": "1", "b": "2", "c": "3"}

result := UnionMaps(x, y, z)

for _, key := range []string{"a", "b", "c"} {
	fmt.Printf("%s: %s\n", key, result[key])
}
Output:

a: 1
b: 2
c: 3

Types

This section is empty.

Jump to

Keyboard shortcuts

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