Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed May 25, 2020
1 parent 8b7b805 commit 5685c15
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ require (
k8s.io/apimachinery v0.18.3
k8s.io/client-go v12.0.0+incompatible
k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6
kmodules.xyz/client-go v0.0.0-20200525012433-99c6914a1eca
kmodules.xyz/client-go v0.0.0-20200525195850-2fd180961371
kmodules.xyz/crd-schema-fuzz v0.0.0-20200521005638-2433a187de95
sigs.k8s.io/yaml v1.2.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,8 @@ k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6 h1:Oh3Mzx5pJ+yIumsAD0MOEC
k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E=
k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89 h1:d4vVOjXm687F1iLSP2q3lyPPuyvTUt3aVoBpi2DqRsU=
k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
kmodules.xyz/client-go v0.0.0-20200525012433-99c6914a1eca h1:mPVAdb27pSmNt1gKB7UFCKmRSeUEFwSvCXIlKUvy8Fk=
kmodules.xyz/client-go v0.0.0-20200525012433-99c6914a1eca/go.mod h1:sY/eoe4ktxZEoHpr5NpAQ5s22VSwTE8psJtKVeVgLRY=
kmodules.xyz/client-go v0.0.0-20200525195850-2fd180961371 h1:PPawDOMyDHGeDPN8j1epNozaIB/Z7MlJsXpwm/r4jgk=
kmodules.xyz/client-go v0.0.0-20200525195850-2fd180961371/go.mod h1:sY/eoe4ktxZEoHpr5NpAQ5s22VSwTE8psJtKVeVgLRY=
kmodules.xyz/crd-schema-fuzz v0.0.0-20200521005638-2433a187de95 h1:v0S/+ftzL6Xrs9XevgchAOJyPKlRQXPiZf87xotj3X4=
kmodules.xyz/crd-schema-fuzz v0.0.0-20200521005638-2433a187de95/go.mod h1:jpu8xFsDKd6kAWUAKk8oTu/GQGBWqhrcaDeOJdaCJnk=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
Expand Down
60 changes: 58 additions & 2 deletions vendor/kmodules.xyz/client-go/apiextensions/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func RegisterCRDs(client crd_cs.Interface, crds []*CustomResourceDefinition) err
in.Annotations = meta_util.MergeKeys(in.Annotations, crd.V1.Annotations)

in.Spec = crd.V1.Spec
return crd.V1
return in
},
metav1.UpdateOptions{},
)
Expand All @@ -76,6 +76,11 @@ func RegisterCRDs(client crd_cs.Interface, crds []*CustomResourceDefinition) err
crd.V1beta1.Spec.Validation.OpenAPIV3Schema.Type = ""
}

if crd.V1beta1.Spec.Validation != nil &&
crd.V1beta1.Spec.Validation.OpenAPIV3Schema != nil {
removeDefaults(crd.V1beta1.Spec.Validation.OpenAPIV3Schema)
}

_, _, err := v1beta1.CreateOrUpdateCustomResourceDefinition(
context.TODO(),
client,
Expand All @@ -85,7 +90,7 @@ func RegisterCRDs(client crd_cs.Interface, crds []*CustomResourceDefinition) err
in.Annotations = meta_util.MergeKeys(in.Annotations, crd.V1beta1.Annotations)

in.Spec = crd.V1beta1.Spec
return crd.V1beta1
return in
},
metav1.UpdateOptions{},
)
Expand All @@ -97,6 +102,57 @@ func RegisterCRDs(client crd_cs.Interface, crds []*CustomResourceDefinition) err
return WaitForCRDReady(client.ApiextensionsV1beta1().RESTClient(), crds)
}

func removeDefaults(schema *crdv1beta1.JSONSchemaProps) {
if schema == nil {
return
}

schema.Default = nil

if schema.Items != nil {
removeDefaults(schema.Items.Schema)

for idx := range schema.Items.JSONSchemas {
removeDefaults(&schema.Items.JSONSchemas[idx])
}
}

for idx := range schema.AllOf {
removeDefaults(&schema.AllOf[idx])
}
for idx := range schema.OneOf {
removeDefaults(&schema.OneOf[idx])
}
for idx := range schema.AnyOf {
removeDefaults(&schema.AnyOf[idx])
}
if schema.Not != nil {
removeDefaults(schema.Not)
}
for key, prop := range schema.Properties {
removeDefaults(&prop)
schema.Properties[key] = prop
}
if schema.AdditionalProperties != nil {
removeDefaults(schema.AdditionalProperties.Schema)
}
for key, prop := range schema.PatternProperties {
removeDefaults(&prop)
schema.PatternProperties[key] = prop
}
for key, prop := range schema.Dependencies {
removeDefaults(prop.Schema)
schema.Dependencies[key] = prop
}
if schema.AdditionalItems != nil {
removeDefaults(schema.AdditionalItems.Schema)
}
for key, prop := range schema.Definitions {
removeDefaults(&prop)
schema.Definitions[key] = prop
}
}

func WaitForCRDReady(restClient rest.Interface, crds []*CustomResourceDefinition) error {
err := wait.Poll(3*time.Second, 5*time.Minute, func() (bool, error) {
for _, crd := range crds {
Expand Down
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ k8s.io/utils/net
k8s.io/utils/path
k8s.io/utils/pointer
k8s.io/utils/trace
# kmodules.xyz/client-go v0.0.0-20200525012433-99c6914a1eca
# kmodules.xyz/client-go v0.0.0-20200525195850-2fd180961371
kmodules.xyz/client-go
kmodules.xyz/client-go/apiextensions
kmodules.xyz/client-go/apiextensions/v1
Expand Down

0 comments on commit 5685c15

Please sign in to comment.