Documentation ¶
Overview ¶
Example ¶
package main import ( "fmt" "sigs.k8s.io/kustomize/kyaml/openapi" "sigs.k8s.io/kustomize/kyaml/yaml" ) func main() { s := openapi.SchemaForResourceType(yaml.TypeMeta{APIVersion: "apps/v1", Kind: "Deployment"}) f := s.Lookup("spec", "replicas") fmt.Println(f.Schema.Description[:70] + "...") fmt.Println(f.Schema.Type) }
Output: Number of desired pods. This is a pointer to distinguish between expli... [integer]
Example (ArrayElement) ¶
package main import ( "fmt" "sigs.k8s.io/kustomize/kyaml/openapi" "sigs.k8s.io/kustomize/kyaml/yaml" ) func main() { s := openapi.SchemaForResourceType(yaml.TypeMeta{APIVersion: "apps/v1", Kind: "Deployment"}) f := s.Lookup("spec", "template", "spec", "containers", openapi.Elements, "ports", openapi.Elements, "containerPort") fmt.Println(f.Schema.Description[:70] + "...") fmt.Println(f.Schema.Type) }
Output: Number of port to expose on the pod's IP address. This must be a valid... [integer]
Example (ArrayMerge) ¶
package main import ( "fmt" "sigs.k8s.io/kustomize/kyaml/openapi" "sigs.k8s.io/kustomize/kyaml/yaml" ) func main() { s := openapi.SchemaForResourceType(yaml.TypeMeta{APIVersion: "apps/v1", Kind: "Deployment"}) f := s.Lookup("spec", "template", "spec", "containers") fmt.Println(f.Schema.Description[:70] + "...") fmt.Println(f.Schema.Type) fmt.Println(f.PatchStrategyAndKey()) // merge patch strategy on name }
Output: List of containers belonging to the pod. Containers cannot currently b... [array] merge name
Example (ArrayReplace) ¶
package main import ( "fmt" "sigs.k8s.io/kustomize/kyaml/openapi" "sigs.k8s.io/kustomize/kyaml/yaml" ) func main() { s := openapi.SchemaForResourceType(yaml.TypeMeta{APIVersion: "apps/v1", Kind: "Deployment"}) f := s.Lookup("spec", "template", "spec", "containers", openapi.Elements, "args") fmt.Println(f.Schema.Description[:70] + "...") fmt.Println(f.Schema.Type) fmt.Println(f.PatchStrategyAndKey()) // no patch strategy or merge key }
Output: Arguments to the entrypoint. The docker image's CMD is used if this is... [array]
Example (Map) ¶
package main import ( "fmt" "sigs.k8s.io/kustomize/kyaml/openapi" "sigs.k8s.io/kustomize/kyaml/yaml" ) func main() { s := openapi.SchemaForResourceType(yaml.TypeMeta{APIVersion: "apps/v1", Kind: "Deployment"}) f := s.Lookup("metadata", "labels") fmt.Println(f.Schema.Description[:70] + "...") fmt.Println(f.Schema.Type) }
Output: Map of string keys and values that can be used to organize and categor... [object]
Index ¶
- Constants
- func AddDefinitions(definitions spec.Definitions)
- func AddSchema(s []byte) (*spec.Schema, error)
- func AddSchemaFromFile(path string) error
- func AddSchemaFromFileUsingField(path, field string) error
- func ResetOpenAPI()
- func Resolve(ref *spec.Ref) (*spec.Schema, error)
- func Schema() *spec.Schema
- func SuppressBuiltInSchemaUse()
- type ResourceSchema
Examples ¶
Constants ¶
const Elements = "[]"
const SupplementaryOpenAPIFieldName = "openAPI"
SupplementaryOpenAPIFieldName is the conventional field name (JSON/YAML) containing supplementary OpenAPI definitions.
Variables ¶
This section is empty.
Functions ¶
func AddDefinitions ¶ added in v0.0.11
func AddDefinitions(definitions spec.Definitions)
AddDefinitions adds the definitions to the global schema.
func AddSchema ¶ added in v0.0.11
AddSchema parses s, and adds definitions from s to the global schema.
func AddSchemaFromFile ¶ added in v0.0.12
AddSchemaFromFile reads the file at path and parses the OpenAPI definitions from the field "openAPI"
func AddSchemaFromFileUsingField ¶ added in v0.0.12
AddSchemaFromFileUsingField reads the file at path and parses the OpenAPI definitions from the specified field. If field is the empty string, use the whole document as OpenAPI.
func ResetOpenAPI ¶ added in v0.0.12
func ResetOpenAPI()
ResetOpenAPI resets the openapi data to empty
func SuppressBuiltInSchemaUse ¶ added in v0.0.11
func SuppressBuiltInSchemaUse()
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.
Types ¶
type ResourceSchema ¶
type ResourceSchema struct { // Schema is the OpenAPI schema for a Resource or field Schema *spec.Schema }
ResourceSchema wraps the OpenAPI Schema.
func GetSchema ¶ added in v0.0.11
func GetSchema(s string) (*ResourceSchema, error)
GetSchema parses s into a ResourceSchema, resolving References within the global schema.
func SchemaForResourceType ¶
func SchemaForResourceType(t yaml.TypeMeta) *ResourceSchema
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 (*ResourceSchema) Elements ¶
func (rs *ResourceSchema) Elements() *ResourceSchema
Elements returns the Schema for the elements of an array.
func (*ResourceSchema) Field ¶
func (rs *ResourceSchema) Field(field string) *ResourceSchema
Field returns the Schema for a field.
func (*ResourceSchema) IsEmpty ¶ added in v0.1.1
func (rs *ResourceSchema) IsEmpty() bool
IsEmpty returns true if the ResourceSchema is empty
func (*ResourceSchema) Lookup ¶
func (rs *ResourceSchema) Lookup(path ...string) *ResourceSchema
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 (*ResourceSchema) PatchStrategyAndKey ¶
func (rs *ResourceSchema) PatchStrategyAndKey() (string, string)
PatchStrategyAndKey returns the patch strategy and merge key extensions
Directories ¶
Path | Synopsis |
---|---|
Code generated for package kubernetesapi by go-bindata DO NOT EDIT.
|
Code generated for package kubernetesapi by go-bindata DO NOT EDIT. |
Code generated for package kustomizationapi by go-bindata DO NOT EDIT.
|
Code generated for package kustomizationapi by go-bindata DO NOT EDIT. |