spec

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindAnnotationOrLabelByKeyPattern

func FindAnnotationOrLabelByKeyPattern(annotationsOrLabels map[string]string, pattern *regexp.Regexp) (key, value string, found bool)

func FindAnnotationsOrLabelsByKeyPattern

func FindAnnotationsOrLabelsByKeyPattern(annotationsOrLabels map[string]string, pattern *regexp.Regexp) (result map[string]string, found bool)

func GVKtoGVR

func GVKtoGVR(gvk schema.GroupVersionKind, mapper meta.RESTMapper) (gvr schema.GroupVersionResource, namespaced bool, err error)

func ID

func ID(name, namespace, group, kind string) string

func IDHuman

func IDHuman(name, namespace, group, kind string) string

func IDWithVersion

func IDWithVersion(name, namespace, group, version, kind string) string

func IsCRD

func IsCRD(groupKind schema.GroupKind) bool

func IsCRDFromGR

func IsCRDFromGR(groupKind schema.GroupResource) bool

func IsHook

func IsHook(annotations map[string]string) bool

func IsReleaseNamespace

func IsReleaseNamespace(resourceName string, resourceGVK schema.GroupVersionKind, releaseNamespace string) bool

func IsWebhook added in v1.16.1

func IsWebhook(groupKind schema.GroupKind) bool

func Namespaced

func Namespaced(gvk schema.GroupVersionKind, mapper meta.RESTMapper) (bool, error)

func ParseKubectlResourceStringToGVR

func ParseKubectlResourceStringToGVR(resource string) schema.GroupVersionResource

func ParseKubectlResourceStringtoGVK

func ParseKubectlResourceStringtoGVK(resource string, restMapper meta.RESTMapper) (schema.GroupVersionKind, error)

func ResourceMetaSortHandler

func ResourceMetaSortHandler(r1, r2 *ResourceMeta) bool

func ResourceSpecSortHandler

func ResourceSpecSortHandler(r1, r2 *ResourceSpec) bool

Types

type DropInvalidAnnotationsAndLabelsTransformer

type DropInvalidAnnotationsAndLabelsTransformer struct{}

TODO(v2): remove this transformer. Replace it with proper early validation of resource Heads.

func NewDropInvalidAnnotationsAndLabelsTransformer

func NewDropInvalidAnnotationsAndLabelsTransformer() *DropInvalidAnnotationsAndLabelsTransformer

func (*DropInvalidAnnotationsAndLabelsTransformer) Match

func (*DropInvalidAnnotationsAndLabelsTransformer) Transform

func (*DropInvalidAnnotationsAndLabelsTransformer) Type

type ExtraMetadataPatcher

type ExtraMetadataPatcher struct {
	// contains filtered or unexported fields
}

func NewExtraMetadataPatcher

func NewExtraMetadataPatcher(annotations, labels map[string]string) *ExtraMetadataPatcher

func (*ExtraMetadataPatcher) Match

func (*ExtraMetadataPatcher) Patch

func (*ExtraMetadataPatcher) Type

type ReleaseMetadataPatcher

type ReleaseMetadataPatcher struct {
	// contains filtered or unexported fields
}

func NewReleaseMetadataPatcher

func NewReleaseMetadataPatcher(releaseName, releaseNamespace string) *ReleaseMetadataPatcher

func (*ReleaseMetadataPatcher) Match

func (*ReleaseMetadataPatcher) Patch

func (*ReleaseMetadataPatcher) Type

type ResourceListsTransformer

type ResourceListsTransformer struct{}

func NewResourceListsTransformer

func NewResourceListsTransformer() *ResourceListsTransformer

func (*ResourceListsTransformer) Match

func (*ResourceListsTransformer) Transform

func (*ResourceListsTransformer) Type

type ResourceMatcher

type ResourceMatcher struct {
	Names      []string
	Namespaces []string
	Groups     []string
	Versions   []string
	Kinds      []string
}

func (*ResourceMatcher) Match

func (s *ResourceMatcher) Match(resMeta *ResourceMeta) bool

type ResourceMeta

type ResourceMeta struct {
	Name             string
	Namespace        string
	GroupVersionKind schema.GroupVersionKind
	FilePath         string
	Annotations      map[string]string
	Labels           map[string]string
}

func NewResourceMeta

func NewResourceMeta(name, namespace, releaseNamespace, filePath string, gvk schema.GroupVersionKind, annotations, labels map[string]string) *ResourceMeta

func NewResourceMetaFromManifest

func NewResourceMetaFromManifest(manifest, releaseNamespace string) (*ResourceMeta, error)

func NewResourceMetaFromPartialMetadata

func NewResourceMetaFromPartialMetadata(meta *v1.PartialObjectMetadata, releaseNamespace, filePath string) *ResourceMeta

func NewResourceMetaFromUnstructured

func NewResourceMetaFromUnstructured(unstruct *unstructured.Unstructured, releaseNamespace, filePath string) *ResourceMeta

func (*ResourceMeta) ID

func (m *ResourceMeta) ID() string

func (*ResourceMeta) IDHuman

func (m *ResourceMeta) IDHuman() string

func (*ResourceMeta) IDWithVersion

func (m *ResourceMeta) IDWithVersion() string

type ResourcePatcher

type ResourcePatcher interface {
	Match(ctx context.Context, resourceInfo *ResourcePatcherResourceInfo) (matched bool, err error)
	Patch(ctx context.Context, matchedResourceInfo *ResourcePatcherResourceInfo) (output *unstructured.Unstructured, err error)
	Type() ResourcePatcherType
}

type ResourcePatcherResourceInfo

type ResourcePatcherResourceInfo struct {
	Obj       *unstructured.Unstructured
	Ownership common.Ownership
}

type ResourcePatcherType

type ResourcePatcherType string
const (
	TypeExtraMetadataPatcher   ResourcePatcherType = "extra-metadata-patcher"
	TypeReleaseMetadataPatcher ResourcePatcherType = "release-metadata-patcher"
)

type ResourceSpec

type ResourceSpec struct {
	*ResourceMeta

	Unstruct *unstructured.Unstructured
	StoreAs  common.StoreAs
}

func BuildReleasableResourceSpecs

func BuildReleasableResourceSpecs(ctx context.Context, releaseNamespace string, transformedResources []*ResourceSpec, patchers []ResourcePatcher) ([]*ResourceSpec, error)

func BuildTransformedResourceSpecs

func BuildTransformedResourceSpecs(ctx context.Context, releaseNamespace string, resources []*ResourceSpec, transformers []ResourceTransformer) ([]*ResourceSpec, error)

func NewResourceSpec

func NewResourceSpec(unstruct *unstructured.Unstructured, releaseNamespace string, opts ResourceSpecOptions) *ResourceSpec

func NewResourceSpecFromManifest

func NewResourceSpecFromManifest(manifest, releaseNamespace string, opts ResourceSpecOptions) (*ResourceSpec, error)

func (*ResourceSpec) SetAnnotations

func (s *ResourceSpec) SetAnnotations(annotations map[string]string)

func (*ResourceSpec) SetLabels

func (s *ResourceSpec) SetLabels(labels map[string]string)

type ResourceSpecOptions

type ResourceSpecOptions struct {
	StoreAs  common.StoreAs
	FilePath string
}

type ResourceTransformer

type ResourceTransformer interface {
	Match(ctx context.Context, resourceInfo *ResourceTransformerResourceInfo) (matched bool, err error)
	Transform(ctx context.Context, matchedResourceInfo *ResourceTransformerResourceInfo) (output []*unstructured.Unstructured, err error)
	Type() ResourceTransformerType
}

type ResourceTransformerResourceInfo

type ResourceTransformerResourceInfo struct {
	Obj *unstructured.Unstructured
}

type ResourceTransformerType

type ResourceTransformerType string
const (
	TypeDropInvalidAnnotationsAndLabelsTransformer ResourceTransformerType = "drop-invalid-annotations-and-labels-transformer"
	TypeResourceListsTransformer                   ResourceTransformerType = "resource-lists-transformer"
)

Jump to

Keyboard shortcuts

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