libraryinputresources

package
v0.0.0-...-2205570 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2025 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EquivalentResources

func EquivalentResources(field string, lhses, rhses []*Resource) []string

func IdentifierForExactResourceRef

func IdentifierForExactResourceRef(resourceReference *ExactResourceID) string

func IdentifyResource

func IdentifyResource(in *Resource) string

func NewDiscoveryClientFromMustGather

func NewDiscoveryClientFromMustGather(mustGatherDir string) (discovery.AggregatedDiscoveryInterface, error)

func NewDynamicClientFromMustGather

func NewDynamicClientFromMustGather(mustGatherDir string) (dynamic.Interface, error)

func NewInputResourcesCommand

func NewInputResourcesCommand(inputResourcesFn InputResourcesFunc, outputResourcesFn libraryoutputresources.OutputResourcesFunc, streams genericiooptions.IOStreams) *cobra.Command

func WriteRequiredInputResourcesFromMustGather

func WriteRequiredInputResourcesFromMustGather(ctx context.Context, inputResources *InputResources, mustGatherDir, targetDir string) error

func WriteResource

func WriteResource(in *Resource, parentDir string) error

Types

type ClusterScopedReference

type ClusterScopedReference struct {
	InputResourceTypeIdentifier `json:",inline"`

	// may have multiple matches
	// TODO CEL may be more appropriate
	NameJSONPath string `json:"nameJSONPath"`
}

type ExactResourceID

type ExactResourceID struct {
	InputResourceTypeIdentifier `json:",inline"`

	Namespace string `json:"namespace,omitempty"`
	Name      string `json:"name"`
}

func ExactClusterOperator

func ExactClusterOperator(name string) ExactResourceID

func ExactClusterRole

func ExactClusterRole(name string) ExactResourceID

func ExactClusterRoleBinding

func ExactClusterRoleBinding(name string) ExactResourceID

func ExactConfigMap

func ExactConfigMap(namespace, name string) ExactResourceID

func ExactConfigResource

func ExactConfigResource(resource string) ExactResourceID

func ExactDaemonSet

func ExactDaemonSet(namespace, name string) ExactResourceID

func ExactDeployment

func ExactDeployment(namespace, name string) ExactResourceID

func ExactLowLevelOperator

func ExactLowLevelOperator(resource string) ExactResourceID

func ExactNamespace

func ExactNamespace(name string) ExactResourceID

func ExactResource

func ExactResource(group, version, resource, namespace, name string) ExactResourceID

func ExactRole

func ExactRole(namespace, name string) ExactResourceID

func ExactRoleBinding

func ExactRoleBinding(namespace, name string) ExactResourceID

func ExactSecret

func ExactSecret(namespace, name string) ExactResourceID

func ExactServiceAccount

func ExactServiceAccount(namespace, name string) ExactResourceID

type ExplicitNamespacedReference

type ExplicitNamespacedReference struct {
	InputResourceTypeIdentifier `json:",inline"`

	// may have multiple matches
	// TODO CEL may be more appropriate
	NamespaceJSONPath string `json:"namespaceJSONPath"`
	NameJSONPath      string `json:"nameJSONPath"`
}

type GeneratedResourceID

type GeneratedResourceID struct {
	InputResourceTypeIdentifier `json:",inline"`

	Namespace     string `json:"namespace,omitempty"`
	GeneratedName string `json:"name"`
}

type ImplicitNamespacedReference

type ImplicitNamespacedReference struct {
	InputResourceTypeIdentifier `json:",inline"`

	Namespace string `json:"namespace"`
	// may have multiple matches
	// TODO CEL may be more appropriate
	NameJSONPath string `json:"nameJSONPath"`
}

type InputResourceTypeIdentifier

type InputResourceTypeIdentifier struct {
	Group string `json:"group"`
	// version is very important because it must match the version of serialization that your operator expects.
	// All Group,Resource tuples must use the same Version.
	Version  string `json:"version"`
	Resource string `json:"resource"`
}

func SecretIdentifierType

func SecretIdentifierType() InputResourceTypeIdentifier

type InputResources

type InputResources struct {
	// applyConfigurationResources are the list of resources used as input to the apply-configuration command.
	// It is the responsibility of the MOM to determine where the inputs come from.
	ApplyConfigurationResources ResourceList `json:"applyConfigurationResources,omitempty"`

	// operandResources is the list of resources that are important for determining check-health
	OperandResources OperandResourceList `json:"operandResources,omitempty"`
}

InputResources contains the items that an operator needs to make a decision about what needs to be create, modified, or removed.

type InputResourcesFunc

type InputResourcesFunc func(ctx context.Context) (*InputResources, error)

type LabelSelectedResource

type LabelSelectedResource struct {
	InputResourceTypeIdentifier `json:",inline"`

	Namespace string `json:"namespace,omitempty"`

	// validation prevents setting matchExpressions
	LabelSelector metav1.LabelSelector `json:"labelSelector"`
}

type OperandResourceList

type OperandResourceList struct {
	ConfigurationResources ResourceList `json:"configurationResources,omitempty"`
	ManagementResources    ResourceList `json:"managementResources,omitempty"`
	UserWorkloadResources  ResourceList `json:"userWorkloadResources,omitempty"`
}

type Resource

type Resource struct {
	Filename     string
	ResourceType schema.GroupVersionResource
	Content      *unstructured.Unstructured
}

TODO this is a good target to move to library-go so we all agree how to reference these.

func GetRequiredInputResourcesForResourceList

func GetRequiredInputResourcesForResourceList(ctx context.Context, resourceList ResourceList, dynamicClient dynamic.Interface) ([]*Resource, error)

func GetRequiredInputResourcesFromMustGather

func GetRequiredInputResourcesFromMustGather(ctx context.Context, inputResources *InputResources, mustGatherDir string) ([]*Resource, error)

func LenientResourcesFromDirRecursive

func LenientResourcesFromDirRecursive(location string) ([]*Resource, error)

func ResourcesFromFile

func ResourcesFromFile(gvkToResources map[schema.GroupVersionKind][]schema.GroupVersionResource, location, fileTrimPrefix string) ([]*Resource, error)

func (Resource) ID

func (r Resource) ID() string

type ResourceList

type ResourceList struct {
	ExactResources []ExactResourceID `json:"exactResources,omitempty"`

	GeneratedNameResources []GeneratedResourceID `json:"generatedNameResources,omitempty"`

	LabelSelectedResources []LabelSelectedResource `json:"labelSelectedResources,omitempty"`

	// use resourceReferences when one resource (apiserver.config.openshift.io/cluster) refers to another resource
	// like a secret (.spec.servingCerts.namedCertificates[*].servingCertificates.name).
	ResourceReferences []ResourceReference `json:"resourceReferences,omitempty"`
}

type ResourceReference

type ResourceReference struct {
	// TODO determine if we need the ability to select multiple containing resources.  I don’t think we’ll need to given the shape of our configuration.
	ReferringResource ExactResourceID `json:"referringResource"`

	Type ResourceReferenceType `json:"type"`

	ExplicitNamespacedReference *ExplicitNamespacedReference `json:"explicitNamespacedReference,omitempty"`
	ImplicitNamespacedReference *ImplicitNamespacedReference `json:"implicitNamespacedReference,omitempty"`
	ClusterScopedReference      *ClusterScopedReference      `json:"clusterScopedReference,omitempty"`
}

type ResourceReferenceType

type ResourceReferenceType string
const (
	ExplicitNamespacedReferenceType ResourceReferenceType = "ExplicitNamespacedReference"
	ImplicitNamespacedReferenceType ResourceReferenceType = "ImplicitNamespacedReference"
	ClusterScopedReferenceType      ResourceReferenceType = "ClusterScopedReference"
)

type UniqueResourceSet

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

func NewUniqueResourceSet

func NewUniqueResourceSet(resources ...*Resource) *UniqueResourceSet

func (*UniqueResourceSet) Insert

func (u *UniqueResourceSet) Insert(resources ...*Resource)

func (*UniqueResourceSet) List

func (u *UniqueResourceSet) List() []*Resource

Jump to

Keyboard shortcuts

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