Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🏃 use ptr package #1003

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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