Documentation ¶
Index ¶
- Variables
- func FieldPath(fieldPath []interface{}) string
- func GetCRDGroupKind(u *unstructured.Unstructured) (schema.GroupKind, bool)
- func InfoToUnstructured(info *resource.Info) *unstructured.Unstructured
- func InfosToUnstructureds(infos []*resource.Info) []*unstructured.Unstructured
- func Invalid(fieldPath []interface{}, value interface{}, detail string) *field.Error
- func InvalidType(fieldPath []interface{}, value interface{}, validTypes string) *field.Error
- func IsCRD(u *unstructured.Unstructured) bool
- func IsKindNamespace(u *unstructured.Unstructured) bool
- func IsNamespaced(u *unstructured.Unstructured) bool
- func LookupResourceScope(u *unstructured.Unstructured, crds []*unstructured.Unstructured, ...) (meta.RESTScope, error)
- func NestedField(obj map[string]interface{}, fields ...interface{}) (interface{}, bool, error)
- func NotFound(fieldPath []interface{}, value interface{}) *field.Error
- func ObjMetadataSetEquals(setA []ObjMetadata, setB []ObjMetadata) bool
- func StripKyamlAnnotations(u *unstructured.Unstructured)
- func UnstructuredSetEquals(setA []*unstructured.Unstructured, setB []*unstructured.Unstructured) bool
- func UnstructuredToInfo(obj *unstructured.Unstructured) (*resource.Info, error)
- func UnstructuredsToInfos(objs []*unstructured.Unstructured) ([]*resource.Info, error)
- type InvalidAnnotationError
- type ObjMetadata
- func InfoToObjMeta(info *resource.Info) (ObjMetadata, error)
- func InfosToObjMetas(infos []*resource.Info) ([]ObjMetadata, error)
- func ParseObjMetadata(s string) (ObjMetadata, error)
- func RuntimeToObjMeta(obj runtime.Object) (ObjMetadata, error)
- func UnstructuredToObjMetadata(obj *unstructured.Unstructured) ObjMetadata
- type ObjMetadataSet
- func (setA ObjMetadataSet) Contains(id ObjMetadata) bool
- func (setA ObjMetadataSet) Diff(setB ObjMetadataSet) ObjMetadataSet
- func (setA ObjMetadataSet) Equal(setB ObjMetadataSet) bool
- func (setA ObjMetadataSet) Hash() string
- func (setA ObjMetadataSet) Intersection(setB ObjMetadataSet) ObjMetadataSet
- func (setA ObjMetadataSet) Remove(obj ObjMetadata) ObjMetadataSet
- func (setA ObjMetadataSet) ToMap() map[ObjMetadata]struct{}
- func (setA ObjMetadataSet) ToStringMap() map[string]string
- func (setA ObjMetadataSet) Union(setB ObjMetadataSet) ObjMetadataSet
- func (setA ObjMetadataSet) Unique() ObjMetadataSet
- type UnknownTypeError
- type UnstructuredSet
- type YamlStringer
Constants ¶
This section is empty.
Variables ¶
var (
NilObjMetadata = ObjMetadata{}
)
var RBACGroupKind = map[schema.GroupKind]bool{ {Group: rbacv1.GroupName, Kind: "Role"}: true, {Group: rbacv1.GroupName, Kind: "ClusterRole"}: true, {Group: rbacv1.GroupName, Kind: "RoleBinding"}: true, {Group: rbacv1.GroupName, Kind: "ClusterRoleBinding"}: true, }
RBACGroupKind is a map of the RBAC resources. Needed since name validation is different than other k8s resources.
Functions ¶
func FieldPath ¶ added in v0.27.0
func FieldPath(fieldPath []interface{}) string
FieldPath formats a list of KRM field keys as a JSONPath expression. The only valid field keys in KRM are strings (map keys) and ints (list keys). Simple strings (see isSimpleString) will be delimited with a period. Complex strings will be wrapped with square brackets and double quotes. Integers will be wrapped with square brackets. All other types will be formatted best-effort within square brackets.
func GetCRDGroupKind ¶ added in v0.26.0
func GetCRDGroupKind(u *unstructured.Unstructured) (schema.GroupKind, bool)
GetCRDGroupKind returns the GroupKind stored in the passed Unstructured CustomResourceDefinition and true if the passed object is a CRD.
func InfoToUnstructured ¶ added in v0.21.0
func InfoToUnstructured(info *resource.Info) *unstructured.Unstructured
InfoToUnstructured transforms the passed info object into unstructured format.
func InfosToUnstructureds ¶ added in v0.21.0
func InfosToUnstructureds(infos []*resource.Info) []*unstructured.Unstructured
InfosToUnstructureds transforms the passed objects in Info format to Unstructured.
func Invalid ¶ added in v0.27.0
Invalid returns a *Error indicating "invalid value". This is used to report malformed values (e.g. failed regex match, too long, out of bounds).
func InvalidType ¶ added in v0.27.0
InvalidType returns a *Error indicating "invalid value type". This is used to report malformed values (e.g. found int, expected string).
func IsCRD ¶ added in v0.26.0
func IsCRD(u *unstructured.Unstructured) bool
IsCRD returns true if the passed Unstructured object has GroupKind == Extensions/CustomResourceDefinition; false otherwise.
func IsKindNamespace ¶ added in v0.26.0
func IsKindNamespace(u *unstructured.Unstructured) bool
IsKindNamespace returns true if the passed Unstructured object is GroupKind == Core/Namespace (no version checked); false otherwise.
func IsNamespaced ¶ added in v0.26.0
func IsNamespaced(u *unstructured.Unstructured) bool
IsNamespaced returns true if the passed Unstructured object is namespace-scoped (not cluster-scoped); false otherwise.
func LookupResourceScope ¶ added in v0.26.0
func LookupResourceScope(u *unstructured.Unstructured, crds []*unstructured.Unstructured, mapper meta.RESTMapper) (meta.RESTScope, error)
LookupResourceScope tries to look up the scope of the type of the provided resource, looking at both the types known to the cluster (through the RESTMapper) and the provided CRDs. If no information about the type can be found, an UnknownTypeError wil be returned.
func NestedField ¶ added in v0.27.0
NestedField gets a value from a KRM map, if it exists, otherwise nil. Fields can be string (map key) or int (array index).
func NotFound ¶ added in v0.27.0
NotFound returns a *Error indicating "value not found". This is used to report failure to find a requested value (e.g. looking up an ID).
func ObjMetadataSetEquals ¶ added in v0.26.0
func ObjMetadataSetEquals(setA []ObjMetadata, setB []ObjMetadata) bool
UnstructuredSetEquals returns true if the slice of objects in setA equals the slice of objects in setB.
func StripKyamlAnnotations ¶ added in v0.28.0
func StripKyamlAnnotations(u *unstructured.Unstructured)
StripKyamlAnnotations removes any path and index annotations from the unstructured resource.
func UnstructuredSetEquals ¶ added in v0.26.0
func UnstructuredSetEquals(setA []*unstructured.Unstructured, setB []*unstructured.Unstructured) bool
UnstructuredSetEquals returns true if the slice of objects in setA equals the slice of objects in setB.
func UnstructuredToInfo ¶ added in v0.21.0
func UnstructuredToInfo(obj *unstructured.Unstructured) (*resource.Info, error)
UnstructuredToInfo transforms the passed Unstructured object into Info format, or an error if one occurs.
func UnstructuredsToInfos ¶ added in v0.21.0
func UnstructuredsToInfos(objs []*unstructured.Unstructured) ([]*resource.Info, error)
UnstructuredsToInfos transforms the passed Unstructured objects into Info format or an error if one occurs.
Types ¶
type InvalidAnnotationError ¶ added in v0.28.0
InvalidAnnotationError represents an invalid annotation. Fields are exposed to allow callers to perform introspection.
func (InvalidAnnotationError) Error ¶ added in v0.28.0
func (iae InvalidAnnotationError) Error() string
func (InvalidAnnotationError) Unwrap ¶ added in v0.28.0
func (iae InvalidAnnotationError) Unwrap() error
type ObjMetadata ¶
ObjMetadata organizes and stores the indentifying information for an object. This struct (as a string) is stored in a inventory object to keep track of sets of applied objects.
func InfoToObjMeta ¶ added in v0.8.0
func InfoToObjMeta(info *resource.Info) (ObjMetadata, error)
InfoToObjMeta takes information from the provided info and returns an ObjMetadata that identifies the resource.
func InfosToObjMetas ¶ added in v0.8.0
func InfosToObjMetas(infos []*resource.Info) ([]ObjMetadata, error)
InfosToObjMetas returns object metadata (ObjMetadata) for the passed objects (infos); returns an error if one occurs.
func ParseObjMetadata ¶
func ParseObjMetadata(s string) (ObjMetadata, error)
ParseObjMetadata takes a string, splits it into its four fields, and returns an ObjMetadata struct storing the four fields. Example inventory string:
test-namespace_test-name_apps_ReplicaSet
Returns an error if unable to parse and create the ObjMetadata struct.
NOTE: name field can contain double underscore (__), which represents a colon. RBAC resources can have this additional character (:) in their name.
func RuntimeToObjMeta ¶ added in v0.22.1
func RuntimeToObjMeta(obj runtime.Object) (ObjMetadata, error)
RuntimeToObjMeta extracts the object metadata information from a runtime.Object and returns it as ObjMetadata.
func UnstructuredToObjMetadata ¶ added in v0.27.0
func UnstructuredToObjMetadata(obj *unstructured.Unstructured) ObjMetadata
UnstructuredToObjMetadata extracts the identifying information from an Unstructured object and returns it as ObjMetadata object.
func (*ObjMetadata) Equals ¶
func (o *ObjMetadata) Equals(other *ObjMetadata) bool
Equals compares two ObjMetadata and returns true if they are equal. This does not contain any special treatment for the extensions API group.
func (ObjMetadata) String ¶
func (o ObjMetadata) String() string
String create a string version of the ObjMetadata struct. For RBAC resources, the "name" field transcodes ":" into double underscore for valid storing as the label of a ConfigMap.
type ObjMetadataSet ¶ added in v0.26.0
type ObjMetadataSet []ObjMetadata
ObjMetadataSet is an ordered list of ObjMetadata that acts like an unordered set for comparison purposes.
func FromStringMap ¶ added in v0.26.0
func FromStringMap(in map[string]string) (ObjMetadataSet, error)
FromStringMap returns a set from a serializable map, with objMeta keys and empty string values. Errors if parsing fails.
func ObjMetadataSetFromMap ¶ added in v0.27.0
func ObjMetadataSetFromMap(mapA map[ObjMetadata]struct{}) ObjMetadataSet
ObjMetadataSetFromMap constructs a set from a map
func UnstructuredSetToObjMetadataSet ¶ added in v0.27.0
func UnstructuredSetToObjMetadataSet(objs UnstructuredSet) ObjMetadataSet
UnstructuredSetToObjMetadataSet converts a UnstructuredSet to a ObjMetadataSet.
func (ObjMetadataSet) Contains ¶ added in v0.26.0
func (setA ObjMetadataSet) Contains(id ObjMetadata) bool
Contains checks if the provided ObjMetadata exists in the set.
func (ObjMetadataSet) Diff ¶ added in v0.26.0
func (setA ObjMetadataSet) Diff(setB ObjMetadataSet) ObjMetadataSet
Diff returns the set of objects that exist in set A, but not in set B (A - B).
func (ObjMetadataSet) Equal ¶ added in v0.26.0
func (setA ObjMetadataSet) Equal(setB ObjMetadataSet) bool
Equal returns true if the two sets contain equivalent objects. Duplicates are ignored. This function satisfies the cmp.Equal interface from github.com/google/go-cmp
func (ObjMetadataSet) Hash ¶ added in v0.26.0
func (setA ObjMetadataSet) Hash() string
Hash the objects in the set by serializing, sorting, concatonating, and hashing the result with the 32-bit FNV-1a algorithm.
func (ObjMetadataSet) Intersection ¶ added in v0.27.0
func (setA ObjMetadataSet) Intersection(setB ObjMetadataSet) ObjMetadataSet
Intersection returns the set of unique objects in both set A and set B.
func (ObjMetadataSet) Remove ¶ added in v0.26.0
func (setA ObjMetadataSet) Remove(obj ObjMetadata) ObjMetadataSet
Remove the object from the set and return the updated set.
func (ObjMetadataSet) ToMap ¶ added in v0.27.0
func (setA ObjMetadataSet) ToMap() map[ObjMetadata]struct{}
ToMap returns the set as a map, with objMeta keys and empty struct values.
func (ObjMetadataSet) ToStringMap ¶ added in v0.26.0
func (setA ObjMetadataSet) ToStringMap() map[string]string
ToStringMap returns the set as a serializable map, with objMeta keys and empty string values.
func (ObjMetadataSet) Union ¶ added in v0.26.0
func (setA ObjMetadataSet) Union(setB ObjMetadataSet) ObjMetadataSet
Union returns the set of unique objects from the merging of set A and set B.
func (ObjMetadataSet) Unique ¶ added in v0.28.0
func (setA ObjMetadataSet) Unique() ObjMetadataSet
Unique returns the set with duplicates removed. Order may or may not remain consistent.
type UnknownTypeError ¶ added in v0.26.0
type UnknownTypeError struct {
GroupVersionKind schema.GroupVersionKind
}
UnknownTypeError captures information about a type for which no information could be found in the cluster or among the known CRDs.
func (*UnknownTypeError) Error ¶ added in v0.26.0
func (e *UnknownTypeError) Error() string
type UnstructuredSet ¶ added in v0.26.0
type UnstructuredSet []*unstructured.Unstructured
UnstructuredSet is an ordered list of Unstructured that acts like an unordered set for comparison purposes.
func (UnstructuredSet) Equal ¶ added in v0.26.0
func (setA UnstructuredSet) Equal(setB UnstructuredSet) bool
type YamlStringer ¶ added in v0.26.0
type YamlStringer struct {
O *unstructured.Unstructured
}
YamlStringer delays YAML marshalling for logging until String() is called.
func (YamlStringer) String ¶ added in v0.26.0
func (ys YamlStringer) String() string
String marshals the wrapped object to a YAML string. If serializing errors, the error string will be returned instead. This is primarily for use with verbose logging.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
This package provides a object sorting functionality based on the explicit "depends-on" annotation, and implicit object dependencies like namespaces and CRD's.
|
This package provides a object sorting functionality based on the explicit "depends-on" annotation, and implicit object dependencies like namespaces and CRD's. |