Skip to content

Commit

Permalink
Merge pull request #1003 from eddycharly/use-ptr
Browse files Browse the repository at this point in the history
🏃 use ptr package
  • Loading branch information
k8s-ci-robot authored Jul 11, 2024
2 parents b07ad66 + 0adb7e1 commit 7483ddc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (
k8s.io/api v0.30.2
k8s.io/apiextensions-apiserver v0.30.2
k8s.io/apimachinery v0.30.2
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
sigs.k8s.io/yaml v1.4.0
)

Expand All @@ -39,7 +40,6 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)
11 changes: 4 additions & 7 deletions pkg/crd/known_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package crd

import (
apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/utils/ptr"

"sigs.k8s.io/controller-tools/pkg/loader"
)
Expand Down Expand Up @@ -75,7 +76,7 @@ var KnownPackages = map[string]PackageOverride{
p.Schemata[TypeIdent{Name: "RawExtension", Package: pkg}] = apiext.JSONSchemaProps{
// TODO(directxman12): regexp validation for this (or get kube to support it as a format value)
Type: "object",
XPreserveUnknownFields: boolPtr(true),
XPreserveUnknownFields: ptr.To(true),
}
p.AddPackage(pkg) // get the rest of the types
},
Expand All @@ -100,13 +101,13 @@ var KnownPackages = map[string]PackageOverride{

"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1": func(p *Parser, pkg *loader.Package) {
p.Schemata[TypeIdent{Name: "JSON", Package: pkg}] = apiext.JSONSchemaProps{
XPreserveUnknownFields: boolPtr(true),
XPreserveUnknownFields: ptr.To(true),
}
p.AddPackage(pkg) // get the rest of the types
},
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1": func(p *Parser, pkg *loader.Package) {
p.Schemata[TypeIdent{Name: "JSON", Package: pkg}] = apiext.JSONSchemaProps{
XPreserveUnknownFields: boolPtr(true),
XPreserveUnknownFields: ptr.To(true),
}
p.AddPackage(pkg) // get the rest of the types
},
Expand Down Expand Up @@ -159,10 +160,6 @@ var ObjectMetaPackages = map[string]PackageOverride{
},
}

func boolPtr(b bool) *bool {
return &b
}

// AddKnownTypes registers the packages overrides in KnownPackages with the given parser.
func AddKnownTypes(parser *Parser) {
// ensure everything is there before adding to PackageOverrides
Expand Down

0 comments on commit 7483ddc

Please sign in to comment.