resources

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2020 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIGroupKindMatcher

type APIGroupKindMatcher struct {
	APIGroup string
	Kind     string
}

func (APIGroupKindMatcher) Matches

func (m APIGroupKindMatcher) Matches(res Resource) bool

type APIVersionKindMatcher

type APIVersionKindMatcher struct {
	APIVersion string
	Kind       string
}

func (APIVersionKindMatcher) Matches

func (m APIVersionKindMatcher) Matches(res Resource) bool

type AllAndMatchingOpts added in v0.8.0

type AllAndMatchingOpts struct {
	SkipResourceOwnershipCheck      bool
	BlacklistedResourcesByLabelKeys []string
}

type AllResourceMatcher

type AllResourceMatcher struct{}

func (AllResourceMatcher) Matches

func (AllResourceMatcher) Matches(Resource) bool

type AnyMatcher

type AnyMatcher struct {
	Matchers []ResourceMatcher
}

func (AnyMatcher) Matches

func (m AnyMatcher) Matches(res Resource) bool

type AnyResourceMatcher

type AnyResourceMatcher struct {
	Matchers []ResourceMatcher
}

func (AnyResourceMatcher) Matches

func (m AnyResourceMatcher) Matches(res Resource) bool

type AssociationLabel

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

func NewAssociationLabel

func NewAssociationLabel(resource Resource) AssociationLabel

func (AssociationLabel) AsSelector

func (a AssociationLabel) AsSelector() labels.Selector

func (AssociationLabel) Key

func (a AssociationLabel) Key() string

func (AssociationLabel) Value

func (a AssociationLabel) Value() string

type BoolFilter

type BoolFilter struct {
	And      []BoolFilter
	Or       []BoolFilter
	Not      *BoolFilter
	Resource *ResourceFilter
}

func NewBoolFilterFromString

func NewBoolFilterFromString(data string) (*BoolFilter, error)

func (BoolFilter) Matches

func (m BoolFilter) Matches(res Resource) bool

type BytesSource added in v0.10.0

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

func NewBytesSource added in v0.10.0

func NewBytesSource(bytes []byte) BytesSource

func (BytesSource) Bytes added in v0.10.0

func (s BytesSource) Bytes() ([]byte, error)

func (BytesSource) Description added in v0.10.0

func (s BytesSource) Description() string

type FieldCopyMod

type FieldCopyMod struct {
	ResourceMatcher ResourceMatcher
	Path            Path
	Sources         []FieldCopyModSource // first preferred
}

func (FieldCopyMod) ApplyFromMultiple

func (t FieldCopyMod) ApplyFromMultiple(res Resource, srcs map[FieldCopyModSource]Resource) error

type FieldCopyModSource

type FieldCopyModSource string
const (
	FieldCopyModSourceNew      FieldCopyModSource = "new"
	FieldCopyModSourceExisting                    = "existing"
)

type FieldRemoveMod

type FieldRemoveMod struct {
	ResourceMatcher ResourceMatcher
	Path            Path
}

func (FieldRemoveMod) Apply

func (t FieldRemoveMod) Apply(res Resource) error

func (FieldRemoveMod) ApplyFromMultiple added in v0.6.0

func (t FieldRemoveMod) ApplyFromMultiple(res Resource, _ map[FieldCopyModSource]Resource) error

type FileResource

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

func NewFileResource added in v0.10.0

func NewFileResource(fileSrc FileSource) FileResource

func NewFileResources

func NewFileResources(file string) ([]FileResource, error)

func (FileResource) Description

func (r FileResource) Description() string

func (FileResource) Resources

func (r FileResource) Resources() ([]Resource, error)

type FileSource

type FileSource interface {
	Description() string
	Bytes() ([]byte, error)
}

type FilteringPodWatcher

type FilteringPodWatcher struct {
	MatcherFunc func(*corev1.Pod) bool
	Watcher     PodWatcherI
}

func (FilteringPodWatcher) Watch

func (w FilteringPodWatcher) Watch(podsToWatchCh chan corev1.Pod, cancelCh chan struct{}) error

type HTTPFileSource

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

func NewHTTPFileSource

func NewHTTPFileSource(path string) HTTPFileSource

func (HTTPFileSource) Bytes

func (s HTTPFileSource) Bytes() ([]byte, error)

func (HTTPFileSource) Description

func (s HTTPFileSource) Description() string

type IdentifiedResources

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

func NewIdentifiedResources

func NewIdentifiedResources(coreClient kubernetes.Interface,
	dynamicClient dynamic.Interface, resourceTypes ResourceTypes,
	fallbackAllowedNamespaces []string, logger logger.Logger) IdentifiedResources

func (IdentifiedResources) ConfigMapResources

func (r IdentifiedResources) ConfigMapResources(labelSelector labels.Selector) ([]corev1.ConfigMap, error)

func (IdentifiedResources) Create

func (r IdentifiedResources) Create(resource Resource) (Resource, error)

func (IdentifiedResources) Delete

func (r IdentifiedResources) Delete(resource Resource) error

func (IdentifiedResources) Exists

func (r IdentifiedResources) Exists(resource Resource) (bool, error)

func (IdentifiedResources) Get

func (r IdentifiedResources) Get(resource Resource) (Resource, error)

func (IdentifiedResources) List

func (r IdentifiedResources) List(labelSelector labels.Selector) ([]Resource, error)

func (IdentifiedResources) Patch

func (r IdentifiedResources) Patch(resource Resource, patchType types.PatchType, data []byte) (Resource, error)

func (IdentifiedResources) PodResources

func (r IdentifiedResources) PodResources(labelSelector labels.Selector) UniquePodWatcher

func (IdentifiedResources) Update

func (r IdentifiedResources) Update(resource Resource) (Resource, error)

type IdentityAnnotation

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

func NewIdentityAnnotation

func NewIdentityAnnotation(resource Resource) IdentityAnnotation

func (IdentityAnnotation) AddMod

func (IdentityAnnotation) MatchesVersion

func (a IdentityAnnotation) MatchesVersion() bool

MatchesVersion returns true if annotation is valid and it matches version

func (IdentityAnnotation) RemoveMod

func (a IdentityAnnotation) RemoveMod() FieldRemoveMod

func (IdentityAnnotation) Valid

func (a IdentityAnnotation) Valid() bool

Valid returns true if signature matches resource itself

type KindNamespaceNameMatcher

type KindNamespaceNameMatcher struct {
	Kind, Namespace, Name string
}

func (KindNamespaceNameMatcher) Matches

func (m KindNamespaceNameMatcher) Matches(res Resource) bool

type LabelScopingModsFunc

type LabelScopingModsFunc func(kvs map[string]string) []StringMapAppendMod

type LabeledResources

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

func NewLabeledResources

func NewLabeledResources(labelSelector labels.Selector,
	identifiedResources IdentifiedResources, logger logger.Logger) *LabeledResources

func (*LabeledResources) All

func (a *LabeledResources) All() ([]Resource, error)

func (*LabeledResources) AllAndMatching

func (a *LabeledResources) AllAndMatching(newResources []Resource, opts AllAndMatchingOpts) ([]Resource, error)

AllAndMatching returns set of all labeled resources plus resources that match newResources. Returns errors if non-labeled resources were labeled with a different value.

func (*LabeledResources) GetAssociated

func (a *LabeledResources) GetAssociated(resource Resource) ([]Resource, error)

func (*LabeledResources) Prepare

func (a *LabeledResources) Prepare(resources []Resource, olmFunc OwnershipLabelModsFunc,
	lsmFunc LabelScopingModsFunc, additionalLabels map[string]string) error

type LocalFileSource

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

func NewLocalFileSource

func NewLocalFileSource(path string) LocalFileSource

func (LocalFileSource) Bytes

func (s LocalFileSource) Bytes() ([]byte, error)

func (LocalFileSource) Description

func (s LocalFileSource) Description() string

type ObjectRefSetMod

type ObjectRefSetMod struct {
	ResourceMatcher ResourceMatcher
	Path            Path
	ReplacementFunc func(map[string]interface{}) error
}

func (ObjectRefSetMod) Apply

func (t ObjectRefSetMod) Apply(res Resource) error

type OwnershipLabelModsFunc

type OwnershipLabelModsFunc func(kvs map[string]string) []StringMapAppendMod

type PartialResourceRef

type PartialResourceRef struct {
	schema.GroupVersionResource
}

func (PartialResourceRef) Matches

type Path

type Path []*PathPart

func NewPathFromInterfaces

func NewPathFromInterfaces(parts []interface{}) Path

func NewPathFromStrings

func NewPathFromStrings(strs []string) Path

func (Path) AsString

func (p Path) AsString() string

func (Path) AsStrings

func (p Path) AsStrings() []string

func (Path) ContainsNonMapKeys

func (p Path) ContainsNonMapKeys() bool

type PathPart

type PathPart struct {
	MapKey     *string
	ArrayIndex *PathPartArrayIndex
}

func NewPathPartFromIndex

func NewPathPartFromIndex(i int) *PathPart

func NewPathPartFromIndexAll

func NewPathPartFromIndexAll() *PathPart

func NewPathPartFromString

func NewPathPartFromString(str string) *PathPart

func (*PathPart) AsString

func (p *PathPart) AsString() string

func (*PathPart) UnmarshalJSON

func (p *PathPart) UnmarshalJSON(data []byte) error

type PathPartArrayIndex

type PathPartArrayIndex struct {
	Index *int
	All   *bool `json:"allIndexes"`
}

type PodWatcher

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

func NewPodWatcher

func NewPodWatcher(
	podsClient typedcorev1.PodInterface,
	listOpts metav1.ListOptions,
) PodWatcher

func (PodWatcher) Watch

func (w PodWatcher) Watch(podsToWatchCh chan corev1.Pod, cancelCh chan struct{}) error

type PodWatcherI

type PodWatcherI interface {
	Watch(podsToWatchCh chan corev1.Pod, cancelCh chan struct{}) error
}

type Resource

type Resource interface {
	GroupVersionResource() schema.GroupVersionResource
	Kind() string
	APIVersion() string
	APIGroup() string

	Namespace() string
	SetNamespace(name string)
	RemoveNamespace()

	Name() string
	SetName(name string)
	Description() string

	Annotations() map[string]string
	Labels() map[string]string
	OwnerRefs() []metav1.OwnerReference
	Status() map[string]interface{}

	CreatedAt() time.Time
	IsProvisioned() bool
	IsDeleting() bool
	UID() string

	Equal(res Resource) bool
	DeepCopy() Resource
	DeepCopyRaw() map[string]interface{}
	AsYAMLBytes() ([]byte, error)
	AsCompactBytes() ([]byte, error)
	AsTypedObj(obj interface{}) error
	AsUncheckedTypedObj(obj interface{}) error

	Debug(string)

	SetOrigin(string)
	Origin() string

	MarkTransient(bool)
	Transient() bool
	// contains filtered or unexported methods
}

func NewResourcesFromBytes

func NewResourcesFromBytes(data []byte) ([]Resource, error)

type ResourceFilter

type ResourceFilter struct {
	CreatedAtBeforeTime *time.Time
	CreatedAtAfterTime  *time.Time

	Kinds          []string
	Namespaces     []string
	Names          []string
	KindNames      []string
	KindNamespaces []string
	KindNsNames    []string

	BoolFilter *BoolFilter
}

func (ResourceFilter) Apply

func (f ResourceFilter) Apply(resources []Resource) []Resource

func (ResourceFilter) Matches

func (f ResourceFilter) Matches(resource Resource) bool

type ResourceImpl

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

func MustNewResourceFromBytes

func MustNewResourceFromBytes(data []byte) *ResourceImpl

func NewResourceFromBytes

func NewResourceFromBytes(data []byte) (*ResourceImpl, error)

func NewResourceUnstructured

func NewResourceUnstructured(un unstructured.Unstructured, resType ResourceType) *ResourceImpl

func (*ResourceImpl) APIGroup

func (r *ResourceImpl) APIGroup() string

func (*ResourceImpl) APIVersion

func (r *ResourceImpl) APIVersion() string

func (*ResourceImpl) Annotations

func (r *ResourceImpl) Annotations() map[string]string

func (*ResourceImpl) AsCompactBytes added in v0.15.0

func (r *ResourceImpl) AsCompactBytes() ([]byte, error)

func (*ResourceImpl) AsTypedObj

func (r *ResourceImpl) AsTypedObj(obj interface{}) error

func (*ResourceImpl) AsUncheckedTypedObj added in v0.10.0

func (r *ResourceImpl) AsUncheckedTypedObj(obj interface{}) error

func (*ResourceImpl) AsYAMLBytes

func (r *ResourceImpl) AsYAMLBytes() ([]byte, error)

func (*ResourceImpl) CreatedAt

func (r *ResourceImpl) CreatedAt() time.Time

func (*ResourceImpl) Debug added in v0.6.0

func (r *ResourceImpl) Debug(title string)

func (*ResourceImpl) DeepCopy

func (r *ResourceImpl) DeepCopy() Resource

func (*ResourceImpl) DeepCopyRaw

func (r *ResourceImpl) DeepCopyRaw() map[string]interface{}

func (*ResourceImpl) Description

func (r *ResourceImpl) Description() string

func (*ResourceImpl) Equal

func (r *ResourceImpl) Equal(res Resource) bool

func (*ResourceImpl) GroupVersionResource

func (r *ResourceImpl) GroupVersionResource() schema.GroupVersionResource

func (*ResourceImpl) IsDeleting

func (r *ResourceImpl) IsDeleting() bool

func (*ResourceImpl) IsProvisioned

func (r *ResourceImpl) IsProvisioned() bool

func (*ResourceImpl) Kind

func (r *ResourceImpl) Kind() string

func (*ResourceImpl) Labels

func (r *ResourceImpl) Labels() map[string]string

func (*ResourceImpl) MarkTransient added in v0.12.0

func (r *ResourceImpl) MarkTransient(transient bool)

func (*ResourceImpl) Name

func (r *ResourceImpl) Name() string

func (*ResourceImpl) Namespace

func (r *ResourceImpl) Namespace() string

func (*ResourceImpl) Origin added in v0.14.0

func (r *ResourceImpl) Origin() string

func (*ResourceImpl) OwnerRefs

func (r *ResourceImpl) OwnerRefs() []metav1.OwnerReference

func (*ResourceImpl) RemoveNamespace added in v0.2.0

func (r *ResourceImpl) RemoveNamespace()

func (*ResourceImpl) SetName

func (r *ResourceImpl) SetName(name string)

func (*ResourceImpl) SetNamespace

func (r *ResourceImpl) SetNamespace(name string)

func (*ResourceImpl) SetOrigin added in v0.14.0

func (r *ResourceImpl) SetOrigin(origin string)

func (*ResourceImpl) Status

func (r *ResourceImpl) Status() map[string]interface{}

func (*ResourceImpl) Transient

func (r *ResourceImpl) Transient() bool

func (*ResourceImpl) UID

func (r *ResourceImpl) UID() string

type ResourceMatcher

type ResourceMatcher interface {
	Matches(Resource) bool
}

type ResourceMod

type ResourceMod interface {
	Apply(Resource) error
}

type ResourceModWithMultiple added in v0.6.0

type ResourceModWithMultiple interface {
	ApplyFromMultiple(Resource, map[FieldCopyModSource]Resource) error
}

type ResourceRef

type ResourceRef struct {
	schema.GroupVersionResource
}

type ResourceType

type ResourceType struct {
	schema.GroupVersionResource
	metav1.APIResource
}

func Listable

func Listable(in []ResourceType) []ResourceType

func Matching

func Matching(in []ResourceType, ref ResourceRef) []ResourceType

func NonMatching

func NonMatching(in []ResourceType, ref ResourceRef) []ResourceType

func (ResourceType) Deletable

func (p ResourceType) Deletable() bool

func (ResourceType) Listable

func (p ResourceType) Listable() bool

func (ResourceType) Namespaced

func (p ResourceType) Namespaced() bool

type ResourceTypes

type ResourceTypes interface {
	All() ([]ResourceType, error)
	Find(Resource) (ResourceType, error)
}

type ResourceTypesImpl

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

func NewResourceTypesImpl

func NewResourceTypesImpl(coreClient kubernetes.Interface, opts ResourceTypesImplOpts) *ResourceTypesImpl

func (*ResourceTypesImpl) All

func (g *ResourceTypesImpl) All() ([]ResourceType, error)

func (*ResourceTypesImpl) Find

func (g *ResourceTypesImpl) Find(resource Resource) (ResourceType, error)

type ResourceTypesImplOpts added in v0.15.0

type ResourceTypesImplOpts struct {
	IgnoreFailingAPIServices bool
}

type ResourceTypesUnknownTypeErr

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

func (ResourceTypesUnknownTypeErr) Error

type Resources

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

func NewResources

func NewResources(resourceTypes ResourceTypes, coreClient kubernetes.Interface,
	dynamicClient dynamic.Interface, fallbackAllowedNamespaces []string, logger logger.Logger) *Resources

func (*Resources) All

func (c *Resources) All(resTypes []ResourceType, opts ResourcesAllOpts) ([]Resource, error)

func (*Resources) Create

func (c *Resources) Create(resource Resource) (Resource, error)

func (*Resources) Delete

func (c *Resources) Delete(resource Resource) error

func (*Resources) Exists

func (c *Resources) Exists(resource Resource) (bool, error)

func (*Resources) Get

func (c *Resources) Get(resource Resource) (Resource, error)

func (*Resources) Patch

func (c *Resources) Patch(resource Resource, patchType types.PatchType, data []byte) (Resource, error)

func (*Resources) Update

func (c *Resources) Update(resource Resource) (Resource, error)

type ResourcesAllOpts

type ResourcesAllOpts struct {
	ListOpts *metav1.ListOptions
}

type SimpleLabel

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

func NewSimpleLabel

func NewSimpleLabel(labelSelector labels.Selector) SimpleLabel

func (SimpleLabel) KV

func (a SimpleLabel) KV() (string, string, error)

type StdinSource

type StdinSource struct{}

func NewStdinSource

func NewStdinSource() StdinSource

func (StdinSource) Bytes

func (s StdinSource) Bytes() ([]byte, error)

func (StdinSource) Description

func (s StdinSource) Description() string

type StringMapAppendMod

type StringMapAppendMod struct {
	// For example applies to Deployment, ReplicaSet, StatefulSet
	// TODO should there be an opt-out way?
	ResourceMatcher ResourceMatcher
	Path            Path
	SkipIfNotFound  bool
	KVs             map[string]string
}

func (StringMapAppendMod) Apply

func (t StringMapAppendMod) Apply(res Resource) error

type UniquePodWatcher

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

func (UniquePodWatcher) Watch

func (w UniquePodWatcher) Watch(podsToWatchCh chan corev1.Pod, cancelCh chan struct{}) error

type UniqueResourceKey

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

func NewUniqueResourceKey

func NewUniqueResourceKey(res Resource) UniqueResourceKey

func NewUniqueResourceKeyWithCustomName

func NewUniqueResourceKeyWithCustomName(res Resource, name string) UniqueResourceKey

func (UniqueResourceKey) String

func (k UniqueResourceKey) String() string

type UniqueResources

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

func NewUniqueResources

func NewUniqueResources(resources []Resource) UniqueResources

func (UniqueResources) Match

func (r UniqueResources) Match(newResources []Resource) ([]Resource, error)

func (UniqueResources) Resources

func (r UniqueResources) Resources() ([]Resource, error)

type YAMLFile

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

func NewYAMLFile

func NewYAMLFile(fileSrc FileSource) YAMLFile

func (YAMLFile) Docs

func (f YAMLFile) Docs() ([][]byte, error)

Jump to

Keyboard shortcuts

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