sources

package
v0.0.0-...-8f52349 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package sources provides access to the Kf build process.

Index

Examples

Constants

View Source
const (
	// Kind contains the kind for the backing Kubernetes API.
	Kind = "Source"

	// APIVersion contains the version for the backing Kubernetes API.
	APIVersion = "kf.dev/v1alpha1"
)

Variables

This section is empty.

Functions

func ConditionDeleted

func ConditionDeleted(_ *v1alpha1.Source, apiErr error) (bool, error)

ConditionDeleted is a ConditionFuncE that succeeds if the error returned by the cluster was a not found error.

func FormatDiff

func FormatDiff(w io.Writer, leftName, rightName string, left, right *v1alpha1.Source)

FormatDiff creates a diff between two v1alpha1.Sources and writes it to the given writer.

func SourceStatus

func SourceStatus(source v1alpha1.Source) (finished bool, err error)

SourceStatus gets the status of the given source. Complete will be set to true if the build has completed (or doesn't exist). Error will be set if the build completed with an error (or doesn't exist). A successful result is one that completed and error is nil.

Types

type BuildTailer

type BuildTailer interface {
	Tail(ctx context.Context, out io.Writer, buildName, namespace string) error
}

BuildTailer is implemented by github.com/knative/build/pkg/logs

type BuildTailerFunc

type BuildTailerFunc func(ctx context.Context, out io.Writer, buildName, namespace string) error

BuildTailerFunc converts a func into a BuildTailer.

func (BuildTailerFunc) Tail

func (f BuildTailerFunc) Tail(ctx context.Context, out io.Writer, buildName, namespace string) error

Tail implements BuildTailer.

type Client

type Client interface {
	Create(namespace string, obj *v1alpha1.Source, opts ...CreateOption) (*v1alpha1.Source, error)
	Update(namespace string, obj *v1alpha1.Source, opts ...UpdateOption) (*v1alpha1.Source, error)
	Transform(namespace string, name string, transformer Mutator) (*v1alpha1.Source, error)
	Get(namespace string, name string, opts ...GetOption) (*v1alpha1.Source, error)
	Delete(namespace string, name string, opts ...DeleteOption) error
	List(namespace string, opts ...ListOption) ([]v1alpha1.Source, error)
	Upsert(namespace string, newObj *v1alpha1.Source, merge Merger) (*v1alpha1.Source, error)
	WaitFor(ctx context.Context, namespace string, name string, interval time.Duration, condition Predicate) (*v1alpha1.Source, error)
	WaitForE(ctx context.Context, namespace string, name string, interval time.Duration, condition ConditionFuncE) (*v1alpha1.Source, error)

	// ClientExtension can be used by the developer to extend the client.
	ClientExtension
}

Client is the interface for interacting with v1alpha1.Source types as Build CF style objects.

func NewClient

func NewClient(kclient cv1alpha1.SourcesGetter, buildTailer BuildTailer) Client

NewClient creates a new build client.

type ClientExtension

type ClientExtension interface {
	Tail(ctx context.Context, namespace, name string, writer io.Writer) error
	Status(namespace, name string) (bool, error)
}

ClientExtension holds additional functions that should be exposed by client.

type ConditionFuncE

type ConditionFuncE func(instance *v1alpha1.Source, 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 CreateOption

type CreateOption func(*createConfig)

CreateOption is a single option for configuring a createConfig

type CreateOptions

type CreateOptions []CreateOption

CreateOptions is a configuration set defining a createConfig

func CreateOptionDefaults

func CreateOptionDefaults() CreateOptions

CreateOptionDefaults gets the default values for Create.

func (CreateOptions) Extend

func (opts CreateOptions) Extend(other CreateOptions) CreateOptions

Extend creates a new CreateOptions with the contents of other overriding the values set in this CreateOptions.

type DeleteOption

type DeleteOption func(*deleteConfig)

DeleteOption is a single option for configuring a deleteConfig

func WithDeleteDeleteImmediately

func WithDeleteDeleteImmediately(val bool) DeleteOption

WithDeleteDeleteImmediately creates an Option that sets If the resource should be deleted immediately.

func WithDeleteForegroundDeletion

func WithDeleteForegroundDeletion(val bool) DeleteOption

WithDeleteForegroundDeletion creates an Option that sets If the resource should be deleted in the foreground.

type DeleteOptions

type DeleteOptions []DeleteOption

DeleteOptions is a configuration set defining a deleteConfig

func DeleteOptionDefaults

func DeleteOptionDefaults() DeleteOptions

DeleteOptionDefaults gets the default values for Delete.

func (DeleteOptions) DeleteImmediately

func (opts DeleteOptions) DeleteImmediately() bool

DeleteImmediately returns the last set value for DeleteImmediately or the empty value if not set.

func (DeleteOptions) Extend

func (opts DeleteOptions) Extend(other DeleteOptions) DeleteOptions

Extend creates a new DeleteOptions with the contents of other overriding the values set in this DeleteOptions.

func (DeleteOptions) ForegroundDeletion

func (opts DeleteOptions) ForegroundDeletion() bool

ForegroundDeletion returns the last set value for ForegroundDeletion or the empty value if not set.

type GetOption

type GetOption func(*getConfig)

GetOption is a single option for configuring a getConfig

type GetOptions

type GetOptions []GetOption

GetOptions is a configuration set defining a getConfig

func GetOptionDefaults

func GetOptionDefaults() GetOptions

GetOptionDefaults gets the default values for Get.

func (GetOptions) Extend

func (opts GetOptions) Extend(other GetOptions) GetOptions

Extend creates a new GetOptions with the contents of other overriding the values set in this GetOptions.

type KfSource

type KfSource v1alpha1.Source

KfSource provides a facade around v1alpha1.Source for accessing and mutating its values.

Example (Buildpack)
source := NewKfSource()

source.SetName("my-buildpack-build")
source.SetNamespace("my-namespace")
source.SetBuildpackBuildSource("gcr.io/my-source-code-image")
source.SetBuildpackBuildEnv([]corev1.EnvVar{{Name: "JAVA_VERSION", Value: "11"}})
source.SetBuildpackBuildBuildpack("java")
source.SetBuildpackBuildImage("gcr.io/some-registry/my-image:latest")
source.SetBuildpackBuildStack("cflinuxfs3")

fmt.Println("Name:", source.GetName())
fmt.Println("Namespace:", source.GetNamespace())
fmt.Println("Source:", source.GetBuildpackBuildSource())
fmt.Println("Buildpack:", source.GetBuildpackBuildBuildpack())
fmt.Println("Image:", source.GetBuildpackBuildImage())
fmt.Println("Stack:", source.GetBuildpackBuildStack())

for _, env := range source.GetBuildpackBuildEnv() {
	fmt.Println("Env:", env.Name, "=", env.Value)
}
Output:

Name: my-buildpack-build
Namespace: my-namespace
Source: gcr.io/my-source-code-image
Buildpack: java
Image: gcr.io/some-registry/my-image:latest
Stack: cflinuxfs3
Env: JAVA_VERSION = 11
Example (Docker)
source := NewKfSource()

source.SetName("my-docker-build")
source.SetNamespace("my-namespace")
source.SetContainerImageSource("mysql/mysql")

fmt.Println("Name:", source.GetName())
fmt.Println("Namespace:", source.GetNamespace())
fmt.Println("Source:", source.GetContainerImageSource())
Output:

Name: my-docker-build
Namespace: my-namespace
Source: mysql/mysql

func NewKfSource

func NewKfSource() KfSource

NewKfSource creates a new KfSource.

func (*KfSource) GetBuildpackBuildBuildpack

func (k *KfSource) GetBuildpackBuildBuildpack() string

GetBuildpackBuildBuildpack gets the buildpack for a buildpack build.

func (*KfSource) GetBuildpackBuildEnv

func (k *KfSource) GetBuildpackBuildEnv() []corev1.EnvVar

GetBuildpackBuildEnv sets the environment variables for a buildpack build.

func (*KfSource) GetBuildpackBuildImage

func (k *KfSource) GetBuildpackBuildImage() string

GetBuildpackBuildImage returns the container image that the built code will be pushed to.

func (*KfSource) GetBuildpackBuildSource

func (k *KfSource) GetBuildpackBuildSource() string

GetBuildpackBuildSource returns the image that contins the build source if this is a buildpack style build.

func (*KfSource) GetBuildpackBuildStack

func (k *KfSource) GetBuildpackBuildStack() string

GetBuildpackBuildStack gets the stack to use with a buildpack build.

func (*KfSource) GetContainerImageSource

func (k *KfSource) GetContainerImageSource() string

GetContainerImageSource gets the container image source.

func (*KfSource) GetName

func (k *KfSource) GetName() string

GetName retrieves the name of the space.

func (*KfSource) GetNamespace

func (k *KfSource) GetNamespace() string

GetNamespace retrieves the namespace for the source.

func (*KfSource) SetBuildpackBuildBuildpack

func (k *KfSource) SetBuildpackBuildBuildpack(buildpack string)

SetBuildpackBuildBuildpack sets the buildpack for a buildpack build.

func (*KfSource) SetBuildpackBuildEnv

func (k *KfSource) SetBuildpackBuildEnv(env []corev1.EnvVar)

SetBuildpackBuildEnv sets the environment variables for a buildpack build.

func (*KfSource) SetBuildpackBuildImage

func (k *KfSource) SetBuildpackBuildImage(registry string)

SetBuildpackBuildImage sets the container image that the built code will be pushed to.

func (*KfSource) SetBuildpackBuildSource

func (k *KfSource) SetBuildpackBuildSource(sourceImage string)

SetBuildpackBuildSource sets the image that contains the source code.

func (*KfSource) SetBuildpackBuildStack

func (k *KfSource) SetBuildpackBuildStack(stack string)

SetBuildpackBuildStack sets the stack to use with a buildpack build.

func (*KfSource) SetContainerImageSource

func (k *KfSource) SetContainerImageSource(sourceImage string)

SetContainerImageSource sets an image as a container image source.

func (*KfSource) SetName

func (k *KfSource) SetName(name string)

SetName sets the name of the space.

func (*KfSource) SetNamespace

func (k *KfSource) SetNamespace(namespace string)

SetNamespace sets the namespace for the source.

func (*KfSource) ToSource

func (k *KfSource) ToSource() *v1alpha1.Source

ToSource casts this alias back into a Namespace.

type List

type List []v1alpha1.Source

List represents a collection of v1alpha1.Source.

func (List) Filter

func (list List) Filter(filter Predicate) (out List)

Filter returns a new list items for which the predicates fails removed.

type ListOption

type ListOption func(*listConfig)

ListOption is a single option for configuring a listConfig

func WithListFieldSelector

func WithListFieldSelector(val map[string]string) ListOption

WithListFieldSelector creates an Option that sets A selector on the resource's fields.

func WithListFilters

func WithListFilters(val []Predicate) ListOption

WithListFilters creates an Option that sets Additional filters to apply.

func WithListLabelSelector

func WithListLabelSelector(val map[string]string) ListOption

WithListLabelSelector creates an Option that sets A label selector.

type ListOptions

type ListOptions []ListOption

ListOptions is a configuration set defining a listConfig

func ListOptionDefaults

func ListOptionDefaults() ListOptions

ListOptionDefaults gets the default values for List.

func (ListOptions) Extend

func (opts ListOptions) Extend(other ListOptions) ListOptions

Extend creates a new ListOptions with the contents of other overriding the values set in this ListOptions.

type Merger

type Merger func(newObj, oldObj *v1alpha1.Source) *v1alpha1.Source

Merger is a type to merge an existing value with a new one.

type Mutator

type Mutator func(*v1alpha1.Source) error

Mutator is a function that changes v1alpha1.Source.

func DiffWrapper

func DiffWrapper(w io.Writer, mutator Mutator) Mutator

DiffWrapper wraps a mutator and prints out the diff between the original object and the one it returns if there's no error.

func LabelSetMutator

func LabelSetMutator(labels map[string]string) Mutator

LabelSetMutator creates a mutator that sets the given labels on the object.

type MutatorList

type MutatorList []Mutator

MutatorList is a list of mutators.

func (MutatorList) Apply

func (list MutatorList) Apply(svc *v1alpha1.Source) error

Apply passes the given value to each of the mutators in the list failing if one of them returns an error.

type Predicate

type Predicate func(*v1alpha1.Source) bool

Predicate is a boolean function for a v1alpha1.Source.

func AllPredicate

func AllPredicate(children ...Predicate) Predicate

AllPredicate is a predicate that passes if all children pass.

func LabelEqualsPredicate

func LabelEqualsPredicate(key, value string) Predicate

LabelEqualsPredicate validates that the given label exists exactly on the object.

func LabelsContainsPredicate

func LabelsContainsPredicate(key string) Predicate

LabelsContainsPredicate validates that the given label exists on the object.

type UpdateOption

type UpdateOption func(*updateConfig)

UpdateOption is a single option for configuring a updateConfig

type UpdateOptions

type UpdateOptions []UpdateOption

UpdateOptions is a configuration set defining a updateConfig

func UpdateOptionDefaults

func UpdateOptionDefaults() UpdateOptions

UpdateOptionDefaults gets the default values for Update.

func (UpdateOptions) Extend

func (opts UpdateOptions) Extend(other UpdateOptions) UpdateOptions

Extend creates a new UpdateOptions with the contents of other overriding the values set in this UpdateOptions.

Directories

Path Synopsis
Package fake is a generated GoMock package.
Package fake is a generated GoMock package.

Jump to

Keyboard shortcuts

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