Documentation ¶
Overview ¶
Package resource implements representations of k8s API resources.
Index ¶
- type ConflictDetector
- type ConflictDetectorFactory
- type Factory
- func (rf *Factory) FromBytes(in []byte) (*Resource, error)
- func (rf *Factory) FromKunstructured(u ifc.Kunstructured) *Resource
- func (rf *Factory) FromMap(m map[string]interface{}) *Resource
- func (rf *Factory) FromMapAndOption(m map[string]interface{}, args *types.GeneratorArgs) *Resource
- func (rf *Factory) FromMapWithName(n string, m map[string]interface{}) *Resource
- func (rf *Factory) FromMapWithNamespace(n string, m map[string]interface{}) *Resource
- func (rf *Factory) FromMapWithNamespaceAndName(ns string, n string, m map[string]interface{}) *Resource
- func (rf *Factory) Hasher() ifc.KunstructuredHasher
- func (rf *Factory) MakeConfigMap(kvLdr ifc.KvLoader, args *types.ConfigMapArgs) (*Resource, error)
- func (rf *Factory) MakeSecret(kvLdr ifc.KvLoader, args *types.SecretArgs) (*Resource, error)
- func (rf *Factory) SliceFromBytes(in []byte) ([]*Resource, error)
- func (rf *Factory) SliceFromBytesWithNames(names []string, in []byte) ([]*Resource, error)
- func (rf *Factory) SliceFromPatches(ldr ifc.Loader, paths []types.PatchStrategicMerge) ([]*Resource, error)
- type IdSet
- type ResCtx
- type ResCtxMatcher
- type Resource
- func (r *Resource) AddNamePrefix(p string)
- func (r *Resource) AddNameSuffix(s string)
- func (r *Resource) AppendRefBy(id resid.ResId)
- func (r *Resource) AppendRefVarName(variable types.Var)
- func (r *Resource) ApplyFilter(f kio.Filter) error
- func (r *Resource) ApplySmPatch(patch *Resource) error
- func (r *Resource) AsYAML() ([]byte, error)
- func (r *Resource) Behavior() types.GenerationBehavior
- func (r *Resource) Copy() ifc.Kunstructured
- func (r *Resource) CopyMergeMetaDataFieldsFrom(other *Resource)
- func (r *Resource) CurId() resid.ResId
- func (r *Resource) DeepCopy() *Resource
- func (r *Resource) ErrIfNotEquals(o *Resource) error
- func (r *Resource) GetAnnotations() map[string]string
- func (r *Resource) GetDataMap() map[string]string
- func (r *Resource) GetFieldValue(f string) (interface{}, error)
- func (r *Resource) GetGvk() resid.Gvk
- func (r *Resource) GetKind() string
- func (r *Resource) GetLabels() map[string]string
- func (r *Resource) GetName() string
- func (r *Resource) GetNamePrefixes() []string
- func (r *Resource) GetNameSuffixes() []string
- func (r *Resource) GetNamespace() string
- func (r *Resource) GetOriginalName() string
- func (r *Resource) GetOriginalNs() string
- func (r *Resource) GetOutermostNamePrefix() string
- func (r *Resource) GetOutermostNameSuffix() string
- func (r *Resource) GetRefBy() []resid.ResId
- func (r *Resource) GetRefVarNames() []string
- func (r *Resource) GetSlice(p string) ([]interface{}, error)
- func (r *Resource) GetString(p string) (string, error)
- func (r *Resource) IsEmpty() bool
- func (r *Resource) KunstructEqual(o *Resource) bool
- func (r *Resource) Map() map[string]interface{}
- func (r *Resource) MarshalJSON() ([]byte, error)
- func (r *Resource) MatchesAnnotationSelector(selector string) (bool, error)
- func (r *Resource) MatchesLabelSelector(selector string) (bool, error)
- func (r *Resource) MergeDataMapFrom(o *Resource)
- func (r *Resource) NeedHashSuffix() bool
- func (r *Resource) OrgId() resid.ResId
- func (r *Resource) OutermostPrefixSuffixEquals(o ResCtx) bool
- func (r *Resource) PrefixesSuffixesEquals(o ResCtx) bool
- func (r *Resource) ReferencesEqual(o *Resource) bool
- func (r *Resource) RemoveBuildAnnotations()
- func (r *Resource) ResetPrimaryData(incoming *Resource)
- func (r *Resource) SetAnnotations(m map[string]string)
- func (r *Resource) SetDataMap(m map[string]string)
- func (r *Resource) SetGvk(gvk resid.Gvk)
- func (r *Resource) SetLabels(m map[string]string)
- func (r *Resource) SetName(n string)
- func (r *Resource) SetNamespace(n string)
- func (r *Resource) SetOptions(o *types.GenArgs)
- func (r *Resource) SetOriginalName(n string, overwrite bool) *Resource
- func (r *Resource) SetOriginalNs(n string, overwrite bool) *Resource
- func (r *Resource) String() string
- func (r *Resource) UnmarshalJSON(s []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConflictDetector ¶ added in v0.6.6
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 ¶ added in v0.6.6
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) FromKunstructured ¶
func (rf *Factory) FromKunstructured(u ifc.Kunstructured) *Resource
FromKunstructured 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 ¶
FromMapWithName returns a new instance with the given "original" name.
func (*Factory) FromMapWithNamespace ¶
FromMapWithNamespace returns a new instance with the given "original" namespace.
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 ¶
MakeConfigMap makes an instance of Resource for ConfigMap
func (*Factory) MakeSecret ¶
MakeSecret makes an instance of Resource for Secret
func (*Factory) SliceFromBytes ¶
SliceFromBytes unmarshals bytes into a Resource slice.
func (*Factory) SliceFromBytesWithNames ¶ added in v0.6.0
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 ResCtx ¶
type ResCtx interface { AddNamePrefix(p string) AddNameSuffix(s string) GetOutermostNamePrefix() string GetOutermostNameSuffix() 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 ¶
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 ¶
Implements ResCtx AddNamePrefix
func (*Resource) AddNameSuffix ¶
Implements ResCtx AddNameSuffix
func (*Resource) AppendRefBy ¶
AppendRefBy appends a ResId into the refBy list
func (*Resource) AppendRefVarName ¶
AppendRefVarName appends a name of a var into the refVar list
func (*Resource) ApplySmPatch ¶ added in v0.6.6
ApplySmPatch applies the provided strategic merge patch.
func (*Resource) Behavior ¶
func (r *Resource) Behavior() types.GenerationBehavior
Behavior returns the behavior for the resource.
func (*Resource) Copy ¶ added in v0.4.2
func (r *Resource) Copy() ifc.Kunstructured
func (*Resource) CopyMergeMetaDataFieldsFrom ¶ added in v0.6.8
CopyMergeMetaDataFields copies everything but the non-metadata in the ifc.Kunstructured map, merging labels and annotations.
func (*Resource) CurId ¶
CurId returns a ResId for the resource using the mutable parts of the resource. This should be unique in any ResMap.
func (*Resource) ErrIfNotEquals ¶ added in v0.6.6
func (*Resource) GetAnnotations ¶ added in v0.4.2
func (*Resource) GetDataMap ¶ added in v0.6.8
func (*Resource) GetFieldValue ¶ added in v0.4.2
func (*Resource) GetNamePrefixes ¶
Implements ResCtx GetNamePrefixes
func (*Resource) GetNameSuffixes ¶
Implements ResCtx GetNameSuffixes
func (*Resource) GetNamespace ¶
GetNamespace returns the namespace the resource thinks it's in.
func (*Resource) GetOriginalName ¶
func (*Resource) GetOriginalNs ¶
func (*Resource) GetOutermostNamePrefix ¶
Implements ResCtx GetOutermostNamePrefix
func (*Resource) GetOutermostNameSuffix ¶
Implements ResCtx GetOutermostNameSuffix
func (*Resource) GetRefVarNames ¶
GetRefVarNames returns vars that refer to current resource
func (*Resource) KunstructEqual ¶
func (*Resource) MarshalJSON ¶ added in v0.4.2
func (*Resource) MatchesAnnotationSelector ¶ added in v0.4.2
func (*Resource) MatchesLabelSelector ¶ added in v0.4.2
func (*Resource) MergeDataMapFrom ¶ added in v0.6.8
func (*Resource) NeedHashSuffix ¶
NeedHashSuffix returns true if a resource content hash should be appended to the name of the resource.
func (*Resource) OrgId ¶
OrgId returns the original, immutable ResId for the resource. This doesn't have to be unique in a ResMap. TODO: compute this once and save it in the resource.
func (*Resource) OutermostPrefixSuffixEquals ¶
OutermostPrefixSuffixEquals returns true if both resources outer suffix and prefix matches.
func (*Resource) PrefixesSuffixesEquals ¶
PrefixesSuffixesEquals is conceptually doing the same task as OutermostPrefixSuffix but performs a deeper comparison of the suffix and prefix slices.
Important note: The PrefixSuffixTransformer is stacking the prefix values in the reverse order of appearance in the transformed name. For this reason the sameEndingSubarray method is used (as opposed to the sameBeginningSubarray) to compare the prefix slice. In the same spirit, the GetOutermostNamePrefix is using the last element of the nameprefix slice and not the first.
func (*Resource) ReferencesEqual ¶
func (*Resource) RemoveBuildAnnotations ¶ added in v0.6.9
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 ¶ added in v0.4.2
func (*Resource) SetAnnotations ¶ added in v0.4.2
func (*Resource) SetDataMap ¶ added in v0.6.8
func (*Resource) SetNamespace ¶ added in v0.4.2
func (*Resource) SetOptions ¶
SetOptions updates the generator options for the resource.