Documentation
¶
Overview ¶
Package render implements composition rendering using composition functions.
Index ¶
- Constants
- func LoadCompositeResource(fs afero.Fs, file string) (*composite.Unstructured, error)
- func LoadComposition(fs afero.Fs, file string) (*apiextensionsv1.Composition, error)
- func LoadCredentials(fs afero.Fs, file string) ([]corev1.Secret, error)
- func LoadExtraResources(fs afero.Fs, file string) ([]unstructured.Unstructured, error)
- func LoadFunctions(filesys afero.Fs, file string) ([]pkgv1.Function, error)
- func LoadObservedResources(fs afero.Fs, file string) ([]composed.Unstructured, error)
- func LoadYAMLStream(filesys afero.Fs, fileOrDir string) ([][]byte, error)
- func LoadYAMLStreamFromFile(fs afero.Fs, file string) ([][]byte, error)
- func PullImage(ctx context.Context, p pullClient, image string, ...) error
- func SetComposedResourceMetadata(cd resource.Object, xr resource.Composite, name string) error
- type Cmd
- type DockerCleanup
- type DockerPullPolicy
- type FilteringFetcher
- type Inputs
- type Outputs
- type Runtime
- type RuntimeContext
- type RuntimeDevelopment
- type RuntimeDocker
- type RuntimeFunctionRunner
- type RuntimeType
Constants ¶
const ( AnnotationKeyCompositionResourceName = "crossplane.io/composition-resource-name" AnnotationKeyCompositeName = "crossplane.io/composite" AnnotationKeyClaimNamespace = "crossplane.io/claim-namespace" AnnotationKeyClaimName = "crossplane.io/claim-name" )
Annotations added to composed resources.
const ( // AnnotationKeyRuntimeDockerCleanup configures how a Function's Docker // container should be cleaned up once rendering is done. AnnotationKeyRuntimeDockerCleanup = "render.crossplane.io/runtime-docker-cleanup" // AnnotationKeyRuntimeDockerImage overrides the Docker image that will be // used to run the Function. By default render assumes the Function package // (i.e. spec.package) can be used to run the Function. AnnotationKeyRuntimeDockerImage = "render.crossplane.io/runtime-docker-image" // AnnotationKeyRuntimeNamedContainer sets the Docker container name that will // be used for the container. it will also reuse the same container as long as // it is available and also try to restart if it is not running. AnnotationKeyRuntimeNamedContainer = "render.crossplane.io/runtime-docker-name" )
Annotations that can be used to configure the Docker runtime.
const AnnotationKeyRuntime = "render.crossplane.io/runtime"
AnnotationKeyRuntime can be added to a Function to control what runtime is used to run it locally.
const ( // AnnotationKeyRuntimeDevelopmentTarget can be used to configure the gRPC // target where the Function is listening. The default is localhost:9443. AnnotationKeyRuntimeDevelopmentTarget = "render.crossplane.io/runtime-development-target" )
Annotations that can be used to configure the Development runtime.
const AnnotationKeyRuntimeDockerPullPolicy = "render.crossplane.io/runtime-docker-pull-policy"
AnnotationKeyRuntimeDockerPullPolicy can be added to a Function to control how its runtime image is pulled.
Variables ¶
This section is empty.
Functions ¶
func LoadCompositeResource ¶
LoadCompositeResource from a YAML manifest.
func LoadComposition ¶
func LoadComposition(fs afero.Fs, file string) (*apiextensionsv1.Composition, error)
LoadComposition form a YAML manifest.
func LoadCredentials ¶ added in v1.18.0
LoadCredentials from a stream of YAML manifests.
func LoadExtraResources ¶
func LoadExtraResources(fs afero.Fs, file string) ([]unstructured.Unstructured, error)
LoadExtraResources from a stream of YAML manifests.
func LoadFunctions ¶
LoadFunctions from a stream of YAML manifests.
func LoadObservedResources ¶
LoadObservedResources from a stream of YAML manifests.
func LoadYAMLStream ¶
LoadYAMLStream from the supplied file or directory. Returns an array of byte arrays, where each byte array is expected to be a YAML manifest.
func LoadYAMLStreamFromFile ¶
LoadYAMLStreamFromFile from the supplied file. Returns an array of byte arrays, where each byte array is expected to be a YAML manifest.
func PullImage ¶
func PullImage(ctx context.Context, p pullClient, image string, options typesimage.PullOptions) error
PullImage pulls the supplied image using the supplied client. It blocks until the image has either finished pulling or hit an error.
func SetComposedResourceMetadata ¶
SetComposedResourceMetadata sets standard, required composed resource metadata. It's a simplified version of the same function used by Crossplane. Notably it doesn't handle 'nested' XRs - it assumes the supplied XR should be treated as the top-level XR for setting the crossplane.io/composite, crossplane.io/claim-namespace, and crossplane.io/claim-name annotations.
Types ¶
type Cmd ¶
type Cmd struct {
// Arguments.
CompositeResource string `` /* 134-byte string literal not displayed */
Composition string `` /* 134-byte string literal not displayed */
Functions string `` /* 126-byte string literal not displayed */
// Flags. Keep them in alphabetical order.
ContextFiles map[string]string `` /* 154-byte string literal not displayed */
ContextValues map[string]string `` /* 154-byte string literal not displayed */
IncludeFunctionResults bool `` /* 154-byte string literal not displayed */
IncludeFullXR bool `` /* 154-byte string literal not displayed */
ObservedResources string `` /* 187-byte string literal not displayed */
ExtraResources string `` /* 187-byte string literal not displayed */
IncludeContext bool `` /* 154-byte string literal not displayed */
FunctionCredentials string `` /* 175-byte string literal not displayed */
Timeout time.Duration `default:"1m" help:"How long to run before timing out."`
// contains filtered or unexported fields
}
Cmd arguments and flags for render subcommand.
type DockerCleanup ¶
type DockerCleanup string
DockerCleanup specifies what Docker should do with a Function container after it has been run.
const ( // AnnotationValueRuntimeDockerCleanupStop is the default. It stops the // container once rendering is done. AnnotationValueRuntimeDockerCleanupStop DockerCleanup = "Stop" // AnnotationValueRuntimeDockerCleanupRemove stops and removes the // container once rendering is done. AnnotationValueRuntimeDockerCleanupRemove DockerCleanup = "Remove" // AnnotationValueRuntimeDockerCleanupOrphan leaves the container running // once rendering is done. AnnotationValueRuntimeDockerCleanupOrphan DockerCleanup = "Orphan" AnnotationValueRuntimeDockerCleanupDefault = AnnotationValueRuntimeDockerCleanupRemove )
Supported AnnotationKeyRuntimeDockerCleanup values.
func GetDockerCleanup ¶
func GetDockerCleanup(fn pkgv1.Function) (DockerCleanup, error)
GetDockerCleanup extracts Cleanup configuration from the supplied Function.
type DockerPullPolicy ¶
type DockerPullPolicy string
DockerPullPolicy can be added to a Function to control how its runtime image is pulled by Docker.
const ( // Always pull the image. AnnotationValueRuntimeDockerPullPolicyAlways DockerPullPolicy = "Always" // Never pull the image. AnnotationValueRuntimeDockerPullPolicyNever DockerPullPolicy = "Never" // Pull the image if it's not present. AnnotationValueRuntimeDockerPullPolicyIfNotPresent DockerPullPolicy = "IfNotPresent" AnnotationValueRuntimeDockerPullPolicyDefault DockerPullPolicy = AnnotationValueRuntimeDockerPullPolicyIfNotPresent )
Supported pull policies.
func GetDockerPullPolicy ¶
func GetDockerPullPolicy(fn pkgv1.Function) (DockerPullPolicy, error)
GetDockerPullPolicy extracts PullPolicy configuration from the supplied Function.
type FilteringFetcher ¶
type FilteringFetcher struct {
// contains filtered or unexported fields
}
FilteringFetcher is a composite.ExtraResourcesFetcher that "fetches" any supplied resource that matches a resource selector.
func (*FilteringFetcher) Fetch ¶
func (f *FilteringFetcher) Fetch(_ context.Context, rs *fnv1.ResourceSelector) (*fnv1.Resources, error)
Fetch returns all of the underlying extra resources that match the supplied resource selector.
type Inputs ¶
type Inputs struct {
CompositeResource *ucomposite.Unstructured
Composition *apiextensionsv1.Composition
Functions []pkgv1.Function
FunctionCredentials []corev1.Secret
ObservedResources []composed.Unstructured
ExtraResources []unstructured.Unstructured
Context map[string][]byte
}
Inputs contains all inputs to the render process.
type Outputs ¶
type Outputs struct {
CompositeResource *ucomposite.Unstructured
ComposedResources []composed.Unstructured
Results []unstructured.Unstructured
Context *unstructured.Unstructured
}
Outputs contains all outputs from the render process.
type Runtime ¶
type Runtime interface {
// Start the Function.
Start(ctx context.Context) (RuntimeContext, error)
}
A Runtime runs a Function.
type RuntimeContext ¶
type RuntimeContext struct {
// Target for RunFunctionRequest gRPCs.
Target string
// Stop the running Function.
Stop func(context.Context) error
}
RuntimeContext contains context on how a Function is being run.
type RuntimeDevelopment ¶
type RuntimeDevelopment struct {
// Target is the gRPC target for the running function, for example
// localhost:9443.
Target string
// Function is the name of the function to be run.
Function string
// contains filtered or unexported fields
}
RuntimeDevelopment is largely a no-op. It expects you to run the Function manually. This is useful for developing Functions.
func GetRuntimeDevelopment ¶
func GetRuntimeDevelopment(fn pkgv1.Function, log logging.Logger) *RuntimeDevelopment
GetRuntimeDevelopment extracts RuntimeDevelopment configuration from the supplied Function.
func (*RuntimeDevelopment) Start ¶
func (r *RuntimeDevelopment) Start(_ context.Context) (RuntimeContext, error)
Start does nothing. It returns a Stop function that also does nothing.
type RuntimeDocker ¶
type RuntimeDocker struct {
// Image to run
Image string
// Container name
Name string
// Cleanup controls how the containers are handled after rendering.
Cleanup DockerCleanup
// PullPolicy controls how the runtime image is pulled.
PullPolicy DockerPullPolicy
// Keychain to use for pulling images from private registry.
Keychain authn.Keychain
// contains filtered or unexported fields
}
RuntimeDocker uses a Docker daemon to run a Function.
func GetRuntimeDocker ¶
GetRuntimeDocker extracts RuntimeDocker configuration from the supplied Function.
func (*RuntimeDocker) Start ¶
func (r *RuntimeDocker) Start(ctx context.Context) (RuntimeContext, error)
Start a Function as a Docker container.
type RuntimeFunctionRunner ¶
type RuntimeFunctionRunner struct {
// contains filtered or unexported fields
}
A RuntimeFunctionRunner is a composite.FunctionRunner that runs functions locally, using the runtime configured in their annotations (e.g. Docker).
func NewRuntimeFunctionRunner ¶
func NewRuntimeFunctionRunner(ctx context.Context, log logging.Logger, fns []pkgv1.Function) (*RuntimeFunctionRunner, error)
NewRuntimeFunctionRunner returns a FunctionRunner that runs functions locally, using the runtime configured in their annotations (e.g. Docker). It starts all the functions and creates gRPC connections when called.
func (*RuntimeFunctionRunner) RunFunction ¶
func (r *RuntimeFunctionRunner) RunFunction(ctx context.Context, name string, req *fnv1.RunFunctionRequest) (*fnv1.RunFunctionResponse, error)
RunFunction runs the named function.
type RuntimeType ¶
type RuntimeType string
RuntimeType is a type of Function runtime.
const ( // The Docker runtime uses a Docker daemon to run a Function. It uses the // standard DOCKER_ environment variables to determine how to connect to the // daemon. AnnotationValueRuntimeDocker RuntimeType = "Docker" // The Development runtime expects you to deploy a Function locally. This is // mostly useful when developing a Function. The Function must be running // with the --insecure flag, i.e. without transport security. AnnotationValueRuntimeDevelopment RuntimeType = "Development" AnnotationValueRuntimeDefault = AnnotationValueRuntimeDocker )
Supported runtimes.