resource

package
v0.0.0-...-59ba1d5 Latest Latest
Warning

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

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

Documentation

Overview

Package resource implements representations of k8s API resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SameEndingSubarray

func SameEndingSubarray(shortest, longest []string) bool

Types

type ConflictDetector

type ConflictDetector interface {
	// HasConflict returns true if the given resources have a conflict.
	HasConflict(patch1, patch2 *Resource) (bool, error)
	// Merge two resources into one.
	MergePatches(patch1, patch2 *Resource) (*Resource, error)
}

ConflictDetector detects conflicts between resources.

type ConflictDetectorFactory

type ConflictDetectorFactory interface {
	New(gvk resid.Gvk) (ConflictDetector, error)
}

ConflictDetectorFactory makes instances of ConflictDetector that know how to handle the given Group, Version, Kind tuple.

type Factory

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

Factory makes instances of Resource.

func NewFactory

func NewFactory(kf ifc.KunstructuredFactory) *Factory

NewFactory makes an instance of Factory.

func (*Factory) FromBytes

func (rf *Factory) FromBytes(in []byte) (*Resource, error)

FromBytes unmarshalls bytes into one Resource.

func (*Factory) FromKunstructured

func (rf *Factory) FromKunstructured(u ifc.Kunstructured) *Resource

FromKunstructured returns a new instance of Resource.

func (*Factory) FromMap

func (rf *Factory) FromMap(m map[string]interface{}) *Resource

FromMap returns a new instance of Resource.

func (*Factory) FromMapAndOption

func (rf *Factory) FromMapAndOption(
	m map[string]interface{}, args *types.GeneratorArgs) *Resource

FromMapAndOption returns a new instance of Resource with given options.

func (*Factory) FromMapWithName

func (rf *Factory) FromMapWithName(n string, m map[string]interface{}) *Resource

FromMapWithName returns a new instance with the given "original" name.

func (*Factory) FromMapWithNamespaceAndName

func (rf *Factory) FromMapWithNamespaceAndName(ns string, n string, m map[string]interface{}) *Resource

FromMapWithNamespaceAndName returns a new instance with the given "original" namespace.

func (*Factory) Hasher

func (rf *Factory) Hasher() ifc.KunstructuredHasher

func (*Factory) MakeConfigMap

func (rf *Factory) MakeConfigMap(kvLdr ifc.KvLoader, args *types.ConfigMapArgs) (*Resource, error)

MakeConfigMap makes an instance of Resource for ConfigMap

func (*Factory) MakeSecret

func (rf *Factory) MakeSecret(kvLdr ifc.KvLoader, args *types.SecretArgs) (*Resource, error)

MakeSecret makes an instance of Resource for Secret

func (*Factory) SliceFromBytes

func (rf *Factory) SliceFromBytes(in []byte) ([]*Resource, error)

SliceFromBytes unmarshals bytes into a Resource slice.

func (*Factory) SliceFromBytesWithNames

func (rf *Factory) SliceFromBytesWithNames(names []string, in []byte) ([]*Resource, error)

SliceFromBytesWithNames unmarshals bytes into a Resource slice with specified original name.

func (*Factory) SliceFromPatches

func (rf *Factory) SliceFromPatches(
	ldr ifc.Loader, paths []types.PatchStrategicMerge) ([]*Resource, error)

SliceFromPatches returns a slice of resources given a patch path slice from a kustomization file.

type IdSet

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

func MakeIdSet

func MakeIdSet(slice []*Resource) *IdSet

func (IdSet) Contains

func (s IdSet) Contains(id resid.ResId) bool

func (IdSet) Size

func (s IdSet) Size() int

type ResCtx

type ResCtx interface {
	AddNamePrefix(p string)
	AddNameSuffix(s string)
	GetNamePrefixes() []string
	GetNameSuffixes() []string
}

ResCtx is an interface describing the contextual added kept kustomize in the context of each Resource object. Currently mainly the name prefix and name suffix are added.

type ResCtxMatcher

type ResCtxMatcher func(ResCtx) bool

ResCtxMatcher returns true if two Resources are being modified in the same kustomize context.

type Resource

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

Resource is a representation of a Kubernetes Resource Model (KRM) object paired with metadata used by kustomize. For more history, see sigs.k8s.io/kustomize/api/ifc.Unstructured

func (*Resource) AddNamePrefix

func (r *Resource) AddNamePrefix(p string)

Implements ResCtx AddNamePrefix

func (*Resource) AddNameSuffix

func (r *Resource) AddNameSuffix(s string)

Implements ResCtx AddNameSuffix

func (*Resource) AppendRefBy

func (r *Resource) AppendRefBy(id resid.ResId)

AppendRefBy appends a ResId into the refBy list

func (*Resource) AppendRefVarName

func (r *Resource) AppendRefVarName(variable types.Var)

AppendRefVarName appends a name of a var into the refVar list

func (*Resource) ApplyFilter

func (r *Resource) ApplyFilter(f kio.Filter) error

func (*Resource) ApplySmPatch

func (r *Resource) ApplySmPatch(patch *Resource) error

ApplySmPatch applies the provided strategic merge patch.

func (*Resource) AsYAML

func (r *Resource) AsYAML() ([]byte, error)

AsYAML returns the resource in Yaml form. Easier to read than JSON.

func (*Resource) Behavior

func (r *Resource) Behavior() types.GenerationBehavior

Behavior returns the behavior for the resource.

func (*Resource) Copy

func (r *Resource) Copy() ifc.Kunstructured

func (*Resource) CopyMergeMetaDataFieldsFrom

func (r *Resource) CopyMergeMetaDataFieldsFrom(other *Resource)

CopyMergeMetaDataFields copies everything but the non-metadata in the ifc.Kunstructured map, merging labels and annotations.

func (*Resource) CurId

func (r *Resource) CurId() resid.ResId

CurId returns a ResId for the resource using the mutable parts of the resource. This should be unique in any ResMap.

func (*Resource) DeepCopy

func (r *Resource) DeepCopy() *Resource

DeepCopy returns a new copy of resource

func (*Resource) ErrIfNotEquals

func (r *Resource) ErrIfNotEquals(o *Resource) error

func (*Resource) GetAnnotations

func (r *Resource) GetAnnotations() map[string]string

func (*Resource) GetBinaryDataMap

func (r *Resource) GetBinaryDataMap() map[string]string

func (*Resource) GetDataMap

func (r *Resource) GetDataMap() map[string]string

func (*Resource) GetFieldValue

func (r *Resource) GetFieldValue(f string) (interface{}, error)

func (*Resource) GetGvk

func (r *Resource) GetGvk() resid.Gvk

func (*Resource) GetKind

func (r *Resource) GetKind() string

func (*Resource) GetLabels

func (r *Resource) GetLabels() map[string]string

func (*Resource) GetName

func (r *Resource) GetName() string

func (*Resource) GetNamePrefixes

func (r *Resource) GetNamePrefixes() []string

Implements ResCtx GetNamePrefixes

func (*Resource) GetNameSuffixes

func (r *Resource) GetNameSuffixes() []string

Implements ResCtx GetNameSuffixes

func (*Resource) GetNamespace

func (r *Resource) GetNamespace() string

GetNamespace returns the namespace the resource thinks it's in.

func (*Resource) GetRefBy

func (r *Resource) GetRefBy() []resid.ResId

GetRefBy returns the ResIds that referred to current resource

func (*Resource) GetRefVarNames

func (r *Resource) GetRefVarNames() []string

GetRefVarNames returns vars that refer to current resource

func (*Resource) GetSlice

func (r *Resource) GetSlice(p string) ([]interface{}, error)

func (*Resource) GetString

func (r *Resource) GetString(p string) (string, error)

func (*Resource) IsEmpty

func (r *Resource) IsEmpty() bool

func (*Resource) KunstructEqual

func (r *Resource) KunstructEqual(o *Resource) bool

func (*Resource) Map

func (r *Resource) Map() map[string]interface{}

func (*Resource) MarshalJSON

func (r *Resource) MarshalJSON() ([]byte, error)

func (*Resource) MatchesAnnotationSelector

func (r *Resource) MatchesAnnotationSelector(selector string) (bool, error)

func (*Resource) MatchesLabelSelector

func (r *Resource) MatchesLabelSelector(selector string) (bool, error)

func (*Resource) MergeBinaryDataMapFrom

func (r *Resource) MergeBinaryDataMapFrom(o *Resource)

func (*Resource) MergeDataMapFrom

func (r *Resource) MergeDataMapFrom(o *Resource)

func (*Resource) MustYaml

func (r *Resource) MustYaml() string

MustYaml returns YAML or panics.

func (*Resource) NeedHashSuffix

func (r *Resource) NeedHashSuffix() bool

NeedHashSuffix returns true if a resource content hash should be appended to the name of the resource.

func (*Resource) OrgId

func (r *Resource) OrgId() resid.ResId

OrgId returns the original, immutable ResId for the resource. This doesn't have to be unique in a ResMap.

func (*Resource) PrefixesSuffixesEquals

func (r *Resource) PrefixesSuffixesEquals(o ResCtx) bool

PrefixesSuffixesEquals is conceptually doing the same task as OutermostPrefixSuffix but performs a deeper comparison of the suffix and prefix slices.

func (*Resource) PrevIds

func (r *Resource) PrevIds() []resid.ResId

PrevIds returns a list of ResIds that includes every previous ResId the resource has had through all of its GVKN transformations, in the order that it had that ID. I.e. the oldest ID is first. The returned array does not include the resource's current ID. If there are no previous IDs, this will return nil.

func (*Resource) ReferencesEqual

func (r *Resource) ReferencesEqual(other *Resource) bool

func (*Resource) RemoveBuildAnnotations

func (r *Resource) RemoveBuildAnnotations()

RemoveBuildAnnotations removes annotations created by the build process. These are internal-only to kustomize, added to the data pipeline to track name changes so name references can be fixed.

func (*Resource) ResetPrimaryData

func (r *Resource) ResetPrimaryData(incoming *Resource)

func (*Resource) SetAnnotations

func (r *Resource) SetAnnotations(m map[string]string)

func (*Resource) SetBinaryDataMap

func (r *Resource) SetBinaryDataMap(m map[string]string)

func (*Resource) SetDataMap

func (r *Resource) SetDataMap(m map[string]string)

func (*Resource) SetGvk

func (r *Resource) SetGvk(gvk resid.Gvk)

func (*Resource) SetLabels

func (r *Resource) SetLabels(m map[string]string)

func (*Resource) SetName

func (r *Resource) SetName(n string)

func (*Resource) SetNamespace

func (r *Resource) SetNamespace(n string)

func (*Resource) SetOptions

func (r *Resource) SetOptions(o *types.GenArgs)

SetOptions updates the generator options for the resource.

func (*Resource) StorePreviousId

func (r *Resource) StorePreviousId()

StorePreviousId stores the resource's current ID via build annotations.

func (*Resource) String

func (r *Resource) String() string

String returns resource as JSON.

func (*Resource) UnmarshalJSON

func (r *Resource) UnmarshalJSON(s []byte) error

Jump to

Keyboard shortcuts

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