Debian Codegraph @

kyaml/openapi/example_test.go

raw symbols SCIP
1 // Copyright 2019 The Kubernetes Authors.
2 // SPDX-License-Identifier: Apache-2.0
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 // Output:
21 // Number of desired pods. This is a pointer to distinguish between expli...
22 // [integer]
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()) // merge patch strategy on name
32
33 // Output:
34 // List of containers belonging to the pod. Containers cannot currently b...
35 // [array]
36 // merge name
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()) // no patch strategy or merge key
46
47 // Output:
48 // Arguments to the entrypoint. The docker image's CMD is used if this is...
49 // [array]
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 // Output:
61 // Number of port to expose on the pod's IP address. This must be a valid...
62 // [integer]
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 // Output:
73 // Map of string keys and values that can be used to organize and categor...
74 // [object]
75 }