extramanifest

package
v0.0.0-...-4c5e57f Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Overview

nolint

Index

Constants

View Source
const (
	CmManifestPath              = "/opt/extra-manifests"  // manifests extracted from configmaps
	PolicyManifestPath          = "/opt/policy-manifests" // manifests extracted from policies
	ValidationWarningAnnotation = "extra-manifest.lca.openshift.io/validation-warning"
)
View Source
const TargetOcpVersionLabel = "lca.openshift.io/target-ocp-version"
View Source
const TargetOcpVersionManifestCountAnnotation = "lca.openshift.io/target-ocp-version-manifest-count"

Variables

This section is empty.

Functions

func AddAnnotationEMWarningValidation

func AddAnnotationEMWarningValidation(c client.Client, log logr.Logger, ibu *ibuv1.ImageBasedUpgrade, annotationValue string) error

AddAnnotationEMWarningValidation add warning in annotation for when CRD is unknown

func ApplyExtraManifest

func ApplyExtraManifest(ctx context.Context, dc dynamic.Interface, restMapper meta.RESTMapper, manifest *unstructured.Unstructured, isDryRun bool) error

func GetMatchingTargetOcpVersionLabelVersions

func GetMatchingTargetOcpVersionLabelVersions(ocpVersion string) ([]string, error)

GetMatchingTargetOcpVersionLabelVersions generates a list of matching versions that be used for extracting manifests from the policy The matching versions include: [full release version, Major.Minor.Patch, Major.Minor]

func IsEMFailedError

func IsEMFailedError(err error) bool

func RemoveAnnotationEMWarningValidation

func RemoveAnnotationEMWarningValidation(c client.Client, log logr.Logger, ibu *ibuv1.ImageBasedUpgrade) error

RemoveAnnotationEMWarningValidation remove the warning if present

Types

type EMHandler

type EMHandler struct {
	Client        client.Client
	DynamicClient dynamic.Interface
	Log           logr.Logger
}

EMHandler handles the extra manifests

func (*EMHandler) ApplyExtraManifests

func (h *EMHandler) ApplyExtraManifests(ctx context.Context, fromDir string) error

ApplyExtraManifests applies the extra manifests from the preserved extra manifests directory

func (*EMHandler) ExportExtraManifestToDir

func (h *EMHandler) ExportExtraManifestToDir(ctx context.Context, extraManifestCMs []ibuv1.ConfigMapRef, toDir string) error

ExportExtraManifestToDir extracts the extra manifests from configmaps and writes them to the given directory

func (*EMHandler) ExtractAndExportManifestFromPoliciesToDir

func (h *EMHandler) ExtractAndExportManifestFromPoliciesToDir(ctx context.Context, policyLabels, objectLabels, validationAnns map[string]string, toDir string) error

ExtractAndExportManifestFromPoliciesToDir extracts CR specs from policies and writes to a given directory. It matches policies and/or CRs by labels.

func (*EMHandler) GetPolicies

func (h *EMHandler) GetPolicies(ctx context.Context, labels map[string]string) ([]*policiesv1.Policy, error)

GetPolicies gets the policies matching the labels from the namespace and sort them by the ztp wave annotation value

func (*EMHandler) ValidateAndExtractManifestFromPolicies

func (h *EMHandler) ValidateAndExtractManifestFromPolicies(ctx context.Context, policyLabels, objectLabels, validationAnns map[string]string) ([][]*unstructured.Unstructured, error)

func (*EMHandler) ValidateExtraManifestConfigmaps

func (h *EMHandler) ValidateExtraManifestConfigmaps(ctx context.Context, content []ibuv1.ConfigMapRef) (string, error)

ValidateExtraManifestConfigmaps validates IBU extramanifest configmaps and returns validation warning and error. It iterates over all manifests included in the configmaps and perform Kubernetes Dry-run. Errors such as Invalid or webhook BadRequest types from Dry-run apply are considered warnings. This also includes cases where CRDs are missing from the current stateroot and dependent namespace does not exist on the current stateroot but is also not found in the configmaps. Other validation failures are treated as errors, such as random chars, missing resource Kind, resource ApiVersion, resource name or the presence of disallowed resource types

type EMStatusError

type EMStatusError struct {
	Reason     string
	ErrMessage string
}

EMStatusError type

func NewEMFailedError

func NewEMFailedError(msg string) *EMStatusError

func NewEMFailedValidationError

func NewEMFailedValidationError(msg string) *EMStatusError

func (*EMStatusError) Error

func (e *EMStatusError) Error() string

type EManifestHandler

type EManifestHandler interface {
	ApplyExtraManifests(ctx context.Context, fromDir string) error
	ExportExtraManifestToDir(ctx context.Context, extraManifestCMs []ibuv1.ConfigMapRef, toDir string) error
	ExtractAndExportManifestFromPoliciesToDir(ctx context.Context, policyLabels, objectLabels, validationAnns map[string]string, toDir string) error
	ValidateAndExtractManifestFromPolicies(ctx context.Context, policyLabels, objectLabels, validationAnns map[string]string) ([][]*unstructured.Unstructured, error)
	ValidateExtraManifestConfigmaps(ctx context.Context, extraManifestCMs []ibuv1.ConfigMapRef) (string, error)
}

Directories

Path Synopsis
Code generated by MockGen.
Code generated by MockGen.

Jump to

Keyboard shortcuts

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