spec

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanUnstruct added in v1.17.1

Clean an Unstructured object from things like managed fields, non-deterministic runtime data, etc, for diffing, hashing, human-friendly output and so on.

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 CleanUnstructOptions added in v1.17.1

type CleanUnstructOptions struct {
	CleanHelmShAnnos        bool
	CleanManagedFields      bool
	CleanNullFields         bool
	CleanReleaseAnnosLabels bool
	CleanRuntimeData        bool
	CleanWerfIoAnnos        bool
	CleanWerfIoRuntimeAnnos bool
}

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 LegacyOnlyTrackJobsPatcher added in v1.20.1

type LegacyOnlyTrackJobsPatcher struct{}

TODO(v2): get rid of it when patching is implemented or when Kubedog compaitiblity with Helm charts improved

func NewLegacyOnlyTrackJobsPatcher added in v1.20.1

func NewLegacyOnlyTrackJobsPatcher() *LegacyOnlyTrackJobsPatcher

func (*LegacyOnlyTrackJobsPatcher) Match added in v1.20.1

func (*LegacyOnlyTrackJobsPatcher) Patch added in v1.20.1

func (*LegacyOnlyTrackJobsPatcher) Type added in v1.20.1

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
}

Contains basic information about a Kubernetes resource, without its full spec. Very useful for getting, deleting, tracking resources, when you don't care about the resource spec (or when it's not available). If also the resource spec is needed, use ResourceSpec.

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

Uniquely identifies the resource.

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"
	TypeOnlyTrackJobsPatcher    ResourcePatcherType = "only-track-jobs-patcher"
	TypeSecretStringDataPatcher ResourcePatcherType = "secret-string-data-patcher"
)

type ResourceSpec

type ResourceSpec struct {
	*ResourceMeta

	Unstruct *unstructured.Unstructured
	StoreAs  common.StoreAs
}

Contains all generic information about the resource, e.g. its name, namespace, GVK and its spec. Enough to create or update resources, as well as delete, get, etc. Use it when ResourceMeta is not enough and you also need the actual resource spec.

func BuildReleasableResourceSpecs

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

Patch ResourceSpecs to make them releasable, after which they can be saved into the Helm release. Don't try to add/delete/expand specs here, use transformers in BuildTransformedResourceSpecs instead.

func BuildTransformedResourceSpecs

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

Transforms ResourceSpecs, which means specs can be added, deleted, expanded (like Lists). If you just need to modify specs, use patchers in BuildReleasableResourceSpecs instead.

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 {
	FilePath                string
	LegacyNoCleanNullFields bool // TODO(v2): always clean
	StoreAs                 common.StoreAs
}

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"
)

type SecretStringDataPatcher added in v1.20.1

type SecretStringDataPatcher struct{}

func NewSecretStringDataPatcher added in v1.20.1

func NewSecretStringDataPatcher() *SecretStringDataPatcher

func (*SecretStringDataPatcher) Match added in v1.20.1

func (*SecretStringDataPatcher) Patch added in v1.20.1

func (*SecretStringDataPatcher) Type added in v1.20.1

Jump to

Keyboard shortcuts

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