| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
package openapi_test |
| 5 |
|
| 6 |
import ( |
| 7 |
"fmt" |
| 8 |
|
| 9 |
"sigs.k8s.io/kustomize/kyaml/openapi" |
| 10 |
"sigs.k8s.io/kustomize/kyaml/yaml" |
| 11 |
) |
| 12 |
|
| 13 |
func Example() { |
| 14 |
s := openapi.SchemaForResourceType(yaml.TypeMeta{APIVersion: "apps/v1", Kind: "Deployment"}) |
| 15 |
|
| 16 |
f := s.Lookup("spec", "replicas") |
| 17 |
fmt.Println(f.Schema.Description[:70] + "...") |
| 18 |
fmt.Println(f.Schema.Type) |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
} |
| 24 |
|
| 25 |
func Example_arrayMerge() { |
| 26 |
s := openapi.SchemaForResourceType(yaml.TypeMeta{APIVersion: "apps/v1", Kind: "Deployment"}) |
| 27 |
|
| 28 |
f := s.Lookup("spec", "template", "spec", "containers") |
| 29 |
fmt.Println(f.Schema.Description[:70] + "...") |
| 30 |
fmt.Println(f.Schema.Type) |
| 31 |
fmt.Println(f.PatchStrategyAndKey()) |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
} |
| 38 |
|
| 39 |
func Example_arrayReplace() { |
| 40 |
s := openapi.SchemaForResourceType(yaml.TypeMeta{APIVersion: "apps/v1", Kind: "Deployment"}) |
| 41 |
|
| 42 |
f := s.Lookup("spec", "template", "spec", "containers", openapi.Elements, "args") |
| 43 |
fmt.Println(f.Schema.Description[:70] + "...") |
| 44 |
fmt.Println(f.Schema.Type) |
| 45 |
fmt.Println(f.PatchStrategyAndKey()) |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
} |
| 51 |
|
| 52 |
func Example_arrayElement() { |
| 53 |
s := openapi.SchemaForResourceType(yaml.TypeMeta{APIVersion: "apps/v1", Kind: "Deployment"}) |
| 54 |
|
| 55 |
f := s.Lookup("spec", "template", "spec", "containers", |
| 56 |
openapi.Elements, "ports", openapi.Elements, "containerPort") |
| 57 |
fmt.Println(f.Schema.Description[:70] + "...") |
| 58 |
fmt.Println(f.Schema.Type) |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
} |
| 64 |
|
| 65 |
func Example_map() { |
| 66 |
s := openapi.SchemaForResourceType(yaml.TypeMeta{APIVersion: "apps/v1", Kind: "Deployment"}) |
| 67 |
|
| 68 |
f := s.Lookup("metadata", "labels") |
| 69 |
fmt.Println(f.Schema.Description[:70] + "...") |
| 70 |
fmt.Println(f.Schema.Type) |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
} |