Documentation
¶
Overview ¶
Code generated for package openapi by go-bindata DO NOT EDIT. (@generated) sources: openapi/swagger.json
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 Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func MustAsset(name string) []byte
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- type ResourceSchema
Examples ¶
Constants ¶
const Elements = "[]"
Variables ¶
This section is empty.
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
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 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 (r *ResourceSchema) Elements() *ResourceSchema
Elements returns the Schema for the elements of an array.
func (*ResourceSchema) Field ¶
func (r *ResourceSchema) Field(field string) *ResourceSchema
Field returns the Schema for a field.
func (*ResourceSchema) Lookup ¶
func (r *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 (r *ResourceSchema) PatchStrategyAndKey() (string, string)
PatchStrategyAndKey returns the patch strategy and merge key extensions