mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-30 18:01:21 +00:00
update kyaml go.mod and go.sum
also update cmd/config,cmd/kubectl,cmd/resource
This commit is contained in:
@@ -13,8 +13,7 @@ import (
|
||||
func Example() {
|
||||
s := openapi.SchemaForResourceType(yaml.TypeMeta{APIVersion: "apps/v1", Kind: "Deployment"})
|
||||
|
||||
f := s.SchemaForField("spec").
|
||||
SchemaForField("replicas")
|
||||
f := s.Lookup("spec", "replicas")
|
||||
fmt.Println(f.Schema.Description[:70] + "...")
|
||||
fmt.Println(f.Schema.Type)
|
||||
|
||||
@@ -26,10 +25,7 @@ func Example() {
|
||||
func Example_arrayMerge() {
|
||||
s := openapi.SchemaForResourceType(yaml.TypeMeta{APIVersion: "apps/v1", Kind: "Deployment"})
|
||||
|
||||
f := s.SchemaForField("spec").
|
||||
SchemaForField("template").
|
||||
SchemaForField("spec").
|
||||
SchemaForField("containers")
|
||||
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
|
||||
@@ -43,11 +39,7 @@ func Example_arrayMerge() {
|
||||
func Example_arrayReplace() {
|
||||
s := openapi.SchemaForResourceType(yaml.TypeMeta{APIVersion: "apps/v1", Kind: "Deployment"})
|
||||
|
||||
f := s.SchemaForField("spec").
|
||||
SchemaForField("template").
|
||||
SchemaForField("spec").
|
||||
SchemaForField("containers").SchemaForElements().
|
||||
SchemaForField("args")
|
||||
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
|
||||
@@ -60,12 +52,8 @@ func Example_arrayReplace() {
|
||||
func Example_arrayElement() {
|
||||
s := openapi.SchemaForResourceType(yaml.TypeMeta{APIVersion: "apps/v1", Kind: "Deployment"})
|
||||
|
||||
f := s.SchemaForField("spec").
|
||||
SchemaForField("template").
|
||||
SchemaForField("spec").
|
||||
SchemaForField("containers").SchemaForElements().
|
||||
SchemaForField("ports").SchemaForElements().
|
||||
SchemaForField("containerPort")
|
||||
f := s.Lookup("spec", "template", "spec", "containers",
|
||||
openapi.Elements, "ports", openapi.Elements, "containerPort")
|
||||
fmt.Println(f.Schema.Description[:70] + "...")
|
||||
fmt.Println(f.Schema.Type)
|
||||
|
||||
@@ -77,7 +65,7 @@ func Example_arrayElement() {
|
||||
func Example_map() {
|
||||
s := openapi.SchemaForResourceType(yaml.TypeMeta{APIVersion: "apps/v1", Kind: "Deployment"})
|
||||
|
||||
f := s.SchemaForField("metadata").SchemaForField("labels")
|
||||
f := s.Lookup("metadata", "labels")
|
||||
fmt.Println(f.Schema.Description[:70] + "...")
|
||||
fmt.Println(f.Schema.Type)
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ func SchemaForResourceType(t yaml.TypeMeta) *ResourceSchema {
|
||||
return &ResourceSchema{Schema: rs}
|
||||
}
|
||||
|
||||
// SchemaForElements returns the Schema for the elements of an array.
|
||||
func (r *ResourceSchema) SchemaForElements() *ResourceSchema {
|
||||
// Elements returns the Schema for the elements of an array.
|
||||
func (r *ResourceSchema) Elements() *ResourceSchema {
|
||||
// load the schema from swagger.json
|
||||
initSchema()
|
||||
|
||||
@@ -53,8 +53,30 @@ func (r *ResourceSchema) SchemaForElements() *ResourceSchema {
|
||||
return &ResourceSchema{Schema: &s}
|
||||
}
|
||||
|
||||
// SchemaForField returns the Schema for a field.
|
||||
func (r *ResourceSchema) SchemaForField(field string) *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 (r *ResourceSchema) Lookup(path ...string) *ResourceSchema {
|
||||
s := r
|
||||
for _, p := range path {
|
||||
if s == nil {
|
||||
break
|
||||
}
|
||||
if p == Elements {
|
||||
s = s.Elements()
|
||||
continue
|
||||
}
|
||||
s = s.Field(p)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// Field returns the Schema for a field.
|
||||
func (r *ResourceSchema) Field(field string) *ResourceSchema {
|
||||
// load the schema from swagger.json
|
||||
initSchema()
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ func TestSchemaForResourceType(t *testing.T) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
f := s.SchemaForField("spec")
|
||||
f := s.Field("spec")
|
||||
if !assert.NotNil(t, f) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -27,7 +27,7 @@ func TestSchemaForResourceType(t *testing.T) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
replicas := f.SchemaForField("replicas")
|
||||
replicas := f.Field("replicas")
|
||||
if !assert.NotNil(t, replicas) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -36,7 +36,7 @@ func TestSchemaForResourceType(t *testing.T) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
temp := f.SchemaForField("template")
|
||||
temp := f.Field("template")
|
||||
if !assert.NotNil(t, temp) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -45,16 +45,12 @@ func TestSchemaForResourceType(t *testing.T) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
containers := temp.SchemaForField("spec").
|
||||
SchemaForField("containers").
|
||||
SchemaForElements()
|
||||
containers := temp.Field("spec").Field("containers").Elements()
|
||||
if !assert.NotNil(t, containers) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
targetPort := containers.SchemaForField("ports").
|
||||
SchemaForElements().
|
||||
SchemaForField("containerPort")
|
||||
targetPort := containers.Field("ports").Elements().Field("containerPort")
|
||||
if !assert.NotNil(t, targetPort) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -63,8 +59,7 @@ func TestSchemaForResourceType(t *testing.T) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
arg := containers.SchemaForField("args").
|
||||
SchemaForElements()
|
||||
arg := containers.Field("args").Elements()
|
||||
if !assert.NotNil(t, arg) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user