Documentation
¶
Index ¶
- func CleanUnstruct(unstruct *unstructured.Unstructured, opts CleanUnstructOptions) *unstructured.Unstructured
- func FindAnnotationOrLabelByKeyPattern(annotationsOrLabels map[string]string, pattern *regexp.Regexp) (key, value string, found bool)
- func FindAnnotationsOrLabelsByKeyPattern(annotationsOrLabels map[string]string, pattern *regexp.Regexp) (result map[string]string, found bool)
- func GVKtoGVR(gvk schema.GroupVersionKind, mapper meta.RESTMapper) (gvr schema.GroupVersionResource, namespaced bool, err error)
- func GVRtoGVK(gvr schema.GroupVersionResource, restMapper meta.RESTMapper) (schema.GroupVersionKind, error)
- func ID(name, namespace, group, kind string) string
- func IDHuman(name, namespace, group, kind string) string
- func IDWithVersion(name, namespace, group, version, kind string) string
- func IsCRD(groupKind schema.GroupKind) bool
- func IsCRDFromGR(groupKind schema.GroupResource) bool
- func IsHook(annotations map[string]string) bool
- func IsReleaseNamespace(resourceName string, resourceGVK schema.GroupVersionKind, ...) bool
- func IsWebhook(groupKind schema.GroupKind) bool
- func Namespaced(gvk schema.GroupVersionKind, mapper meta.RESTMapper) (bool, error)
- func ParseKubectlResourceStringToGVR(resource string) schema.GroupVersionResource
- func ParseKubectlResourceStringtoGVK(resource string, restMapper meta.RESTMapper) (schema.GroupVersionKind, error)
- func ResourceMetaSortHandler(r1, r2 *ResourceMeta) bool
- func ResourceSpecSortHandler(r1, r2 *ResourceSpec) bool
- type CleanUnstructOptions
- type DropInvalidAnnotationsAndLabelsTransformer
- func (t *DropInvalidAnnotationsAndLabelsTransformer) Match(ctx context.Context, info *ResourceTransformerResourceInfo) (matched bool, err error)
- func (t *DropInvalidAnnotationsAndLabelsTransformer) Transform(ctx context.Context, info *ResourceTransformerResourceInfo) ([]*unstructured.Unstructured, error)
- func (t *DropInvalidAnnotationsAndLabelsTransformer) Type() ResourceTransformerType
- type ExtraMetadataPatcher
- type LegacyOnlyTrackJobsPatcher
- func (p *LegacyOnlyTrackJobsPatcher) Match(ctx context.Context, info *ResourcePatcherResourceInfo) (bool, error)
- func (p *LegacyOnlyTrackJobsPatcher) Patch(ctx context.Context, info *ResourcePatcherResourceInfo) (*unstructured.Unstructured, error)
- func (p *LegacyOnlyTrackJobsPatcher) Type() ResourcePatcherType
- type ReleaseMetadataPatcher
- type ResourceListsTransformer
- func (t *ResourceListsTransformer) Match(ctx context.Context, info *ResourceTransformerResourceInfo) (matched bool, err error)
- func (t *ResourceListsTransformer) Transform(ctx context.Context, info *ResourceTransformerResourceInfo) ([]*unstructured.Unstructured, error)
- func (t *ResourceListsTransformer) Type() ResourceTransformerType
- type ResourceMatcher
- type ResourceMeta
- func NewResourceMeta(name, namespace, releaseNamespace, filePath string, ...) *ResourceMeta
- func NewResourceMetaFromManifest(manifest, releaseNamespace string) (*ResourceMeta, error)
- func NewResourceMetaFromPartialMetadata(meta *v1.PartialObjectMetadata, releaseNamespace, filePath string) *ResourceMeta
- func NewResourceMetaFromUnstructured(unstruct *unstructured.Unstructured, releaseNamespace, filePath string) *ResourceMeta
- type ResourcePatcher
- type ResourcePatcherResourceInfo
- type ResourcePatcherType
- type ResourceSpec
- func BuildReleasableResourceSpecs(ctx context.Context, releaseNamespace string, ...) ([]*ResourceSpec, error)
- func BuildTransformedResourceSpecs(ctx context.Context, releaseNamespace string, resources []*ResourceSpec, ...) ([]*ResourceSpec, error)
- func NewResourceSpec(unstruct *unstructured.Unstructured, releaseNamespace string, ...) *ResourceSpec
- func NewResourceSpecFromManifest(manifest, releaseNamespace string, opts ResourceSpecOptions) (*ResourceSpec, error)
- type ResourceSpecOptions
- type ResourceTransformer
- type ResourceTransformerResourceInfo
- type ResourceTransformerType
- type SecretStringDataPatcher
- func (p *SecretStringDataPatcher) Match(ctx context.Context, info *ResourcePatcherResourceInfo) (bool, error)
- func (p *SecretStringDataPatcher) Patch(ctx context.Context, info *ResourcePatcherResourceInfo) (*unstructured.Unstructured, error)
- func (p *SecretStringDataPatcher) Type() ResourcePatcherType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanUnstruct ¶ added in v1.17.1
func CleanUnstruct(unstruct *unstructured.Unstructured, opts CleanUnstructOptions) *unstructured.Unstructured
Clean an Unstructured object from things like managed fields, non-deterministic runtime data, etc, for diffing, hashing, human-friendly output and so on.
func GVKtoGVR ¶
func GVKtoGVR(gvk schema.GroupVersionKind, mapper meta.RESTMapper) (gvr schema.GroupVersionResource, namespaced bool, err error)
func GVRtoGVK ¶
func GVRtoGVK(gvr schema.GroupVersionResource, restMapper meta.RESTMapper) (schema.GroupVersionKind, error)
func IDWithVersion ¶
func IsCRDFromGR ¶
func IsCRDFromGR(groupKind schema.GroupResource) bool
func IsReleaseNamespace ¶
func IsReleaseNamespace(resourceName string, resourceGVK schema.GroupVersionKind, releaseNamespace string) 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 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 (t *DropInvalidAnnotationsAndLabelsTransformer) Match(ctx context.Context, info *ResourceTransformerResourceInfo) (matched bool, err error)
func (*DropInvalidAnnotationsAndLabelsTransformer) Transform ¶
func (t *DropInvalidAnnotationsAndLabelsTransformer) Transform(ctx context.Context, info *ResourceTransformerResourceInfo) ([]*unstructured.Unstructured, error)
func (*DropInvalidAnnotationsAndLabelsTransformer) Type ¶
func (t *DropInvalidAnnotationsAndLabelsTransformer) Type() ResourceTransformerType
type ExtraMetadataPatcher ¶
type ExtraMetadataPatcher struct {
// contains filtered or unexported fields
}
func NewExtraMetadataPatcher ¶
func NewExtraMetadataPatcher(annotations, labels map[string]string) *ExtraMetadataPatcher
func (*ExtraMetadataPatcher) Match ¶
func (p *ExtraMetadataPatcher) Match(ctx context.Context, info *ResourcePatcherResourceInfo) (bool, error)
func (*ExtraMetadataPatcher) Patch ¶
func (p *ExtraMetadataPatcher) Patch(ctx context.Context, info *ResourcePatcherResourceInfo) (*unstructured.Unstructured, error)
func (*ExtraMetadataPatcher) Type ¶
func (p *ExtraMetadataPatcher) Type() ResourcePatcherType
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 (p *LegacyOnlyTrackJobsPatcher) Match(ctx context.Context, info *ResourcePatcherResourceInfo) (bool, error)
func (*LegacyOnlyTrackJobsPatcher) Patch ¶ added in v1.20.1
func (p *LegacyOnlyTrackJobsPatcher) Patch(ctx context.Context, info *ResourcePatcherResourceInfo) (*unstructured.Unstructured, error)
func (*LegacyOnlyTrackJobsPatcher) Type ¶ added in v1.20.1
func (p *LegacyOnlyTrackJobsPatcher) Type() ResourcePatcherType
type ReleaseMetadataPatcher ¶
type ReleaseMetadataPatcher struct {
// contains filtered or unexported fields
}
func NewReleaseMetadataPatcher ¶
func NewReleaseMetadataPatcher(releaseName, releaseNamespace string) *ReleaseMetadataPatcher
func (*ReleaseMetadataPatcher) Match ¶
func (p *ReleaseMetadataPatcher) Match(ctx context.Context, info *ResourcePatcherResourceInfo) (bool, error)
func (*ReleaseMetadataPatcher) Patch ¶
func (p *ReleaseMetadataPatcher) Patch(ctx context.Context, info *ResourcePatcherResourceInfo) (*unstructured.Unstructured, error)
func (*ReleaseMetadataPatcher) Type ¶
func (p *ReleaseMetadataPatcher) Type() ResourcePatcherType
type ResourceListsTransformer ¶
type ResourceListsTransformer struct{}
func NewResourceListsTransformer ¶
func NewResourceListsTransformer() *ResourceListsTransformer
func (*ResourceListsTransformer) Match ¶
func (t *ResourceListsTransformer) Match(ctx context.Context, info *ResourceTransformerResourceInfo) (matched bool, err error)
func (*ResourceListsTransformer) Transform ¶
func (t *ResourceListsTransformer) Transform(ctx context.Context, info *ResourceTransformerResourceInfo) ([]*unstructured.Unstructured, error)
func (*ResourceListsTransformer) Type ¶
func (t *ResourceListsTransformer) Type() ResourceTransformerType
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) 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 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 (p *SecretStringDataPatcher) Match(ctx context.Context, info *ResourcePatcherResourceInfo) (bool, error)
func (*SecretStringDataPatcher) Patch ¶ added in v1.20.1
func (p *SecretStringDataPatcher) Patch(ctx context.Context, info *ResourcePatcherResourceInfo) (*unstructured.Unstructured, error)
func (*SecretStringDataPatcher) Type ¶ added in v1.20.1
func (p *SecretStringDataPatcher) Type() ResourcePatcherType