var schemaLock … var kubernetesOpenAPIVersion … var globalSchema … var customSchema … type schemaParseStatus … const schemaNotParsed … const schemaParseDelayed … const schemaParsed … type openapiData … type format … const JsonOrYaml … const Proto … var precomputedIsNamespaceScoped … type ResourceSchema … // IsMissingOrNull returns true if the ResourceSchema is missing or null func (rs *ResourceSchema) IsMissingOrNull() bool { … } // SchemaForResourceType returns the Schema for the given Resource // TODO(pwittrock): create a version of this function that will return a schema // which can be used for duck-typed Resources -- e.g. contains common fields such // as metadata, replicas and spec.template.spec func SchemaForResourceType(t yaml.TypeMeta) *ResourceSchema { … } const SupplementaryOpenAPIFieldName … const Definitions … // AddSchemaFromFile reads the file at path and parses the OpenAPI definitions // from the field "openAPI", also returns a function to clean the added definitions // The returned clean function is a no-op on error, or else it's a function // that the caller should use to remove the added openAPI definitions from // global schema func SchemaFromFile(path string) (*spec.Schema, error) { … } // DefinitionRefs returns the list of openAPI definition references present in the // input openAPIPath func DefinitionRefs(openAPIPath string) ([]string, error) { … } // definitionRefsFromRNode returns the list of openAPI definitions keys from input // yaml RNode func definitionRefsFromRNode(object *yaml.RNode) ([]string, error) { … } // parseOpenAPI reads openAPIPath yaml and converts it to RNode func parseOpenAPI(openAPIPath string) (*yaml.RNode, error) { … } // addSchemaUsingField parses the OpenAPI definitions from the specified field. // If field is the empty string, use the whole document as OpenAPI. func schemaUsingField(object *yaml.RNode, field string) (*spec.Schema, error) { … } // AddSchema parses s, and adds definitions from s to the global schema. func AddSchema(s []byte) error { … } // ResetOpenAPI resets the openapi data to empty func ResetOpenAPI() { … } // AddDefinitions adds the definitions to the global schema. func AddDefinitions(definitions spec.Definitions) { … } func toTypeMeta(ext interface{ … } // Resolve resolves the reference against the global schema func Resolve(ref *spec.Ref, schema *spec.Schema) (*spec.Schema, error) { … } // Schema returns the global schema func Schema() *spec.Schema { … } // GetSchema parses s into a ResourceSchema, resolving References within the // global schema. func GetSchema(s string, schema *spec.Schema) (*ResourceSchema, error) { … } // IsNamespaceScoped determines whether a resource is namespace or // cluster-scoped by looking at the information in the openapi schema. // The second return value tells whether the provided type could be found // in the openapi schema. If the value is false here, the scope of the // resource is not known. If the type is found, the first return value will // be true if the resource is namespace-scoped, and false if the type is // cluster-scoped. func IsNamespaceScoped(typeMeta yaml.TypeMeta) (bool, bool) { … } // isInitSchemaNeededForNamespaceScopeCheck returns true if initSchema is needed // to ensure globalSchema.namespaceabilityByResourceType is fully populated for // cases where a custom or non-default built-in schema is in use. func isInitSchemaNeededForNamespaceScopeCheck() bool { … } // IsCertainlyClusterScoped returns true for Node, Namespace, etc. and // false for Pod, Deployment, etc. and kinds that aren't recognized in the // openapi data. See: // https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces func IsCertainlyClusterScoped(typeMeta yaml.TypeMeta) bool { … } // SuppressBuiltInSchemaUse can be called to prevent using the built-in Kubernetes // schema as part of the global schema. // Must be called before the schema is used. func SuppressBuiltInSchemaUse() { … } // Elements returns the Schema for the elements of an array. func (rs *ResourceSchema) Elements() *ResourceSchema { … } const Elements … // Lookup calls either Field or Elements for each item in the path. // If the path item is "[]", then Elements is called, otherwise // Field is called. // If any Field or Elements call returns nil, then Lookup returns // nil immediately. func (rs *ResourceSchema) Lookup(path ...string) *ResourceSchema { … } // Field returns the Schema for a field. func (rs *ResourceSchema) Field(field string) *ResourceSchema { … } // PatchStrategyAndKeyList returns the patch strategy and complete merge key list func (rs *ResourceSchema) PatchStrategyAndKeyList() (string, []string) { … } // PatchStrategyAndKey returns the patch strategy and merge key extensions func (rs *ResourceSchema) PatchStrategyAndKey() (string, string) { … } const kubernetesOpenAPIDefaultVersion … const kustomizationAPIAssetName … const kubernetesGVKExtensionKey … const kubernetesMergeKeyExtensionKey … const kubernetesPatchStrategyExtensionKey … const kubernetesMergeKeyMapList … const groupKey … const versionKey … const kindKey … // SetSchema sets the kubernetes OpenAPI schema version to use func SetSchema(openAPIField map[string]string, schema []byte, reset bool) error { … } // GetSchemaVersion returns what kubernetes OpenAPI version is being used func GetSchemaVersion() string { … } // initSchema parses the json schema func initSchema() { … } // parseBuiltinSchema calls parse to parse the json or proto schemas func parseBuiltinSchema(version string) { … } // parse parses and indexes a single json or proto schema func parse(b []byte, format format) error { … } // findNamespaceability looks at the api paths for the resource to determine // if it is cluster-scoped or namespace-scoped. The gvk of the resource // for each path is found by looking at the x-kubernetes-group-version-kind // extension. If a path exists for the resource that contains a namespace path // parameter, the resource is namespace-scoped. func findNamespaceability(paths *spec.Paths) { … } func resolve(root interface{ … } func rootSchema() *spec.Schema { … }