Documentation ¶
Overview ¶
Package framework contains structures and functions to handle operator SDK and controllers specificness
Index ¶
- Constants
- Variables
- func AddIstioInjectSidecarAnnotation(objectMeta *metav1.ObjectMeta)
- func AddOwnerReference(owner client.Object, scheme *runtime.Scheme, resources ...client.Object) error
- func ConvertImageTagToImage(imageName string) api.Image
- func ConvertImageToImageTag(image api.Image) string
- func CreateBuildConfigComparator() func(deployed client.Object, requested client.Object) bool
- func CreateConfigMapComparator() func(deployed client.Object, requested client.Object) bool
- func CreateDeploymentComparator() func(deployed client.Object, requested client.Object) bool
- func CreateDeploymentConfigComparator() func(deployed client.Object, requested client.Object) bool
- func CreateEnvVar(key string, value string) corev1.EnvVar
- func CreateImageStreamComparator() func(deployed client.Object, requested client.Object) bool
- func CreatePKCS12TrustStoreFromSecret(secret *v1.Secret, password string, keys ...string) ([]byte, error)
- func CreateRouteComparator() func(deployed client.Object, requested client.Object) bool
- func CreateSecretEnvVar(variableName, secretName, secretKey string) corev1.EnvVar
- func CreateServiceMonitorComparator() func(deployed client.Object, requested client.Object) bool
- func CreateSharedImageStreamComparator() func(deployed client.Object, requested client.Object) bool
- func DiffEnvVar(env1 []corev1.EnvVar, env2 []corev1.EnvVar) []corev1.EnvVar
- func DiscoverPortsAndProbesFromImage(dc *appsv1.DeploymentConfig, dockerImage *dockerv10.DockerImage)
- func EnvOverride(dst []corev1.EnvVar, src ...corev1.EnvVar) []corev1.EnvVar
- func ExtractPrometheusConfigurationFromImage(dockerImage *dockerv10.DockerImage) (scrape bool, scheme string, path string, port *intstr.IntOrString, err error)
- func GetEnvVar(envName string, env []corev1.EnvVar) int
- func GetEnvVarFromContainer(key string, container *corev1.Container) string
- func GetLatestDeploymentCondition(conditions []v1.DeploymentCondition) *v1.DeploymentCondition
- func IsOwner(resource client.Object, owner client.Object) bool
- func IsPersistenceEnabled(dockerImage *dockerv10.DockerImage) (enabled bool)
- func IsSafeToRollOutDeploymentConfig(dc *v1.DeploymentConfig) bool
- func MergeImageMetadataWithDeploymentConfig(dc *appsv1.DeploymentConfig, dockerImage *dockerv10.DockerImage) bool
- func RemoveOwnerReference(owner client.Object, resources ...client.Object)
- func RemoveSharedOwnerReference(owner client.Object, resources ...client.Object) bool
- func SetEnvVar(key, value string, container *corev1.Container)
- func SetEnvVarFromSecret(key, secretKey string, secret *corev1.Secret, container *corev1.Container)
- func SetOwner(owner client.Object, scheme *runtime.Scheme, resources ...client.Object) error
- func SplitImageTag(imageTag string) (domain, name, tag string)
- type Comparator
- type ComparatorBuilder
Constants ¶
const ( // DefaultPortName is the default protocol exposed by inner services specified in image metadata DefaultPortName = "http" // DefaultExposedPort TODO: found an agnostic API to fetch the ImageRaw from the docker image and read this value from there. DefaultExposedPort = 8080 // LabelKeyOrgKie is the label key for KIE metadata LabelKeyOrgKie = "org.kie" + labelNamespaceSep // LabelKeyOrgKiePersistence is the label key for Persistence metadata LabelKeyOrgKiePersistence = LabelKeyOrgKie + "persistence" // LabelKeyOrgKiePersistenceRequired is the label key to check if persistence is enabled or not LabelKeyOrgKiePersistenceRequired = LabelKeyOrgKiePersistence + labelNamespaceSep + "required" // LabelKeyPrometheus is the label key for Prometheus metadata LabelKeyPrometheus = "prometheus.io" // LabelPrometheusScrape is the label key for prometheus scrape configuration LabelPrometheusScrape = LabelKeyPrometheus + "/scrape" // LabelPrometheusPath is the label key for prometheus metrics path LabelPrometheusPath = LabelKeyPrometheus + "/path" // LabelPrometheusPort is the label key for prometheus metrics port LabelPrometheusPort = LabelKeyPrometheus + "/port" // LabelPrometheusScheme is the label key for Prometheus metrics endpoint scheme LabelPrometheusScheme = LabelKeyPrometheus + "/scheme" )
const (
// LabelAppKey is the default label key to bind resources together in "Application Group"
LabelAppKey = "app"
)
Variables ¶
var ( // ModeForCertificates unix file mode for certificates. ModeForCertificates = int32(0640) // ModeForPropertyFiles unix file mode for application property files. ModeForPropertyFiles = int32(0644) // ModeForProtoBufConfigMapVolume mode for Proto Buf config map volume ModeForProtoBufConfigMapVolume = int32(0644) )
var ( // DockerTagRegxCompiled is the compiled regex to verify docker tag names DockerTagRegxCompiled = *regexp.MustCompile(dockerTagRegx) )
Functions ¶
func AddIstioInjectSidecarAnnotation ¶
func AddIstioInjectSidecarAnnotation(objectMeta *metav1.ObjectMeta)
AddIstioInjectSidecarAnnotation adds the annotation to be read by the Istio operator to setup sidecars in the given Pod
func AddOwnerReference ¶
func AddOwnerReference(owner client.Object, scheme *runtime.Scheme, resources ...client.Object) error
AddOwnerReference adds given owner as a OwnerReference in the given resources
func ConvertImageTagToImage ¶
func ConvertImageTagToImage(imageName string) api.Image
ConvertImageTagToImage converts a plain string into an Image structure. For example, see https://regex101.com/r/1YX9rh/1.
func ConvertImageToImageTag ¶
func ConvertImageToImageTag(image api.Image) string
ConvertImageToImageTag converts an Image into a plain string (domain/namespace/name:tag).
func CreateBuildConfigComparator ¶
CreateBuildConfigComparator creates a new comparator for BuildConfig using Label, Trigger and SourceStrategy
func CreateConfigMapComparator ¶
CreateConfigMapComparator creates a new comparator for ConfigMap using Label
func CreateDeploymentComparator ¶
CreateDeploymentComparator creates a new comparator for Deployment sorting volumes
func CreateDeploymentConfigComparator ¶
CreateDeploymentConfigComparator creates a new comparator for DeploymentConfig using Trigger and RollingParams
func CreateEnvVar ¶
CreateEnvVar will create EnvVar value for provided key/value pair
func CreateImageStreamComparator ¶
CreateImageStreamComparator creates a new ImageStream comparator
func CreatePKCS12TrustStoreFromSecret ¶
func CreatePKCS12TrustStoreFromSecret(secret *v1.Secret, password string, keys ...string) ([]byte, error)
CreatePKCS12TrustStoreFromSecret creates a PCKS12 with certificates inside a Kubernetes secret. The `keys` parameter must contain public certificates only.
func CreateRouteComparator ¶
CreateRouteComparator creates a new comparator for Route using Label
func CreateSecretEnvVar ¶
CreateSecretEnvVar will create EnvVar value to hold SecretKey for given secret key/name
func CreateServiceMonitorComparator ¶
CreateServiceMonitorComparator creates a new comparator for ServiceMonitor using Label
func CreateSharedImageStreamComparator ¶
CreateSharedImageStreamComparator creates a new Shared ImageStream comparator that verifies if the OwnerReferences are equal between them Also incorporates the `CreateImageStreamComparator` logic
func DiffEnvVar ¶
DiffEnvVar returns elements in `env1` that are not in `env2`
func DiscoverPortsAndProbesFromImage ¶
func DiscoverPortsAndProbesFromImage(dc *appsv1.DeploymentConfig, dockerImage *dockerv10.DockerImage)
DiscoverPortsAndProbesFromImage set Ports and Probes based on labels set on the DockerImage of this DeploymentConfig
func EnvOverride ¶
EnvOverride replaces or appends the provided EnvVar to the collection
func ExtractPrometheusConfigurationFromImage ¶
func ExtractPrometheusConfigurationFromImage(dockerImage *dockerv10.DockerImage) (scrape bool, scheme string, path string, port *intstr.IntOrString, err error)
ExtractPrometheusConfigurationFromImage retrieves prometheus configurations from the prometheus.io labels of the dockerImage
func GetEnvVarFromContainer ¶
GetEnvVarFromContainer gets the environment variable value from the container
func GetLatestDeploymentCondition ¶
func GetLatestDeploymentCondition(conditions []v1.DeploymentCondition) *v1.DeploymentCondition
GetLatestDeploymentCondition returns the latest condition of the array based on the LastUpdateTime field
func IsPersistenceEnabled ¶
func IsPersistenceEnabled(dockerImage *dockerv10.DockerImage) (enabled bool)
IsPersistenceEnabled verifies if the image has labels indicating that persistence is enabled
func IsSafeToRollOutDeploymentConfig ¶
func IsSafeToRollOutDeploymentConfig(dc *v1.DeploymentConfig) bool
IsSafeToRollOutDeploymentConfig checks if the given `DeploymentConfig` has successfully rolled out to the latest version, thus it's safe to perform a new roll out
func MergeImageMetadataWithDeploymentConfig ¶
func MergeImageMetadataWithDeploymentConfig(dc *appsv1.DeploymentConfig, dockerImage *dockerv10.DockerImage) bool
MergeImageMetadataWithDeploymentConfig retrieves org.kie and prometheus.io labels from DockerImage and adds them to the DeploymentConfig returns true if any changes occurred in the deploymentConfig based on the dockerImage labels
func RemoveOwnerReference ¶
RemoveOwnerReference remove given owner from OwnerReference in the given resources
func RemoveSharedOwnerReference ¶ added in v1.8.0
RemoveSharedOwnerReference remove given owner from OwnerReference in the given resources only if resource is referred by multiple owners.
func SetEnvVarFromSecret ¶
SetEnvVarFromSecret will set the Environment Variable from a Secret
func SplitImageTag ¶
SplitImageTag breaks into parts a given tag name, adds "latest" to the tag name if it's empty. For example, see https://regex101.com/r/1YX9rh/1.
Types ¶
type Comparator ¶
type Comparator struct { ResourceType reflect.Type CompFunc func(deployed client.Object, requested client.Object) bool }
Comparator is a simple struct to encapsulate the complex elements from Operator Utils
type ComparatorBuilder ¶
type ComparatorBuilder interface { // WithCustomComparator it's the custom comparator function that will get called by the Operator Utils WithCustomComparator(customComparator func(deployed client.Object, requested client.Object) (equal bool)) ComparatorBuilder // WithType defines the comparator resource type WithType(resourceType reflect.Type) ComparatorBuilder // UseDefaultComparator defines if the comparator will delegate the comparision to inner comparators from Operator Utils UseDefaultComparator() ComparatorBuilder // Build creates the Comparator in the form of Operator Utils interface Build() (reflect.Type, func(deployed client.Object, requested client.Object) bool) }
ComparatorBuilder creates Comparators to be used during reconciliation phases
func NewComparatorBuilder ¶
func NewComparatorBuilder() ComparatorBuilder
NewComparatorBuilder creates a new comparator builder for comparision usages