Documentation ¶
Overview ¶
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func AppendAdditionalManifests(ctx context.Context, manifest *mf.Manifest, instance v1alpha1.KComponent) error
- func AppendInstalled(ctx context.Context, manifest *mf.Manifest, instance v1alpha1.KComponent) error
- func AppendTarget(ctx context.Context, manifest *mf.Manifest, instance v1alpha1.KComponent) error
- func CheckDeployments(ctx context.Context, manifest *mf.Manifest, instance v1alpha1.KComponent) error
- func ClearCache()
- func ClusterScopedResource(apiVersion, kind, name string) *unstructured.Unstructured
- func ConfigMapTransform(config v1alpha1.ConfigMapData, log *zap.SugaredLogger) mf.Transformer
- func DeploymentsTransform(obj v1alpha1.KComponent, log *zap.SugaredLogger) mf.Transformer
- func FetchManifest(path string) (mf.Manifest, error)
- func FinalizerRemovalPatch(obj v1alpha1.KComponent, toRemove string) ([]byte, error)
- func HighAvailabilityTransform(obj v1alpha1.KComponent, log *zap.SugaredLogger) mf.Transformer
- func ImageTransform(registry *v1alpha1.Registry, log *zap.SugaredLogger) mf.Transformer
- func Install(ctx context.Context, manifest *mf.Manifest, instance v1alpha1.KComponent) error
- func InstalledManifest(instance v1alpha1.KComponent) (mf.Manifest, error)
- func IsVersionValidMigrationEligible(instance v1alpha1.KComponent) error
- func JobTransform(obj v1alpha1.KComponent) mf.Transformer
- func NamespacedResource(apiVersion, kind, ns, name string) *unstructured.Unstructured
- func NoOp(context.Context, *mf.Manifest, v1alpha1.KComponent) error
- func ResourceImageTransformer(imageTransformer ImageTransformer, log *zap.SugaredLogger) mf.Transformer
- func ResourceRequirementsTransform(resources []v1alpha1.ResourceRequirementsOverride, log *zap.SugaredLogger) mf.Transformer
- func SanitizeSemver(version string) string
- func TargetAdditionalManifest(instance v1alpha1.KComponent) (mf.Manifest, error)
- func TargetManifest(instance v1alpha1.KComponent) (mf.Manifest, error)
- func TargetVersion(instance v1alpha1.KComponent) string
- func Transform(ctx context.Context, manifest *mf.Manifest, instance v1alpha1.KComponent, ...) error
- func Uninstall(manifest *mf.Manifest) error
- func UpdateConfigMap(cm *unstructured.Unstructured, data map[string]string, log *zap.SugaredLogger) error
- type Extension
- type ExtensionGenerator
- type ImageTransformer
- type ManifestFetcher
- type Stage
- type Stages
Constants ¶
const ( // KoEnvKey is the key of the environment variable to specify the path to the ko data directory KoEnvKey = "KO_DATA_PATH" // VersionVariable is a string, which can be replaced with the value of spec.version VersionVariable = "${VERSION}" // COMMA is the character comma COMMA = "," // LATEST_VERSION is the special version Knative Operator support, besides all semantic versions of Knative. LATEST_VERSION = "latest" )
Variables ¶
This section is empty.
Functions ¶
func AppendAdditionalManifests ¶ added in v0.22.0
func AppendAdditionalManifests(ctx context.Context, manifest *mf.Manifest, instance v1alpha1.KComponent) error
AppendAdditionalManifests mutates the passed manifest by appending the manifests specified with the field spec.additionalManifests.
func AppendInstalled ¶ added in v0.16.0
func AppendInstalled(ctx context.Context, manifest *mf.Manifest, instance v1alpha1.KComponent) error
AppendInstalled mutates the passed manifest by appending one appropriate for the passed KComponent, which may not be the one corresponding to status.version
func AppendTarget ¶ added in v0.16.0
AppendTarget mutates the passed manifest by appending one appropriate for the passed KComponent
func CheckDeployments ¶
func CheckDeployments(ctx context.Context, manifest *mf.Manifest, instance v1alpha1.KComponent) error
CheckDeployments checks all deployments in the given manifest and updates the given status with the status of the deployments.
func ClearCache ¶ added in v0.22.0
func ClearCache()
ClearCache removes all the records saved in the cache.
func ClusterScopedResource ¶
func ClusterScopedResource(apiVersion, kind, name string) *unstructured.Unstructured
ClusterScopedResource is an unstructured resource with the given apiVersion, kind and name.
func ConfigMapTransform ¶
func ConfigMapTransform(config v1alpha1.ConfigMapData, log *zap.SugaredLogger) mf.Transformer
ConfigMapTransform updates the ConfigMap with the values specified in operator CR
func DeploymentsTransform ¶ added in v0.21.0
func DeploymentsTransform(obj v1alpha1.KComponent, log *zap.SugaredLogger) mf.Transformer
DeploymentTransform transforms deployments based on the configuration in `spec.deployment`.
func FetchManifest ¶ added in v0.21.0
FetchManifest returns the manifest by either getting it from the cache, or reading them from the path. The manifest is saved in the cache, if it is not available.
func FinalizerRemovalPatch ¶
func FinalizerRemovalPatch(obj v1alpha1.KComponent, toRemove string) ([]byte, error)
FinalizerRemovalPatch generates a patch for removing the given finalizer.
func HighAvailabilityTransform ¶ added in v0.21.0
func HighAvailabilityTransform(obj v1alpha1.KComponent, log *zap.SugaredLogger) mf.Transformer
HighAvailabilityTransform mutates configmaps and replicacounts of certain controllers when HA control plane is specified.
func ImageTransform ¶
func ImageTransform(registry *v1alpha1.Registry, log *zap.SugaredLogger) mf.Transformer
ImageTransform updates image with a new registry and tag
func Install ¶
Install applies the manifest resources for the given version and updates the given status accordingly.
func InstalledManifest ¶ added in v0.16.0
func InstalledManifest(instance v1alpha1.KComponent) (mf.Manifest, error)
InstalledManifest returns the version currently installed, which is harder than it sounds, since status.version isn't set until the target version is successfully installed, which can take some time. So we return the target manifest if status.version is empty.
func IsVersionValidMigrationEligible ¶ added in v0.19.0
func IsVersionValidMigrationEligible(instance v1alpha1.KComponent) error
IsVersionValidMigrationEligible returns the bool indicate whether the target version is valid and the installed manifest is able to upgrade or downgrade to the target manifest.
func JobTransform ¶ added in v0.16.0
func JobTransform(obj v1alpha1.KComponent) mf.Transformer
JobTransform updates the job with the expected value for the key app in the label
func NamespacedResource ¶
func NamespacedResource(apiVersion, kind, ns, name string) *unstructured.Unstructured
NamespacedResource is an unstructured resource with the given apiVersion, kind, ns and name.
func ResourceImageTransformer ¶ added in v0.16.0
func ResourceImageTransformer(imageTransformer ImageTransformer, log *zap.SugaredLogger) mf.Transformer
ResourceImageTransformer takes an ImageTransformer and transform images across resources
func ResourceRequirementsTransform ¶
func ResourceRequirementsTransform(resources []v1alpha1.ResourceRequirementsOverride, log *zap.SugaredLogger) mf.Transformer
ResourceRequirementsTransform configures the resource requests for all containers within all deployments in the manifest
func SanitizeSemver ¶ added in v0.21.0
SanitizeSemver always adds `v` in front of the version. x.y.z is the standard format we use as the semantic version for Knative. The letter `v` is added for comparison purpose.
func TargetAdditionalManifest ¶ added in v0.22.0
func TargetAdditionalManifest(instance v1alpha1.KComponent) (mf.Manifest, error)
TargetAdditionalManifest returns the manifest for the TargetVersion specified with spec.additionalManifests.
func TargetManifest ¶ added in v0.16.0
func TargetManifest(instance v1alpha1.KComponent) (mf.Manifest, error)
TargetManifest returns the default manifest for the TargetVersion or the manifest for the TargetVersion specified with spec.manifests
func TargetVersion ¶ added in v0.16.0
func TargetVersion(instance v1alpha1.KComponent) string
TargetVersion returns the version of the manifest to be installed per the spec in the component. If spec.version is empty, the latest version known to the operator is returned.
func Transform ¶ added in v0.16.0
func Transform(ctx context.Context, manifest *mf.Manifest, instance v1alpha1.KComponent, extra ...mf.Transformer) error
Transform will mutate the passed-by-reference manifest with one transformed by platform, common, and any extra passed in
func Uninstall ¶
Uninstall removes all resources except CRDs, which are never deleted automatically.
func UpdateConfigMap ¶
func UpdateConfigMap(cm *unstructured.Unstructured, data map[string]string, log *zap.SugaredLogger) error
UpdateConfigMap set some data in a configmap, only overwriting common keys if they differ
Types ¶
type Extension ¶ added in v0.16.0
type Extension interface { Manifests(v1alpha1.KComponent) ([]mf.Manifest, error) Transformers(v1alpha1.KComponent) []mf.Transformer Reconcile(context.Context, v1alpha1.KComponent) error Finalize(context.Context, v1alpha1.KComponent) error }
Extension enables platform-specific features
func NoExtension ¶ added in v0.16.0
NoPlatform "generates" a NilExtension
type ExtensionGenerator ¶ added in v0.16.0
ExtensionGenerator creates an Extension from a Context
type ImageTransformer ¶ added in v0.16.0
type ImageTransformer interface { ImageForContainer(container *corev1.Container, parentName string) (string, bool) ImageForEnvVar(env *corev1.EnvVar, parentName string) (string, bool) ImageForImage(image *caching.Image, parentName string) (string, bool) HandleImagePullSecrets(imagePullSecrets []corev1.LocalObjectReference, log *zap.SugaredLogger) []corev1.LocalObjectReference }
ImageTransformer is an interface for transforming images passed to the ResourceImageTransformer
type ManifestFetcher ¶ added in v0.16.0
ManifestFetcher returns a manifest appropriate for the instance
type Stage ¶ added in v0.16.0
Stage represents a step in the reconcile process
func DeleteObsoleteResources ¶ added in v0.16.0
func DeleteObsoleteResources(ctx context.Context, instance v1alpha1.KComponent, fetch ManifestFetcher) Stage
DeleteObsoleteResources returns a Stage after calculating the installed manifest from the instance. This is meant to be called *before* executing the reconciliation stages so that the proper manifest is captured in a closure before any stage might mutate the instance status, e.g. Install.