common

package
v0.42.4 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
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 base.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 base.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

func AppendTarget(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error

AppendTarget mutates the passed manifest by appending one appropriate for the passed KComponent

func CheckDeployments

func CheckDeployments(ctx context.Context, manifest *mf.Manifest, instance base.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 base.ConfigMapData, log *zap.SugaredLogger) mf.Transformer

ConfigMapTransform updates the ConfigMap with the values specified in operator CR

func FetchManifest added in v0.21.0

func FetchManifest(path string) (mf.Manifest, error)

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 FetchManifestFromArray added in v0.38.0

func FetchManifestFromArray(paths []string) (mf.Manifest, error)

FetchManifestFromArray 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 base.KComponent, toRemove string) ([]byte, error)

FinalizerRemovalPatch generates a patch for removing the given finalizer.

func GetLatestIngressRelease added in v0.23.0

func GetLatestIngressRelease(version string) string

GetLatestIngressRelease returns the latest release tag available under kodata directory for the ingress based on spec.version.

func GetLatestRelease

func GetLatestRelease(instance base.KComponent, version string) string

GetLatestRelease returns the latest release tag available under kodata directory for Knative component based on spec.version.

func HighAvailabilityTransform added in v0.21.0

func HighAvailabilityTransform(obj base.KComponent) mf.Transformer

HighAvailabilityTransform mutates configmaps and replicacounts of certain controllers when HA control plane is specified.

func ImageTransform

func ImageTransform(registry *base.Registry, log *zap.SugaredLogger) mf.Transformer

ImageTransform updates image with a new registry and tag

func InjectNamespace added in v0.38.0

func InjectNamespace(manifest *mf.Manifest, instance base.KComponent, extra ...mf.Transformer) error

InjectNamespace will mutate the namespace of all installed resources

func Install

func Install(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error

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 base.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 base.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 base.KComponent) mf.Transformer

JobTransform updates the job with the expected value for the key app in the label

func LatestRelease added in v0.36.0

func LatestRelease(instance base.KComponent) string

LatestRelease returns the latest release tag available under kodata directory for Knative component.

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 NoOp added in v0.16.0

NoOp does nothing

func OverridesTransform added in v0.35.0

func OverridesTransform(overrides []base.WorkloadOverride, log *zap.SugaredLogger) mf.Transformer

OverridesTransform transforms deployments based on the configuration in `spec.overrides`.

func PodDisruptionBudgetsTransform added in v0.33.0

func PodDisruptionBudgetsTransform(obj base.KComponent, log *zap.SugaredLogger) mf.Transformer

PodDisruptionBudgetsTransform transforms PodDisruptionBudgets based on the configuration in `spec.podDisruptionBudgets`.

func ResourceRequirementsTransform

func ResourceRequirementsTransform(obj base.KComponent, 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

func SanitizeSemver(version string) string

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 ServicesTransform added in v0.31.0

func ServicesTransform(obj base.KComponent, log *zap.SugaredLogger) mf.Transformer

ServicesTransform transforms services based on the configuration in `spec.service`.

func TargetAdditionalManifest added in v0.22.0

func TargetAdditionalManifest(instance base.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 base.KComponent) (mf.Manifest, error)

TargetManifest returns the default manifest for the TargetVersion or the manifest for the TargetVersion specified with spec.manifests

func TargetManifestPathArray added in v0.37.0

func TargetManifestPathArray(instance base.KComponent) []string

TargetManifestPathArray returns an array of strings, which include all the paths of the Serving or Eventing manifests.

func TargetVersion added in v0.16.0

func TargetVersion(instance base.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 base.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

func Uninstall(manifest *mf.Manifest) error

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(base.KComponent) ([]mf.Manifest, error)
	Transformers(base.KComponent) []mf.Transformer
	Reconcile(context.Context, base.KComponent) error
	Finalize(context.Context, base.KComponent) error
}

Extension enables platform-specific features

func NoExtension added in v0.16.0

func NoExtension(context.Context, *controller.Impl) Extension

NoPlatform "generates" a NilExtension

type ExtensionGenerator added in v0.16.0

type ExtensionGenerator func(context.Context, *controller.Impl) Extension

ExtensionGenerator creates an Extension from a Context

type ManifestFetcher added in v0.16.0

type ManifestFetcher func(ctx context.Context, instance base.KComponent) (*mf.Manifest, error)

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 base.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.

type Stages added in v0.16.0

type Stages []Stage

Stages are a list of steps

func (Stages) Execute added in v0.16.0

func (stages Stages) Execute(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error

Execute each stage in sequence until one returns an error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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