Documentation ¶
Overview ¶
Package apps provides a cf compatible way of managing Knative Services as cf apps.
Index ¶
- Variables
- func ConditionDeleted(ctx context.Context, _ *v1alpha1.App, apiErr error) (bool, error)
- func ConditionKnativeServiceReadyTrue(ctx context.Context, obj *v1alpha1.App, err error) (bool, error)
- func ConditionReadyTrue(ctx context.Context, obj *v1alpha1.App, err error) (bool, error)
- func ConditionRoutesReadyTrue(ctx context.Context, obj *v1alpha1.App, err error) (bool, error)
- func ConditionServiceInstanceBindingsReadyTrue(ctx context.Context, obj *v1alpha1.App, err error) (bool, error)
- func ExtractConditions(obj *v1alpha1.App) (extracted []apis.Condition)
- func JoinRepositoryImage(repository, imageName string) string
- func ObservedGenerationMatchesGeneration(obj *v1alpha1.App) bool
- func SourceImageName(namespace, appName string) string
- func WithConditionReporter(ctx context.Context, reporter ConditionReporter) context.Context
- type Client
- type ClientExtension
- type ConditionFuncE
- type ConditionReporter
- type KfApp
- func (k *KfApp) DeleteEnvVars(names []string)
- func (k *KfApp) GetEnvVars() []corev1.EnvVar
- func (k *KfApp) HasMatchingRoutes(claim v1alpha1.RouteSpecFields) bool
- func (k *KfApp) MergeEnvVars(env []corev1.EnvVar)
- func (k *KfApp) MergeRoute(route v1alpha1.RouteWeightBinding)
- func (k *KfApp) RemoveRoute(ctx context.Context, toRemove v1alpha1.RouteWeightBinding)
- func (k *KfApp) RemoveRoutesForClaim(claim v1alpha1.RouteSpecFields)
- func (k *KfApp) SetEnvVars(env []corev1.EnvVar)
- func (k *KfApp) ToApp() *v1alpha1.App
- type Merger
- type Mutator
- type Predicate
- type PushOption
- func WithPushADXBuild(val bool) PushOption
- func WithPushADXContainerRegistry(val string) PushOption
- func WithPushADXDockerfile(val string) PushOption
- func WithPushADXStack(val config.StackV3Definition) PushOption
- func WithPushAnnotations(val map[string]string) PushOption
- func WithPushAppSpecInstances(val v1alpha1.AppSpecInstances) PushOption
- func WithPushBuild(val *v1alpha1.BuildSpec) PushOption
- func WithPushContainer(val corev1.Container) PushOption
- func WithPushContainerImage(val *string) PushOption
- func WithPushGenerateDefaultRoute(val bool) PushOption
- func WithPushGenerateRandomRoute(val bool) PushOption
- func WithPushLabels(val map[string]string) PushOption
- func WithPushOutput(val io.Writer) PushOption
- func WithPushRoutes(val []v1alpha1.RouteWeightBinding) PushOption
- func WithPushServiceBindings(val []v1alpha1.ServiceInstanceBinding) PushOption
- func WithPushSourcePath(val string) PushOption
- func WithPushSpace(val string) PushOption
- type PushOptions
- func (opts PushOptions) ADXBuild() bool
- func (opts PushOptions) ADXContainerRegistry() string
- func (opts PushOptions) ADXDockerfile() string
- func (opts PushOptions) ADXStack() config.StackV3Definition
- func (opts PushOptions) Annotations() map[string]string
- func (opts PushOptions) AppSpecInstances() v1alpha1.AppSpecInstances
- func (opts PushOptions) Build() *v1alpha1.BuildSpec
- func (opts PushOptions) Container() corev1.Container
- func (opts PushOptions) ContainerImage() *string
- func (opts PushOptions) Extend(other PushOptions) PushOptions
- func (opts PushOptions) GenerateDefaultRoute() bool
- func (opts PushOptions) GenerateRandomRoute() bool
- func (opts PushOptions) Labels() map[string]string
- func (opts PushOptions) Output() io.Writer
- func (opts PushOptions) Routes() []v1alpha1.RouteWeightBinding
- func (opts PushOptions) ServiceBindings() []v1alpha1.ServiceInstanceBinding
- func (opts PushOptions) SourcePath() string
- func (opts PushOptions) Space() string
- type Pusher
- type ResourceInfo
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( ConditionReady = apis.ConditionType(v1alpha1.AppConditionReady) ConditionServiceInstanceBindingsReady = apis.ConditionType(v1alpha1.AppConditionServiceInstanceBindingsReady) ConditionKnativeServiceReady = apis.ConditionType(v1alpha1.AppConditionDeploymentReady) ConditionRoutesReady = apis.ConditionType(v1alpha1.AppConditionRouteReady) )
Functions ¶
func ConditionDeleted ¶
ConditionDeleted is a ConditionFuncE that succeeds if the error returned by the cluster was a not found error.
func ConditionKnativeServiceReadyTrue ¶
func ConditionKnativeServiceReadyTrue(ctx context.Context, obj *v1alpha1.App, err error) (bool, error)
ConditionKnativeServiceReadyTrue is a ConditionFuncE that waits for Condition{KnativeServiceReady v1alpha1.AppConditionDeploymentReady } to become true and fails with an error if the condition becomes false.
func ConditionReadyTrue ¶
ConditionReadyTrue is a ConditionFuncE that waits for Condition{Ready v1alpha1.AppConditionReady } to become true and fails with an error if the condition becomes false.
func ConditionRoutesReadyTrue ¶
ConditionRoutesReadyTrue is a ConditionFuncE that waits for Condition{RoutesReady v1alpha1.AppConditionRouteReady } to become true and fails with an error if the condition becomes false.
func ConditionServiceInstanceBindingsReadyTrue ¶
func ConditionServiceInstanceBindingsReadyTrue(ctx context.Context, obj *v1alpha1.App, err error) (bool, error)
ConditionServiceInstanceBindingsReadyTrue is a ConditionFuncE that waits for Condition{ServiceInstanceBindingsReady v1alpha1.AppConditionServiceInstanceBindingsReady } to become true and fails with an error if the condition becomes false.
func ExtractConditions ¶
ExtractConditions converts the native condition types into an apis.Condition array with the Type, Status, Reason, and Message fields intact.
func JoinRepositoryImage ¶
JoinRepositoryImage joins a repository and image name.
func ObservedGenerationMatchesGeneration ¶
ObservedGenerationMatchesGeneration is a predicate that returns true if the object's ObservedGeneration matches the genration of the object.
func SourceImageName ¶
SourceImageName gets the image name for source code for an application.
func WithConditionReporter ¶ added in v2.11.16
func WithConditionReporter(ctx context.Context, reporter ConditionReporter) context.Context
WithConditionReporter adds a callback to condition waits.
Types ¶
type Client ¶
type Client interface { Create(ctx context.Context, namespace string, obj *v1alpha1.App) (*v1alpha1.App, error) Transform(ctx context.Context, namespace string, name string, transformer Mutator) (*v1alpha1.App, error) Get(ctx context.Context, namespace string, name string) (*v1alpha1.App, error) Delete(ctx context.Context, namespace string, name string) error List(ctx context.Context, namespace string) ([]v1alpha1.App, error) Upsert(ctx context.Context, namespace string, newObj *v1alpha1.App, merge Merger) (*v1alpha1.App, error) WaitFor(ctx context.Context, namespace string, name string, interval time.Duration, condition Predicate) (*v1alpha1.App, error) // Utility functions WaitForDeletion(ctx context.Context, namespace string, name string, interval time.Duration) (*v1alpha1.App, error) WaitForConditionReadyTrue(ctx context.Context, namespace string, name string, interval time.Duration) (*v1alpha1.App, error) WaitForConditionServiceInstanceBindingsReadyTrue(ctx context.Context, namespace string, name string, interval time.Duration) (*v1alpha1.App, error) WaitForConditionKnativeServiceReadyTrue(ctx context.Context, namespace string, name string, interval time.Duration) (*v1alpha1.App, error) WaitForConditionRoutesReadyTrue(ctx context.Context, namespace string, name string, interval time.Duration) (*v1alpha1.App, error) // ClientExtension can be used by the developer to extend the client. ClientExtension }
Client is the interface for interacting with v1alpha1.App types as App CF style objects.
type ClientExtension ¶
type ClientExtension interface { DeployLogsForApp(ctx context.Context, out io.Writer, app *v1alpha1.App) error DeployLogs(ctx context.Context, out io.Writer, appName, resourceVersion, namespace string, noStart bool) error Restart(ctx context.Context, namespace, name string) error Restage(ctx context.Context, namespace, name string) (*v1alpha1.App, error) }
ClientExtension holds additional functions that should be exposed by client.
type ConditionFuncE ¶
type ConditionFuncE func(ctx context.Context, instance *v1alpha1.App, apiErr error) (done bool, err error)
ConditionFuncE is a callback used by waitForE. Done should be set to true once the condition succeeds and shouldn't be called anymore. The error will be passed back to the user.
This function MAY retrieve a nil instance and an apiErr. It's up to the function to decide how to handle the apiErr.
type ConditionReporter ¶ added in v2.11.16
type ConditionReporter func(message string)
ConditionReporter reports on changes to conditions while waiting.
type KfApp ¶
KfApp provides a facade around Knative services for accessing and mutating its values.
Example ¶
space := NewKfApp() // Setup space.SetName("nsname") // Values fmt.Println(space.GetName())
Output: nsname
func NewFromApp ¶
NewFromApp creates a new KfApp from the given service pointer modifications to the KfApp will affect the underling app.
func (*KfApp) DeleteEnvVars ¶
DeleteEnvVars removes environment variables with the given key.
Example ¶
myApp := NewKfApp() myApp.SetEnvVars([]corev1.EnvVar{ {Name: "FOO", Value: "0"}, {Name: "BAR", Value: "0"}, }) myApp.DeleteEnvVars([]string{"FOO", "DOES_NOT_EXIST"}) for _, e := range myApp.GetEnvVars() { fmt.Println("Key", e.Name, "Value", e.Value) }
Output: Key BAR Value 0
func (*KfApp) GetEnvVars ¶
GetEnvVars reads the environment variables off an app.
Example ¶
myApp := NewKfApp() myApp.SetEnvVars([]corev1.EnvVar{ {Name: "FOO", Value: "2"}, {Name: "BAR", Value: "0"}, }) env := myApp.GetEnvVars() for _, e := range env { fmt.Println("Key", e.Name, "Value", e.Value) }
Output: Key FOO Value 2 Key BAR Value 0
Example (EmptyApp) ¶
myApp := NewKfApp() env := myApp.GetEnvVars() fmt.Println(env)
Output: []
func (*KfApp) HasMatchingRoutes ¶
func (k *KfApp) HasMatchingRoutes(claim v1alpha1.RouteSpecFields) bool
HasMatchingRoutes checks if any of the listed routes point to the claim.
func (*KfApp) MergeEnvVars ¶
MergeEnvVars adds the environment variables listed to the existing ones, overwriting duplicates by key.
Example ¶
myApp := NewKfApp() myApp.SetEnvVars([]corev1.EnvVar{ {Name: "FOO", Value: "0"}, {Name: "BAR", Value: "0"}, }) myApp.MergeEnvVars([]corev1.EnvVar{ {Name: "FOO", Value: "1"}, // will replace old {Name: "BAZZ", Value: "0"}, // will be added }) env := myApp.GetEnvVars() for _, e := range env { fmt.Println("Key", e.Name, "Value", e.Value) }
Output: Key BAR Value 0 Key BAZZ Value 0 Key FOO Value 1
func (*KfApp) MergeRoute ¶
func (k *KfApp) MergeRoute(route v1alpha1.RouteWeightBinding)
MergeRoute adds a route to the App, removing any duplicates that already exist.
func (*KfApp) RemoveRoute ¶
func (k *KfApp) RemoveRoute(ctx context.Context, toRemove v1alpha1.RouteWeightBinding)
RemoveRoute removes any routes matching the binding.
func (*KfApp) RemoveRoutesForClaim ¶
func (k *KfApp) RemoveRoutesForClaim(claim v1alpha1.RouteSpecFields)
RemoveRoutesForClaim removes all routes matching the given claim.
func (*KfApp) SetEnvVars ¶
SetEnvVars sets environment variables on an app.
type PushOption ¶
type PushOption func(*pushConfig)
PushOption is a single option for configuring a pushConfig
func WithPushADXBuild ¶
func WithPushADXBuild(val bool) PushOption
WithPushADXBuild creates an Option that sets use AppDevExperience for builds
func WithPushADXContainerRegistry ¶
func WithPushADXContainerRegistry(val string) PushOption
WithPushADXContainerRegistry creates an Option that sets the container registry configured on the Space
func WithPushADXDockerfile ¶
func WithPushADXDockerfile(val string) PushOption
WithPushADXDockerfile creates an Option that sets the path to the dockerfile to us with the AppDevExperience build
func WithPushADXStack ¶
func WithPushADXStack(val config.StackV3Definition) PushOption
WithPushADXStack creates an Option that sets the stack to use with the AppDevExperience build
func WithPushAnnotations ¶ added in v2.11.7
func WithPushAnnotations(val map[string]string) PushOption
WithPushAnnotations creates an Option that sets Annotations to add to the pushed app.
func WithPushAppSpecInstances ¶
func WithPushAppSpecInstances(val v1alpha1.AppSpecInstances) PushOption
WithPushAppSpecInstances creates an Option that sets Scaling information for the service
func WithPushBuild ¶
func WithPushBuild(val *v1alpha1.BuildSpec) PushOption
WithPushBuild creates an Option that sets a custom Tekton task used for the build
func WithPushContainer ¶
func WithPushContainer(val corev1.Container) PushOption
WithPushContainer creates an Option that sets the app container template
func WithPushContainerImage ¶
func WithPushContainerImage(val *string) PushOption
WithPushContainerImage creates an Option that sets the container to deploy
func WithPushGenerateDefaultRoute ¶
func WithPushGenerateDefaultRoute(val bool) PushOption
WithPushGenerateDefaultRoute creates an Option that sets returns true if the app should receive a default route if a route does not already exist
func WithPushGenerateRandomRoute ¶
func WithPushGenerateRandomRoute(val bool) PushOption
WithPushGenerateRandomRoute creates an Option that sets returns true if the app should receive a random route if a route doesn't already exist
func WithPushLabels ¶ added in v2.11.7
func WithPushLabels(val map[string]string) PushOption
WithPushLabels creates an Option that sets Labels to add to the pushed app.
func WithPushOutput ¶
func WithPushOutput(val io.Writer) PushOption
WithPushOutput creates an Option that sets the io.Writer to write output such as build logs
func WithPushRoutes ¶
func WithPushRoutes(val []v1alpha1.RouteWeightBinding) PushOption
WithPushRoutes creates an Option that sets routes for the app
func WithPushServiceBindings ¶
func WithPushServiceBindings(val []v1alpha1.ServiceInstanceBinding) PushOption
WithPushServiceBindings creates an Option that sets a list of Services to bind to the app
func WithPushSourcePath ¶
func WithPushSourcePath(val string) PushOption
WithPushSourcePath creates an Option that sets the path to the source code directory
func WithPushSpace ¶
func WithPushSpace(val string) PushOption
WithPushSpace creates an Option that sets the Space to use
type PushOptions ¶
type PushOptions []PushOption
PushOptions is a configuration set defining a pushConfig
func PushOptionDefaults ¶
func PushOptionDefaults() PushOptions
PushOptionDefaults gets the default values for Push.
func (PushOptions) ADXBuild ¶
func (opts PushOptions) ADXBuild() bool
ADXBuild returns the last set value for ADXBuild or the empty value if not set.
func (PushOptions) ADXContainerRegistry ¶
func (opts PushOptions) ADXContainerRegistry() string
ADXContainerRegistry returns the last set value for ADXContainerRegistry or the empty value if not set.
func (PushOptions) ADXDockerfile ¶
func (opts PushOptions) ADXDockerfile() string
ADXDockerfile returns the last set value for ADXDockerfile or the empty value if not set.
func (PushOptions) ADXStack ¶
func (opts PushOptions) ADXStack() config.StackV3Definition
ADXStack returns the last set value for ADXStack or the empty value if not set.
func (PushOptions) Annotations ¶ added in v2.11.7
func (opts PushOptions) Annotations() map[string]string
Annotations returns the last set value for Annotations or the empty value if not set.
func (PushOptions) AppSpecInstances ¶
func (opts PushOptions) AppSpecInstances() v1alpha1.AppSpecInstances
AppSpecInstances returns the last set value for AppSpecInstances or the empty value if not set.
func (PushOptions) Build ¶
func (opts PushOptions) Build() *v1alpha1.BuildSpec
Build returns the last set value for Build or the empty value if not set.
func (PushOptions) Container ¶
func (opts PushOptions) Container() corev1.Container
Container returns the last set value for Container or the empty value if not set.
func (PushOptions) ContainerImage ¶
func (opts PushOptions) ContainerImage() *string
ContainerImage returns the last set value for ContainerImage or the empty value if not set.
func (PushOptions) Extend ¶
func (opts PushOptions) Extend(other PushOptions) PushOptions
Extend creates a new PushOptions with the contents of other overriding the values set in this PushOptions.
func (PushOptions) GenerateDefaultRoute ¶
func (opts PushOptions) GenerateDefaultRoute() bool
GenerateDefaultRoute returns the last set value for GenerateDefaultRoute or the empty value if not set.
func (PushOptions) GenerateRandomRoute ¶
func (opts PushOptions) GenerateRandomRoute() bool
GenerateRandomRoute returns the last set value for GenerateRandomRoute or the empty value if not set.
func (PushOptions) Labels ¶ added in v2.11.7
func (opts PushOptions) Labels() map[string]string
Labels returns the last set value for Labels or the empty value if not set.
func (PushOptions) Output ¶
func (opts PushOptions) Output() io.Writer
Output returns the last set value for Output or the empty value if not set.
func (PushOptions) Routes ¶
func (opts PushOptions) Routes() []v1alpha1.RouteWeightBinding
Routes returns the last set value for Routes or the empty value if not set.
func (PushOptions) ServiceBindings ¶
func (opts PushOptions) ServiceBindings() []v1alpha1.ServiceInstanceBinding
ServiceBindings returns the last set value for ServiceBindings or the empty value if not set.
func (PushOptions) SourcePath ¶
func (opts PushOptions) SourcePath() string
SourcePath returns the last set value for SourcePath or the empty value if not set.
func (PushOptions) Space ¶
func (opts PushOptions) Space() string
Space returns the last set value for Space or the empty value if not set.
type Pusher ¶
type Pusher interface { // Push deploys an application. Push(ctx context.Context, appName string, opts ...PushOption) error // CreatePlaceholderApp creates a valid stopped application with the given name // if the App doesn't exist yet. CreatePlaceholderApp(ctx context.Context, appName string, opts ...PushOption) (*v1alpha1.App, error) }
Pusher deploys applications.
func NewPusher ¶
func NewPusher( appsClient Client, bindingsClient serviceinstancebindings.Client, secretClient secrets.Client, sourcePackageClient sourcepackages.Client, poster sourcepackages.Poster, ) Pusher
NewPusher creates a new Pusher.
type ResourceInfo ¶
type ResourceInfo struct{}
func NewResourceInfo ¶
func NewResourceInfo() *ResourceInfo
NewResourceInfo returns a new instance of ResourceInfo
func (*ResourceInfo) FriendlyName ¶
func (*ResourceInfo) FriendlyName() string
FriendlyName gets the user-facing name of the resource.
func (*ResourceInfo) GroupVersionKind ¶
func (*ResourceInfo) GroupVersionKind(context.Context) schema.GroupVersionKind
GroupVersionKind gets the GVK struct for the resource.
func (*ResourceInfo) GroupVersionResource ¶
func (*ResourceInfo) GroupVersionResource(context.Context) schema.GroupVersionResource
GroupVersionResource gets the GVR struct for the resource.
func (*ResourceInfo) Namespaced ¶
func (*ResourceInfo) Namespaced() bool
Namespaced returns true if the type belongs in a namespace.