dcl

package
v1.111.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddToMap

func AddToMap(key string, val interface{}, obj map[string]interface{})

func CanonicalizeIntegerValue

func CanonicalizeIntegerValue(val interface{}) (int64, error)

CanonicalizeIntegerValue converts the numeric value for integer type to int64 because that's the integer type used by DCL. During json marshalling, all numeric values are converted to be of type float64; we canonicalize them to int64 before sending to DCL.

func CanonicalizeNumberValue

func CanonicalizeNumberValue(val interface{}) (float64, error)

CanonicalizeNumberValue converts the numeric value for number type to float64 because that's the double type used by DCL.

func GetHierarchicalRefFromConfigForMultiParentResource

func GetHierarchicalRefFromConfigForMultiParentResource(config map[string]interface{}, schema *openapi.Schema,
	smLoader dclmetadata.ServiceMetadataLoader) (interface{}, *corekccv1alpha1.TypeConfig, error)

GetHierarchicalRefFromConfigForMultiParentResource gets the value and TypeConfig of the hierarchical reference in the KRM config, assuming that the config is for a multi-parent resource (i.e. supports more than one hierarchical reference). Returns nil if no hierarchical reference is found. Returns an error if multiple are found.

func GetHierarchicalReferenceConfigForMultiParentResource

func GetHierarchicalReferenceConfigForMultiParentResource(schema *openapi.Schema, smLoader dclmetadata.ServiceMetadataLoader) ([]corekccv1alpha1.HierarchicalReference, error)

func GetHierarchicalReferenceConfigFromDCLSchema

func GetHierarchicalReferenceConfigFromDCLSchema(schema *openapi.Schema, smLoader dclmetadata.ServiceMetadataLoader) ([]corekccv1alpha1.HierarchicalReference, error)

func GetMutableButUnreadableFieldsFromAnnotations

func GetMutableButUnreadableFieldsFromAnnotations(r *Resource) (map[string]interface{}, error)

func GetReferenceTypeConfigs

func GetReferenceTypeConfigs(schema *openapi.Schema, smLoader dclmetadata.ServiceMetadataLoader) ([]corekccv1alpha1.TypeConfig, error)

func IsContainerField

func IsContainerField(path []string) bool

func IsMultiTypeParentReferenceField

func IsMultiTypeParentReferenceField(path []string) bool

func IsNil

func IsNil(v interface{}) bool

An interface value strictly equals to nil only if the V (actual value) and T (type) are both unset; we want to treat interface values like (T=[]interface{}, V=nil) as nil too since the actual value is nil.

func IsNoSuchMethodError

func IsNoSuchMethodError(err error) bool

func IsParentReferenceField

func IsParentReferenceField(path []string) bool

func IsSingleTypeParentReferenceField

func IsSingleTypeParentReferenceField(path []string) bool

func MutableButUnreadableFieldsAnnotationFor

func MutableButUnreadableFieldsAnnotationFor(r *Resource) (string, error)

func ParentPrefixForKind

func ParentPrefixForKind(kind string) string

ParentPrefixForKind gets the parent prefix for the given kind (e.g. "Project" => "projects/"). This is used for setting/parsing values of multi-type parent reference fields in DCL which require a parent prefix to denote the parent type.

func ParentReferenceFields

func ParentReferenceFields() []string

func SupportsMultipleParentTypes

func SupportsMultipleParentTypes(schema *openapi.Schema) bool

func ToTypeConfig

func ToTypeConfig(rawElem map[interface{}]interface{}, smLoader dclmetadata.ServiceMetadataLoader) (*corekccv1alpha1.TypeConfig, error)

ToTypeConfig converts a 'x-dcl-references' element to a TypeConfig.

func TrimNilFields

func TrimNilFields(m map[string]interface{})

TrimNilFields removes all nil fields in the input object, including non-top-level nil fields (e.g. those found in nested objects and nested list of objects).

Types

type Resource

type Resource struct {
	k8s.Resource `json:",inline"`

	Original *k8s.Resource `json:"-"`

	// Fields related to DCL processing
	Schema *openapi.Schema `json:"-"`
}

Resource is a wrapper around k8s.Resource and adds information regarding its corresponding DCL resource and maintains an original copy of the k8s.Resource.

func NewResource

func NewResource(u *unstructured.Unstructured, schema *openapi.Schema) (*Resource, error)

func (*Resource) HasMutableButUnreadableFields

func (r *Resource) HasMutableButUnreadableFields() (bool, error)

func (*Resource) HasServerGeneratedIDAndConfigured

func (r *Resource) HasServerGeneratedIDAndConfigured() (bool, error)

func (*Resource) HasServerGeneratedIDButNotConfigured

func (r *Resource) HasServerGeneratedIDButNotConfigured() (bool, error)

func (*Resource) ValidateResourceIDIfSupported

func (r *Resource) ValidateResourceIDIfSupported() error

Directories

Path Synopsis
Package extension is used to interpret the dcl extensions.
Package extension is used to interpret the dcl extensions.
Package metadata defines some KCC metadata around GCP services and DCL.
Package metadata defines some KCC metadata around GCP services and DCL.
schema

Jump to

Keyboard shortcuts

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