From 1e8762fa648d2f66917416b6033600bfa99facfa Mon Sep 17 00:00:00 2001 From: Joe Betz Date: Mon, 9 Nov 2020 14:57:48 -0800 Subject: [PATCH 01/22] Stub out generator --- cmd/controller-gen/main.go | 3 + pkg/applyconfigurations/doc.go | 18 ++ pkg/applyconfigurations/gen.go | 270 ++++++++++++++++++ pkg/applyconfigurations/jsontagutil.go | 97 +++++++ pkg/applyconfigurations/traverse.go | 257 +++++++++++++++++ .../zz_generated.markerhelp.go | 45 +++ 6 files changed, 690 insertions(+) create mode 100644 pkg/applyconfigurations/doc.go create mode 100644 pkg/applyconfigurations/gen.go create mode 100644 pkg/applyconfigurations/jsontagutil.go create mode 100644 pkg/applyconfigurations/traverse.go create mode 100644 pkg/applyconfigurations/zz_generated.markerhelp.go diff --git a/cmd/controller-gen/main.go b/cmd/controller-gen/main.go index 41b899dc7..a2dac8c22 100644 --- a/cmd/controller-gen/main.go +++ b/cmd/controller-gen/main.go @@ -24,6 +24,8 @@ import ( "strings" "github.com/spf13/cobra" + + "sigs.k8s.io/controller-tools/pkg/applyconfigurations" "sigs.k8s.io/controller-tools/pkg/crd" "sigs.k8s.io/controller-tools/pkg/deepcopy" "sigs.k8s.io/controller-tools/pkg/genall" @@ -51,6 +53,7 @@ var ( "crd": crd.Generator{}, "rbac": rbac.Generator{}, "object": deepcopy.Generator{}, + "apply": applyconfigurations.Generator{}, "webhook": webhook.Generator{}, "schemapatch": schemapatcher.Generator{}, } diff --git a/pkg/applyconfigurations/doc.go b/pkg/applyconfigurations/doc.go new file mode 100644 index 000000000..82c2c10f5 --- /dev/null +++ b/pkg/applyconfigurations/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package applyconfigurations generates types for constructing declarative apply configurations. +package applyconfigurations diff --git a/pkg/applyconfigurations/gen.go b/pkg/applyconfigurations/gen.go new file mode 100644 index 000000000..70e3c2119 --- /dev/null +++ b/pkg/applyconfigurations/gen.go @@ -0,0 +1,270 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package applyconfigurations + +import ( + "bytes" + "fmt" + "go/ast" + "go/format" + "io" + "sort" + "strings" + + "sigs.k8s.io/controller-tools/pkg/genall" + "sigs.k8s.io/controller-tools/pkg/loader" + "sigs.k8s.io/controller-tools/pkg/markers" +) + +// Based on deepcopy gen but with legacy marker support removed. + +var ( + enablePkgMarker = markers.Must(markers.MakeDefinition("kubebuilder:object:generate", markers.DescribesPackage, false)) + enableTypeMarker = markers.Must(markers.MakeDefinition("kubebuilder:object:generate", markers.DescribesType, false)) + isObjectMarker = markers.Must(markers.MakeDefinition("kubebuilder:object:root", markers.DescribesType, false)) +) + +// +controllertools:marker:generateHelp + +// Generator generates code containing apply configuration type implementations. +type Generator struct { + // HeaderFile specifies the header text (e.g. license) to prepend to generated files. + HeaderFile string `marker:",optional"` + // Year specifies the year to substitute for " YEAR" in the header file. + Year string `marker:",optional"` +} + +func (Generator) CheckFilter() loader.NodeFilter { + return func(node ast.Node) bool { + // ignore interfaces + _, isIface := node.(*ast.InterfaceType) + return !isIface + } +} + +func (Generator) RegisterMarkers(into *markers.Registry) error { + if err := markers.RegisterAll(into, + enablePkgMarker, enableTypeMarker, isObjectMarker); err != nil { + return err + } + into.AddHelp(enablePkgMarker, + markers.SimpleHelp("apply", "enables or disables object apply configuration generation for this package")) + into.AddHelp( + enableTypeMarker, markers.SimpleHelp("apply", "overrides enabling or disabling apply configuration generation for this type")) + into.AddHelp(isObjectMarker, + markers.SimpleHelp("apply", "enables apply configuration generation for this type")) + return nil +} + +func enabledOnPackage(col *markers.Collector, pkg *loader.Package) (bool, error) { + pkgMarkers, err := markers.PackageMarkers(col, pkg) + if err != nil { + return false, err + } + pkgMarker := pkgMarkers.Get(enablePkgMarker.Name) + if pkgMarker != nil { + return pkgMarker.(bool), nil + } + + return false, nil +} + +func enabledOnType(allTypes bool, info *markers.TypeInfo) bool { + if typeMarker := info.Markers.Get(enableTypeMarker.Name); typeMarker != nil { + return typeMarker.(bool) + } + return allTypes || genObjectInterface(info) +} + +func genObjectInterface(info *markers.TypeInfo) bool { + objectEnabled := info.Markers.Get(isObjectMarker.Name) + if objectEnabled != nil { + return objectEnabled.(bool) + } + return false +} + +func (d Generator) Generate(ctx *genall.GenerationContext) error { + var headerText string + + if d.HeaderFile != "" { + headerBytes, err := ctx.ReadFile(d.HeaderFile) + if err != nil { + return err + } + headerText = string(headerBytes) + } + headerText = strings.ReplaceAll(headerText, " YEAR", " "+d.Year) + + objGenCtx := ObjectGenCtx{ + Collector: ctx.Collector, + Checker: ctx.Checker, + HeaderText: headerText, + } + + for _, root := range ctx.Roots { + outContents := objGenCtx.generateForPackage(root) + if outContents == nil { + continue + } + + writeOut(ctx, root, outContents) + } + + return nil +} + +// ObjectGenCtx contains the common info for generating apply configuration implementations. +// It mostly exists so that generating for a package can be easily tested without +// requiring a full set of output rules, etc. +type ObjectGenCtx struct { + Collector *markers.Collector + Checker *loader.TypeChecker + HeaderText string +} + +// writeHeader writes out the build tag, package declaration, and imports +func writeHeader(pkg *loader.Package, out io.Writer, packageName string, imports *importsList, headerText string) { + // NB(directxman12): blank line after build tags to distinguish them from comments + _, err := fmt.Fprintf(out, `// +build !ignore_autogenerated + +%[3]s + +// Code generated by controller-gen. DO NOT EDIT. + +package %[1]s + +import ( +%[2]s +) + +`, packageName, strings.Join(imports.ImportSpecs(), "\n"), headerText) + if err != nil { + pkg.AddError(err) + } + +} + +// generateForPackage generates apply configuration implementations for +// types in the given package, writing the formatted result to given writer. +// May return nil if source could not be generated. +func (ctx *ObjectGenCtx) generateForPackage(root *loader.Package) []byte { + allTypes, err := enabledOnPackage(ctx.Collector, root) + if err != nil { + root.AddError(err) + return nil + } + + ctx.Checker.Check(root) + + root.NeedTypesInfo() + + byType := make(map[string][]byte) + imports := &importsList{ + byPath: make(map[string]string), + byAlias: make(map[string]string), + pkg: root, + } + // avoid confusing aliases by "reserving" the root package's name as an alias + imports.byAlias[root.Name] = "" + + if err := markers.EachType(ctx.Collector, root, func(info *markers.TypeInfo) { + outContent := new(bytes.Buffer) + + if !enabledOnType(allTypes, info) { + //root.AddError(fmt.Errorf("skipping type: %v", info.Name)) // TODO(jpbetz): Remove + return + } + + // not all types required a generate apply configuration. For example, no apply configuration + // type is needed for Quantity, IntOrString, RawExtension or Unknown. + if !shouldBeApplyConfiguration(root, info) { + //root.AddError(fmt.Errorf("skipping type: %v", info.Name)) // TODO(jpbetz): Remove + return + } + + copyCtx := &applyConfigurationMaker{ + pkg: root, + importsList: imports, + codeWriter: &codeWriter{out: outContent}, + } + + copyCtx.GenerateTypesFor(root, info) + + outBytes := outContent.Bytes() + if len(outBytes) > 0 { + byType[info.Name] = outBytes + } + }); err != nil { + root.AddError(err) + return nil + } + + if len(byType) == 0 { + return nil + } + + outContent := new(bytes.Buffer) + writeHeader(root, outContent, root.Name, imports, ctx.HeaderText) + writeTypes(root, outContent, byType) + + outBytes := outContent.Bytes() + formattedBytes, err := format.Source(outBytes) + if err != nil { + root.AddError(err) + // we still write the invalid source to disk to figure out what went wrong + } else { + outBytes = formattedBytes + } + + return outBytes +} + +// writeTypes writes each method to the file, sorted by type name. +func writeTypes(pkg *loader.Package, out io.Writer, byType map[string][]byte) { + sortedNames := make([]string, 0, len(byType)) + for name := range byType { + sortedNames = append(sortedNames, name) + } + sort.Strings(sortedNames) + + for _, name := range sortedNames { + _, err := out.Write(byType[name]) + if err != nil { + pkg.AddError(err) + } + } +} + +// writeFormatted outputs the given code, after gofmt-ing it. If we couldn't gofmt, +// we write the unformatted code for debugging purposes. +func writeOut(ctx *genall.GenerationContext, root *loader.Package, outBytes []byte) { + outputFile, err := ctx.Open(root, "zz_generated.applyconfigurations.go") + if err != nil { + root.AddError(err) + return + } + defer outputFile.Close() + n, err := outputFile.Write(outBytes) + if err != nil { + root.AddError(err) + return + } + if n < len(outBytes) { + root.AddError(io.ErrShortWrite) + } +} diff --git a/pkg/applyconfigurations/jsontagutil.go b/pkg/applyconfigurations/jsontagutil.go new file mode 100644 index 000000000..01df470b2 --- /dev/null +++ b/pkg/applyconfigurations/jsontagutil.go @@ -0,0 +1,97 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package applyconfigurations + +import ( + "strings" + + "sigs.k8s.io/controller-tools/pkg/markers" +) + +// TODO: This implements the same functionality as https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/runtime/converter.go#L236 +// but is based on the more efficient approach from https://golang.org/src/encoding/json/encode.go + +type jsonTags struct { + name string + omit bool + inline bool + omitempty bool +} + +func (t jsonTags) String() string { + var tag string + if !t.inline { + tag += t.name + } + if t.omitempty { + tag += ",omitempty" + } + if t.inline { + tag += ",inline" + } + return tag +} + +func lookupJsonTags(field markers.FieldInfo) (jsonTags, bool) { + tag := field.Tag.Get("json") + if tag == "" || tag == "-" { + return jsonTags{}, false + } + name, opts := parseTag(tag) + if name == "" { + name = field.Name + } + return jsonTags{ + name: name, + omit: false, + inline: opts.Contains("inline"), + omitempty: opts.Contains("omitempty"), + }, true +} + +type tagOptions string + +// parseTag splits a struct field's json tag into its name and +// comma-separated options. +func parseTag(tag string) (string, tagOptions) { + if idx := strings.Index(tag, ","); idx != -1 { + return tag[:idx], tagOptions(tag[idx+1:]) + } + return tag, "" +} + +// Contains reports whether a comma-separated listAlias of options +// contains a particular substr flag. substr must be surrounded by a +// string boundary or commas. +func (o tagOptions) Contains(optionName string) bool { + if len(o) == 0 { + return false + } + s := string(o) + for s != "" { + var next string + i := strings.Index(s, ",") + if i >= 0 { + s, next = s[:i], s[i+1:] + } + if s == optionName { + return true + } + s = next + } + return false +} diff --git a/pkg/applyconfigurations/traverse.go b/pkg/applyconfigurations/traverse.go new file mode 100644 index 000000000..3c8bb1bb9 --- /dev/null +++ b/pkg/applyconfigurations/traverse.go @@ -0,0 +1,257 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package applyconfigurations + +import ( + "fmt" + "go/ast" + "go/types" + "io" + "path" + "strings" + "unicode" + "unicode/utf8" + + "sigs.k8s.io/controller-tools/pkg/loader" + "sigs.k8s.io/controller-tools/pkg/markers" +) + +// TODO(jpbetz): This was copied from deepcopy-gen + +// codeWriter assists in writing out Go code lines and blocks to a writer. +type codeWriter struct { + out io.Writer +} + +// Line writes a single line. +func (c *codeWriter) Line(line string) { + if _, err := fmt.Fprintln(c.out, line); err != nil { + panic(err) + } +} + +// Linef writes a single line with formatting (as per fmt.Sprintf). +func (c *codeWriter) Linef(line string, args ...interface{}) { + if _, err := fmt.Fprintf(c.out, line+"\n", args...); err != nil { + panic(err) + } +} + +// importsList keeps track of required imports, automatically assigning aliases +// to import statement. +type importsList struct { + byPath map[string]string + byAlias map[string]string + + pkg *loader.Package +} + +// NeedImport marks that the given package is needed in the list of imports, +// returning the ident (import alias) that should be used to reference the package. +func (l *importsList) NeedImport(importPath string) string { + // we get an actual path from Package, which might include venddored + // packages if running on a package in vendor. + if ind := strings.LastIndex(importPath, "/vendor/"); ind != -1 { + importPath = importPath[ind+8: /* len("/vendor/") */] + } + + // check to see if we've already assigned an alias, and just return that. + alias, exists := l.byPath[importPath] + if exists { + return alias + } + + // otherwise, calculate an import alias by joining path parts till we get something unique + restPath, nextWord := path.Split(importPath) + + for otherPath, exists := "", true; exists && otherPath != importPath; otherPath, exists = l.byAlias[alias] { + if restPath == "" { + // do something else to disambiguate if we're run out of parts and + // still have duplicates, somehow + alias += "x" + } + + // can't have a first digit, per Go identifier rules, so just skip them + for firstRune, runeLen := utf8.DecodeRuneInString(nextWord); unicode.IsDigit(firstRune); firstRune, runeLen = utf8.DecodeRuneInString(nextWord) { + nextWord = nextWord[runeLen:] + } + + // make a valid identifier by replacing "bad" characters with underscores + nextWord = strings.Map(func(r rune) rune { + if unicode.IsLetter(r) || unicode.IsDigit(r) || r == '_' { + return r + } + return '_' + }, nextWord) + + alias = nextWord + alias + if len(restPath) > 0 { + restPath, nextWord = path.Split(restPath[:len(restPath)-1] /* chop off final slash */) + } + } + + l.byPath[importPath] = alias + l.byAlias[alias] = importPath + return alias +} + +// ImportSpecs returns a string form of each import spec +// (i.e. `alias "path/to/import"). Aliases are only present +// when they don't match the package name. +func (l *importsList) ImportSpecs() []string { + res := make([]string, 0, len(l.byPath)) + for importPath, alias := range l.byPath { + pkg := l.pkg.Imports()[importPath] + if pkg != nil && pkg.Name == alias { + // don't print if alias is the same as package name + // (we've already taken care of duplicates). + res = append(res, fmt.Sprintf("%q", importPath)) + } else { + res = append(res, fmt.Sprintf("%s %q", alias, importPath)) + } + } + return res +} + +// namingInfo holds package and syntax for referencing a field, type, +// etc. It's used to allow lazily marking import usage. +// You should generally retrieve the syntax using Syntax. +type namingInfo struct { + // typeInfo is the type being named. + typeInfo types.Type + nameOverride string +} + +// Syntax calculates the code representation of the given type or name, +// and marks that is used (potentially marking an import as used). +func (n *namingInfo) Syntax(basePkg *loader.Package, imports *importsList) string { + if n.nameOverride != "" { + return n.nameOverride + } + + // NB(directxman12): typeInfo.String gets us most of the way there, + // but fails (for us) on named imports, since it uses the full package path. + switch typeInfo := n.typeInfo.(type) { + case *types.Named: + // register that we need an import for this type, + // so we can get the appropriate alias to use. + typeName := typeInfo.Obj() + otherPkg := typeName.Pkg() + if otherPkg == basePkg.Types { + // local import + return typeName.Name() + } + alias := imports.NeedImport(loader.NonVendorPath(otherPkg.Path())) + return alias + "." + typeName.Name() + case *types.Basic: + return typeInfo.String() + case *types.Pointer: + return "*" + (&namingInfo{typeInfo: typeInfo.Elem()}).Syntax(basePkg, imports) + case *types.Slice: + return "[]" + (&namingInfo{typeInfo: typeInfo.Elem()}).Syntax(basePkg, imports) + case *types.Map: + return fmt.Sprintf( + "map[%s]%s", + (&namingInfo{typeInfo: typeInfo.Key()}).Syntax(basePkg, imports), + (&namingInfo{typeInfo: typeInfo.Elem()}).Syntax(basePkg, imports)) + default: + basePkg.AddError(fmt.Errorf("name requested for invalid type: %s", typeInfo)) + return typeInfo.String() + } +} + +// copyMethodMakers makes apply configurations for Go types, +// writing them to its codeWriter. +type applyConfigurationMaker struct { + pkg *loader.Package + *importsList + *codeWriter +} + +// GenerateTypesFor makes makes apply configuration types for the given type, when appropriate +func (c *applyConfigurationMaker) GenerateTypesFor(root *loader.Package, info *markers.TypeInfo) { + typeInfo := root.TypesInfo.TypeOf(info.RawSpec.Name) + if typeInfo == types.Typ[types.Invalid] { + root.AddError(loader.ErrFromNode(fmt.Errorf("unknown type: %s", info.Name), info.RawSpec)) + } + + // TODO(jpbetz): Generate output here + + c.Linef("type %sApplyConfiguration struct {}", info.Name) +} + +// shouldBeApplyConfiguration checks if we're supposed to make apply configurations for the given type. +// +// TODO(jpbetz): Copy over logic for inclusion from requiresApplyConfiguration +func shouldBeApplyConfiguration(pkg *loader.Package, info *markers.TypeInfo) bool { + if !ast.IsExported(info.Name) { + return false + } + + typeInfo := pkg.TypesInfo.TypeOf(info.RawSpec.Name) + if typeInfo == types.Typ[types.Invalid] { + pkg.AddError(loader.ErrFromNode(fmt.Errorf("unknown type: %s", info.Name), info.RawSpec)) + return false + } + + // according to gengo, everything named is an alias, except for an alias to a pointer, + // which is just a pointer, afaict. Just roll with it. + if asPtr, isPtr := typeInfo.(*types.Named).Underlying().(*types.Pointer); isPtr { + typeInfo = asPtr + } + + lastType := typeInfo + if _, isNamed := typeInfo.(*types.Named); isNamed { + for underlyingType := typeInfo.Underlying(); underlyingType != lastType; lastType, underlyingType = underlyingType, underlyingType.Underlying() { + // aliases to other things besides basics need copy methods + // (basics can be straight-up shallow-copied) + if _, isBasic := underlyingType.(*types.Basic); !isBasic { + return true + } + } + } + + // structs are the only thing that's not a basic that apply configurations are generated for + _, isStruct := lastType.(*types.Struct) + if !isStruct { + return false + } + if _, ok := excludeTypes[info.Name]; ok { // TODO(jpbetz): What to do here? + return false + } + var hasJsonTaggedMembers bool + for _, field := range info.Fields { + if _, ok := lookupJsonTags(field); ok { + hasJsonTaggedMembers = true + } + } + return hasJsonTaggedMembers +} + +var ( + rawExtension = "k8s.io/apimachinery/pkg/runtime/RawExtension" + unknown = "k8s.io/apimachinery/pkg/runtime/Unknown" +) +// excludeTypes contains well known types that we do not generate apply configurations for. +// Hard coding because we only have two, very specific types that serve a special purpose +// in the type system here. +var excludeTypes = map[string]struct{}{ + rawExtension: {}, + unknown: {}, + // DO NOT ADD TO THIS LIST. If we need to exclude other types, we should consider allowing the + // go type declarations to be annotated as excluded from this generator. +} diff --git a/pkg/applyconfigurations/zz_generated.markerhelp.go b/pkg/applyconfigurations/zz_generated.markerhelp.go new file mode 100644 index 000000000..84ef16fc2 --- /dev/null +++ b/pkg/applyconfigurations/zz_generated.markerhelp.go @@ -0,0 +1,45 @@ +// +build !ignore_autogenerated + +/* +Copyright2020 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by helpgen. DO NOT EDIT. + +package applyconfigurations + +import ( + "sigs.k8s.io/controller-tools/pkg/markers" +) + +func (Generator) Help() *markers.DefinitionHelp { + return &markers.DefinitionHelp{ + Category: "", + DetailedHelp: markers.DetailedHelp{ + Summary: "generates code containing apply configuration type implementations.", + Details: "", + }, + FieldHelp: map[string]markers.DetailedHelp{ + "HeaderFile": markers.DetailedHelp{ + Summary: "specifies the header text (e.g. license) to prepend to generated files.", + Details: "", + }, + "Year": markers.DetailedHelp{ + Summary: "specifies the year to substitute for \" YEAR\" in the header file.", + Details: "", + }, + }, + } +} From 63421a498e4bd65b24ea43cd2b9447eba93eba78 Mon Sep 17 00:00:00 2001 From: Jefftree Date: Tue, 19 Jan 2021 10:59:18 -0800 Subject: [PATCH 02/22] Add apply gen to controller-tools --- cmd/controller-gen/main.go | 7 +- pkg/applyconfigurations/codewriter.go | 41 ++ pkg/applyconfigurations/gen.go | 304 +++++++++-- pkg/applyconfigurations/jsontagutil.go | 5 +- .../ac/zz_generated.applyconfigurations.go | 331 ++++++++++++ .../testdata/cronjob/cronjob_types.go | 178 +++++++ .../testdata/cronjob/go.mod | 49 ++ .../testdata/cronjob/go.sum | 484 ++++++++++++++++++ .../testdata/cronjob/groupversion_info.go | 20 + pkg/applyconfigurations/traverse.go | 402 ++++++++++----- .../zz_generated.markerhelp.go | 7 +- pkg/deepcopy/testdata/go.sum | 1 + pkg/genall/output.go | 6 + 13 files changed, 1640 insertions(+), 195 deletions(-) create mode 100644 pkg/applyconfigurations/codewriter.go create mode 100644 pkg/applyconfigurations/testdata/cronjob/ac/zz_generated.applyconfigurations.go create mode 100644 pkg/applyconfigurations/testdata/cronjob/cronjob_types.go create mode 100644 pkg/applyconfigurations/testdata/cronjob/go.mod create mode 100644 pkg/applyconfigurations/testdata/cronjob/go.sum create mode 100644 pkg/applyconfigurations/testdata/cronjob/groupversion_info.go diff --git a/cmd/controller-gen/main.go b/cmd/controller-gen/main.go index a2dac8c22..0dd85ce13 100644 --- a/cmd/controller-gen/main.go +++ b/cmd/controller-gen/main.go @@ -142,13 +142,18 @@ func main() { controller-gen object paths=./apis/v1beta1/some_types.go # Generate OpenAPI v3 schemas for API packages and merge them into existing CRD manifests - controller-gen schemapatch:manifests=./manifests output:dir=./manifests paths=./pkg/apis/... + controller-gen schemapatch:manifests=./manifests output:dir=./manifests paths=./pkg/apis/... # Run all the generators for a given project controller-gen paths=./apis/... # Explain the markers for generating CRDs, and their arguments controller-gen crd -ww + + # Generate applyconfigurations for CRDs for use with Server Side Apply. They will be placed + # into a "ac/" subdirectory + + controller-gen apply paths=./apis/... `, RunE: func(c *cobra.Command, rawOpts []string) error { // print version if asked for it diff --git a/pkg/applyconfigurations/codewriter.go b/pkg/applyconfigurations/codewriter.go new file mode 100644 index 000000000..431de8081 --- /dev/null +++ b/pkg/applyconfigurations/codewriter.go @@ -0,0 +1,41 @@ +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package applyconfigurations + +import ( + "fmt" + "io" +) + +// codeWriter assists in writing out Go code lines and blocks to a writer. +type codeWriter struct { + out io.Writer +} + +// Line writes a single line. +func (c *codeWriter) Line(line string) { + if _, err := fmt.Fprintln(c.out, line); err != nil { + panic(err) + } +} + +// Linef writes a single line with formatting (as per fmt.Sprintf). +func (c *codeWriter) Linef(line string, args ...interface{}) { + if _, err := fmt.Fprintf(c.out, line+"\n", args...); err != nil { + panic(err) + } +} diff --git a/pkg/applyconfigurations/gen.go b/pkg/applyconfigurations/gen.go index 70e3c2119..dc7c2162b 100644 --- a/pkg/applyconfigurations/gen.go +++ b/pkg/applyconfigurations/gen.go @@ -1,5 +1,5 @@ /* -Copyright 2019 The Kubernetes Authors. +Copyright 2021 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -18,26 +18,40 @@ package applyconfigurations import ( "bytes" - "fmt" "go/ast" "go/format" + "go/types" "io" + "path/filepath" "sort" "strings" + "golang.org/x/tools/go/packages" + crdmarkers "sigs.k8s.io/controller-tools/pkg/crd/markers" "sigs.k8s.io/controller-tools/pkg/genall" "sigs.k8s.io/controller-tools/pkg/loader" "sigs.k8s.io/controller-tools/pkg/markers" + "sigs.k8s.io/controller-tools/pkg/util" ) // Based on deepcopy gen but with legacy marker support removed. var ( - enablePkgMarker = markers.Must(markers.MakeDefinition("kubebuilder:object:generate", markers.DescribesPackage, false)) - enableTypeMarker = markers.Must(markers.MakeDefinition("kubebuilder:object:generate", markers.DescribesType, false)) - isObjectMarker = markers.Must(markers.MakeDefinition("kubebuilder:object:root", markers.DescribesType, false)) + groupNameMarker = markers.Must(markers.MakeDefinition("groupName", markers.DescribesPackage, "")) + versionNameMarker = markers.Must(markers.MakeDefinition("versionName", markers.DescribesPackage, "")) + isCRDMarker = markers.Must(markers.MakeDefinition("kubebuilder:resource", markers.DescribesType, crdmarkers.Resource{})) + enablePkgMarker = markers.Must(markers.MakeDefinition("kubebuilder:ac:generate", markers.DescribesPackage, false)) + enableTypeMarker = markers.Must(markers.MakeDefinition("kubebuilder:ac:generate", markers.DescribesType, false)) ) +var importMapping = map[string]string{ + "k8s.io/apimachinery/pkg/apis/": "k8s.io/client-go/applyconfigurations/", + "k8s.io/api/": "k8s.io/client-go/applyconfigurations/", +} + +const importPathSuffix = "ac" +const packageFileName = "zz_generated.applyconfigurations.go" + // +controllertools:marker:generateHelp // Generator generates code containing apply configuration type implementations. @@ -58,16 +72,23 @@ func (Generator) CheckFilter() loader.NodeFilter { func (Generator) RegisterMarkers(into *markers.Registry) error { if err := markers.RegisterAll(into, - enablePkgMarker, enableTypeMarker, isObjectMarker); err != nil { + groupNameMarker, versionNameMarker, isCRDMarker, enablePkgMarker, enableTypeMarker); err != nil { return err } - into.AddHelp(enablePkgMarker, - markers.SimpleHelp("apply", "enables or disables object apply configuration generation for this package")) - into.AddHelp( - enableTypeMarker, markers.SimpleHelp("apply", "overrides enabling or disabling apply configuration generation for this type")) - into.AddHelp(isObjectMarker, + into.AddHelp(groupNameMarker, + markers.SimpleHelp("apply", "specifies the API group name for this package.")) + + into.AddHelp(versionNameMarker, + markers.SimpleHelp("apply", "overrides the API group version for this package (defaults to the package name).")) + into.AddHelp(isCRDMarker, markers.SimpleHelp("apply", "enables apply configuration generation for this type")) + into.AddHelp( + enableTypeMarker, markers.SimpleHelp("apply", "overrides enabling or disabling applyconfigurations generation for the type")) + + into.AddHelp( + enablePkgMarker, markers.SimpleHelp("apply", "overrides enabling or disabling applyconfigurations generation for the package")) return nil + } func enabledOnPackage(col *markers.Collector, pkg *loader.Package) (bool, error) { @@ -79,25 +100,41 @@ func enabledOnPackage(col *markers.Collector, pkg *loader.Package) (bool, error) if pkgMarker != nil { return pkgMarker.(bool), nil } - return false, nil } -func enabledOnType(allTypes bool, info *markers.TypeInfo) bool { +// enableOnType marks whether applyconfiguration generation is enabled for the type. +func enabledOnType(info *markers.TypeInfo) bool { if typeMarker := info.Markers.Get(enableTypeMarker.Name); typeMarker != nil { return typeMarker.(bool) } - return allTypes || genObjectInterface(info) + return isCRD(info) } -func genObjectInterface(info *markers.TypeInfo) bool { - objectEnabled := info.Markers.Get(isObjectMarker.Name) +// isCRD marks whether the type is a CRD based on the +kubebuilder:resource marker. +func isCRD(info *markers.TypeInfo) bool { + objectEnabled := info.Markers.Get(isCRDMarker.Name) if objectEnabled != nil { - return objectEnabled.(bool) + return true } return false } +func isCRDClusterScope(info *markers.TypeInfo) bool { + if o := info.Markers.Get(isCRDMarker.Name); o != nil { + crd := o.(crdmarkers.Resource) + return crd.Scope == "Cluster" + } + return false +} + +func createApplyConfigPackage(pkg *loader.Package) *loader.Package { + newPkg := &loader.Package{Package: &packages.Package{}} + dir := filepath.Dir(pkg.CompiledGoFiles[0]) + newPkg.CompiledGoFiles = append(newPkg.CompiledGoFiles, dir+"/"+importPathSuffix+"/") + return newPkg +} + func (d Generator) Generate(ctx *genall.GenerationContext) error { var headerText string @@ -116,15 +153,45 @@ func (d Generator) Generate(ctx *genall.GenerationContext) error { HeaderText: headerText, } + var pkgList []*loader.Package + visited := make(map[string]*loader.Package) + for _, root := range ctx.Roots { - outContents := objGenCtx.generateForPackage(root) - if outContents == nil { - continue + visited[root.PkgPath] = root + pkgList = append(pkgList, root) + } + + for _, pkg := range pkgList { + for _, imp := range pkg.Imports() { + if _, ok := visited[imp.PkgPath]; ok { + continue + } + visited[imp.PkgPath] = imp } + } + + universe := &Universe{typeMetadata: make(map[types.Type]*typeMetadata)} - writeOut(ctx, root, outContents) + // Multiple traverses are required so that cross package imports are able + // to be resolved. + // generateEligibleTypes creates the universe for generateUsedTypes to perform a + // breadth first search across all CRDs that need ac generation. + // generateForPackage is final step and performs the code generation. + for _, pkg := range visited { + objGenCtx.generateEligibleTypes(pkg, universe) + } + for _, pkg := range visited { + objGenCtx.generateUsedTypes(pkg, universe) } + for _, pkg := range pkgList { + outContents := objGenCtx.generateForPackage(universe, pkg) + if outContents == nil { + continue + } + newPkg := createApplyConfigPackage(pkg) + writeOut(ctx, newPkg, outContents) + } return nil } @@ -137,73 +204,198 @@ type ObjectGenCtx struct { HeaderText string } -// writeHeader writes out the build tag, package declaration, and imports -func writeHeader(pkg *loader.Package, out io.Writer, packageName string, imports *importsList, headerText string) { - // NB(directxman12): blank line after build tags to distinguish them from comments - _, err := fmt.Fprintf(out, `// +build !ignore_autogenerated +// generateEligibleTypes generates a universe of all possible ApplyConfiguration types. +// The function also scans all imported packages for types that are eligible to be ApplyConfigurations. +// This first pass is necessary because the loader package is not able to follow references between packages +// and this universe constructs the necessary references. +func (ctx *ObjectGenCtx) generateEligibleTypes(root *loader.Package, universe *Universe) { + ctx.Checker.Check(root) + root.NeedTypesInfo() -%[3]s + if err := markers.EachType(ctx.Collector, root, func(info *markers.TypeInfo) { + // not all types required a generate apply configuration. For example, no apply configuration + // type is needed for Quantity, IntOrString, RawExtension or Unknown. -// Code generated by controller-gen. DO NOT EDIT. + if shouldBeApplyConfiguration(root, info) { + typeInfo := root.TypesInfo.TypeOf(info.RawSpec.Name) + universe.typeMetadata[typeInfo] = &typeMetadata{ + info: info, + root: root, + eligible: true, + used: false, + } + } -package %[1]s + }); err != nil { + root.AddError(err) + return + } + return +} -import ( -%[2]s -) +// generateUsedTypes does a breadth first search from each top level root object +// to find all ApplyConfiguration types that must be generated based on the fields +// that the object references. +func (ctx *ObjectGenCtx) generateUsedTypes(root *loader.Package, universe *Universe) { + ctx.Checker.Check(root) + root.NeedTypesInfo() -`, packageName, strings.Join(imports.ImportSpecs(), "\n"), headerText) - if err != nil { - pkg.AddError(err) + if err := markers.EachType(ctx.Collector, root, func(info *markers.TypeInfo) { + if !enabledOnType(info) { + return + } + + var q []types.Type + q = append(q, root.TypesInfo.TypeOf(info.RawSpec.Name)) + + for len(q) > 0 { + node := universe.typeMetadata[q[0]] + q = q[1:] + if node.used { + continue + } + node.used = true + if len(node.info.Fields) > 0 { + for _, field := range node.info.Fields { + fieldType := node.root.TypesInfo.TypeOf(field.RawField.Type) + resolved := false + // TODO: Are these all the types that need to be resolved? + for !resolved { + resolved = true + switch typeInfo := fieldType.(type) { + case *types.Pointer: + fieldType = typeInfo.Elem() + resolved = false + case *types.Slice: + fieldType = typeInfo.Elem() + resolved = false + } + } + + if _, ok := universe.typeMetadata[fieldType]; ok { + q = append(q, fieldType) + } + } + } + } + }); err != nil { + root.AddError(err) + return + } + return +} + +type Universe struct { + typeMetadata map[types.Type]*typeMetadata +} + +type typeMetadata struct { + info *markers.TypeInfo + root *loader.Package + eligible bool + used bool +} + +func (u *Universe) existingApplyConfigPath(_ *types.Named, pkgPath string) (string, bool) { + for prefix, replacePath := range importMapping { + if strings.HasPrefix(pkgPath, prefix) { + path := replacePath + strings.TrimPrefix(pkgPath, prefix) + return path, true + } + } + return "", false +} + +func (u *Universe) IsApplyConfigGenerated(typeInfo *types.Named) bool { + if t, ok := u.typeMetadata[typeInfo]; ok { + return t.used } + return false +} +func (u *Universe) GetApplyConfigPath(typeInfo *types.Named, pkgPath string) (string, bool) { + isApplyConfigGenerated := u.IsApplyConfigGenerated(typeInfo) + if path, ok := u.existingApplyConfigPath(typeInfo, pkgPath); ok { + if isApplyConfigGenerated { + return path, true + } + return pkgPath, false + } + // ApplyConfig is necessary but location is not explicitly specified. Assume the ApplyConfig exists at the below directory + if isApplyConfigGenerated { + return pkgPath + "/" + importPathSuffix, true + } + return pkgPath, false } // generateForPackage generates apply configuration implementations for // types in the given package, writing the formatted result to given writer. // May return nil if source could not be generated. -func (ctx *ObjectGenCtx) generateForPackage(root *loader.Package) []byte { - allTypes, err := enabledOnPackage(ctx.Collector, root) +func (ctx *ObjectGenCtx) generateForPackage(universe *Universe, root *loader.Package) []byte { + pkgMarkers, err := markers.PackageMarkers(ctx.Collector, root) if err != nil { root.AddError(err) - return nil + } + group := "" + if val := pkgMarkers.Get("groupName"); val != nil { + group = val.(string) } - ctx.Checker.Check(root) - - root.NeedTypesInfo() + version := root.Name + if val := pkgMarkers.Get("versionName"); val != nil { + version = val.(string) + } byType := make(map[string][]byte) - imports := &importsList{ - byPath: make(map[string]string), - byAlias: make(map[string]string), - pkg: root, + imports := util.NewImportsList(root) + + enabled, _ := enabledOnPackage(ctx.Collector, root) + if !enabled { + return nil } - // avoid confusing aliases by "reserving" the root package's name as an alias - imports.byAlias[root.Name] = "" if err := markers.EachType(ctx.Collector, root, func(info *markers.TypeInfo) { outContent := new(bytes.Buffer) - if !enabledOnType(allTypes, info) { - //root.AddError(fmt.Errorf("skipping type: %v", info.Name)) // TODO(jpbetz): Remove - return + if t, ok := universe.typeMetadata[root.TypesInfo.TypeOf(info.RawSpec.Name)]; ok { + if !t.used { + return + } } - // not all types required a generate apply configuration. For example, no apply configuration - // type is needed for Quantity, IntOrString, RawExtension or Unknown. if !shouldBeApplyConfiguration(root, info) { - //root.AddError(fmt.Errorf("skipping type: %v", info.Name)) // TODO(jpbetz): Remove return } copyCtx := &applyConfigurationMaker{ pkg: root, - importsList: imports, + ImportsList: imports, codeWriter: &codeWriter{out: outContent}, } - copyCtx.GenerateTypesFor(root, info) + copyCtx.GenerateTypesFor(universe, root, info) + for _, field := range info.Fields { + if field.Name != "" { + switch root.TypesInfo.TypeOf(field.RawField.Type).(type) { + case *types.Slice: + copyCtx.GenerateMemberSetForSlice(universe, field, root, info) + case *types.Map: + copyCtx.GenerateMemberSetForMap(universe, field, root, info) + default: + copyCtx.GenerateMemberSet(universe, field, root, info) + } + } + } + + if enabledOnType(info) { + copyCtx.GenerateRootStructConstructor(root, info, isCRDClusterScope(info), group, version) + } else { + copyCtx.GenerateStructConstructor(root, info) + } + + if enabledOnType(info) { + copyCtx.GenerateRootFunctions(universe, root, info) + } outBytes := outContent.Bytes() if len(outBytes) > 0 { @@ -219,7 +411,7 @@ func (ctx *ObjectGenCtx) generateForPackage(root *loader.Package) []byte { } outContent := new(bytes.Buffer) - writeHeader(root, outContent, root.Name, imports, ctx.HeaderText) + util.WriteHeader(root, outContent, root.Name, imports, ctx.HeaderText) writeTypes(root, outContent, byType) outBytes := outContent.Bytes() @@ -253,7 +445,7 @@ func writeTypes(pkg *loader.Package, out io.Writer, byType map[string][]byte) { // writeFormatted outputs the given code, after gofmt-ing it. If we couldn't gofmt, // we write the unformatted code for debugging purposes. func writeOut(ctx *genall.GenerationContext, root *loader.Package, outBytes []byte) { - outputFile, err := ctx.Open(root, "zz_generated.applyconfigurations.go") + outputFile, err := ctx.Open(root, packageFileName) if err != nil { root.AddError(err) return diff --git a/pkg/applyconfigurations/jsontagutil.go b/pkg/applyconfigurations/jsontagutil.go index 01df470b2..fa37243aa 100644 --- a/pkg/applyconfigurations/jsontagutil.go +++ b/pkg/applyconfigurations/jsontagutil.go @@ -22,8 +22,7 @@ import ( "sigs.k8s.io/controller-tools/pkg/markers" ) -// TODO: This implements the same functionality as https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/runtime/converter.go#L236 -// but is based on the more efficient approach from https://golang.org/src/encoding/json/encode.go +// TODO(jefftree): Import from k8s.io/code-generator/cmd/applyconfiguration-gen/generators/jsontagutil.go instead. type jsonTags struct { name string @@ -46,7 +45,7 @@ func (t jsonTags) String() string { return tag } -func lookupJsonTags(field markers.FieldInfo) (jsonTags, bool) { +func lookupJSONTags(field markers.FieldInfo) (jsonTags, bool) { tag := field.Tag.Get("json") if tag == "" || tag == "-" { return jsonTags{}, false diff --git a/pkg/applyconfigurations/testdata/cronjob/ac/zz_generated.applyconfigurations.go b/pkg/applyconfigurations/testdata/cronjob/ac/zz_generated.applyconfigurations.go new file mode 100644 index 000000000..1d6133a79 --- /dev/null +++ b/pkg/applyconfigurations/testdata/cronjob/ac/zz_generated.applyconfigurations.go @@ -0,0 +1,331 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 2022 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by controller-gen. DO NOT EDIT. + +package testdata + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + v1beta1 "k8s.io/client-go/applyconfigurations/batch/v1beta1" + v1 "k8s.io/client-go/applyconfigurations/core/v1" + applyconfigurationsmetav1 "k8s.io/client-go/applyconfigurations/meta/v1" + cronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob" +) + +// AssociativeTypeApplyConfiguration represents a declarative configuration of the AssociativeType type for use +// with apply. +type AssociativeTypeApplyConfiguration struct { + Name *string `json:"name,omitempty"` + Secondary *int `json:"secondary,omitempty"` + Foo *string `json:"foo,omitempty"` +} + +// WithName sets the Name field in the declarative configuration to the given value +func (b *AssociativeTypeApplyConfiguration) WithName(value string) *AssociativeTypeApplyConfiguration { + b.Name = &value + return b +} + +// WithSecondary sets the Secondary field in the declarative configuration to the given value +func (b *AssociativeTypeApplyConfiguration) WithSecondary(value int) *AssociativeTypeApplyConfiguration { + b.Secondary = &value + return b +} + +// WithFoo sets the Foo field in the declarative configuration to the given value +func (b *AssociativeTypeApplyConfiguration) WithFoo(value string) *AssociativeTypeApplyConfiguration { + b.Foo = &value + return b +} + +// AssociativeTypeApplyConfiguration represents a declarative configuration of the AssociativeType type for use +// with apply. +func AssociativeType() *AssociativeTypeApplyConfiguration { + return &AssociativeTypeApplyConfiguration{} +} + +// CronJobApplyConfiguration represents a declarative configuration of the CronJob type for use +// with apply. +type CronJobApplyConfiguration struct { + applyconfigurationsmetav1.TypeMetaApplyConfiguration `json:",inline"` + *applyconfigurationsmetav1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *CronJobSpecApplyConfiguration `json:"spec,omitempty"` + Status *CronJobStatusApplyConfiguration `json:"status,omitempty"` +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +func (b *CronJobApplyConfiguration) WithSpec(value *CronJobSpecApplyConfiguration) *CronJobApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +func (b *CronJobApplyConfiguration) WithStatus(value *CronJobStatusApplyConfiguration) *CronJobApplyConfiguration { + b.Status = value + return b +} + +// CronJobApplyConfiguration represents a declarative configuration of the CronJob type for use +// with apply. +func CronJob(name, namespace string) *CronJobApplyConfiguration { + ac := &CronJobApplyConfiguration{} + ac.WithName(name) + ac.WithNamespace(namespace) + ac.WithKind("CronJob") + ac.WithAPIVersion("testdata.kubebuilder.io/v1") + return ac +} +func (ac *CronJobApplyConfiguration) WithKind(value string) *CronJobApplyConfiguration { + ac.Kind = &value + return ac +} +func (ac *CronJobApplyConfiguration) WithAPIVersion(value string) *CronJobApplyConfiguration { + ac.APIVersion = &value + return ac +} +func (ac *CronJobApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if ac.ObjectMetaApplyConfiguration == nil { + ac.ObjectMetaApplyConfiguration = &applyconfigurationsmetav1.ObjectMetaApplyConfiguration{} + } +} +func (ac *CronJobApplyConfiguration) WithName(value string) *CronJobApplyConfiguration { + ac.ensureObjectMetaApplyConfigurationExists() + ac.Name = &value + return ac +} +func (ac *CronJobApplyConfiguration) WithNamespace(value string) *CronJobApplyConfiguration { + ac.Namespace = &value + return ac +} +func (ac *CronJobApplyConfiguration) GetName() string { + ac.ensureObjectMetaApplyConfigurationExists() + return *ac.Name +} +func (ac *CronJobApplyConfiguration) GetNamespace() string { + ac.ensureObjectMetaApplyConfigurationExists() + return *ac.Namespace +} + +// CronJobSpecApplyConfiguration represents a declarative configuration of the CronJobSpec type for use +// with apply. +type CronJobSpecApplyConfiguration struct { + Schedule *string `json:"schedule,omitempty"` + StartingDeadlineSeconds *int64 `json:"startingDeadlineSeconds,omitempty"` + ConcurrencyPolicy *cronjob.ConcurrencyPolicy `json:"concurrencyPolicy,omitempty"` + Suspend *bool `json:"suspend,omitempty"` + BinaryName []byte `json:"binaryName,omitempty"` + CanBeNull *string `json:"canBeNull,omitempty"` + JobTemplate *v1beta1.JobTemplateSpecApplyConfiguration `json:"jobTemplate,omitempty"` + SuccessfulJobsHistoryLimit *int32 `json:"successfulJobsHistoryLimit,omitempty"` + FailedJobsHistoryLimit *int32 `json:"failedJobsHistoryLimit,omitempty"` + StringSliceData map[string][]string `json:"stringSliceData,omitempty"` + PtrData map[string]*string `json:"ptrData,omitempty"` + Slice []string `json:"slice,omitempty"` + SlicePtr []*string `json:"slicePtr,omitempty"` + SliceStruct []*ExampleStructApplyConfiguration `json:"sliceStruct,omitempty"` + BuiltInReference *v1.PodSpecApplyConfiguration `json:"builtInReference,omitempty"` + Int *int `json:"int,omitempty"` + AssociativeList []AssociativeTypeApplyConfiguration `json:"associativeList,omitempty"` +} + +// WithSchedule sets the Schedule field in the declarative configuration to the given value +func (b *CronJobSpecApplyConfiguration) WithSchedule(value string) *CronJobSpecApplyConfiguration { + b.Schedule = &value + return b +} + +// WithStartingDeadlineSeconds sets the StartingDeadlineSeconds field in the declarative configuration to the given value +func (b *CronJobSpecApplyConfiguration) WithStartingDeadlineSeconds(value *int64) *CronJobSpecApplyConfiguration { + b.StartingDeadlineSeconds = value + return b +} + +// WithConcurrencyPolicy sets the ConcurrencyPolicy field in the declarative configuration to the given value +func (b *CronJobSpecApplyConfiguration) WithConcurrencyPolicy(value cronjob.ConcurrencyPolicy) *CronJobSpecApplyConfiguration { + b.ConcurrencyPolicy = &value + return b +} + +// WithSuspend sets the Suspend field in the declarative configuration to the given value +func (b *CronJobSpecApplyConfiguration) WithSuspend(value *bool) *CronJobSpecApplyConfiguration { + b.Suspend = value + return b +} + +// WithInternalData sets the InternalData field in the declarative configuration to the given value +func (b *CronJobSpecApplyConfiguration) WithInternalData(value string) *CronJobSpecApplyConfiguration { + return b +} + +// WithBinaryName sets the BinaryName field in the declarative configuration to the given value +func (b *CronJobSpecApplyConfiguration) WithBinaryName(values ...byte) *CronJobSpecApplyConfiguration { + for i := range values { + b.BinaryName = append(b.BinaryName, values[i]) + } + return b +} + +// WithCanBeNull sets the CanBeNull field in the declarative configuration to the given value +func (b *CronJobSpecApplyConfiguration) WithCanBeNull(value string) *CronJobSpecApplyConfiguration { + b.CanBeNull = &value + return b +} + +// WithJobTemplate sets the JobTemplate field in the declarative configuration to the given value +func (b *CronJobSpecApplyConfiguration) WithJobTemplate(value *v1beta1.JobTemplateSpecApplyConfiguration) *CronJobSpecApplyConfiguration { + b.JobTemplate = value + return b +} + +// WithSuccessfulJobsHistoryLimit sets the SuccessfulJobsHistoryLimit field in the declarative configuration to the given value +func (b *CronJobSpecApplyConfiguration) WithSuccessfulJobsHistoryLimit(value *int32) *CronJobSpecApplyConfiguration { + b.SuccessfulJobsHistoryLimit = value + return b +} + +// WithFailedJobsHistoryLimit sets the FailedJobsHistoryLimit field in the declarative configuration to the given value +func (b *CronJobSpecApplyConfiguration) WithFailedJobsHistoryLimit(value *int32) *CronJobSpecApplyConfiguration { + b.FailedJobsHistoryLimit = value + return b +} + +// WithStringSliceData sets the StringSliceData field in the declarative configuration to the given value +func (b *CronJobSpecApplyConfiguration) WithStringSliceData(entries map[string][]string) *CronJobSpecApplyConfiguration { + if b.StringSliceData == nil && len(entries) > 0 { + b.StringSliceData = make(map[string][]string, len(entries)) + } + for k, v := range entries { + b.StringSliceData[k] = v + } + return b +} + +// WithPtrData sets the PtrData field in the declarative configuration to the given value +func (b *CronJobSpecApplyConfiguration) WithPtrData(entries map[string]*string) *CronJobSpecApplyConfiguration { + if b.PtrData == nil && len(entries) > 0 { + b.PtrData = make(map[string]*string, len(entries)) + } + for k, v := range entries { + b.PtrData[k] = v + } + return b +} + +// WithSlice sets the Slice field in the declarative configuration to the given value +func (b *CronJobSpecApplyConfiguration) WithSlice(values ...string) *CronJobSpecApplyConfiguration { + for i := range values { + b.Slice = append(b.Slice, values[i]) + } + return b +} + +// WithSlicePtr sets the SlicePtr field in the declarative configuration to the given value +func (b *CronJobSpecApplyConfiguration) WithSlicePtr(values ...*string) *CronJobSpecApplyConfiguration { + for i := range values { + b.SlicePtr = append(b.SlicePtr, values[i]) + } + return b +} + +// WithSliceStruct sets the SliceStruct field in the declarative configuration to the given value +func (b *CronJobSpecApplyConfiguration) WithSliceStruct(values ...*ExampleStructApplyConfiguration) *CronJobSpecApplyConfiguration { + for i := range values { + b.SliceStruct = append(b.SliceStruct, values[i]) + } + return b +} + +// WithBuiltInReference sets the BuiltInReference field in the declarative configuration to the given value +func (b *CronJobSpecApplyConfiguration) WithBuiltInReference(value *v1.PodSpecApplyConfiguration) *CronJobSpecApplyConfiguration { + b.BuiltInReference = value + return b +} + +// WithInt sets the Int field in the declarative configuration to the given value +func (b *CronJobSpecApplyConfiguration) WithInt(value int) *CronJobSpecApplyConfiguration { + b.Int = &value + return b +} + +// WithAssociativeList sets the AssociativeList field in the declarative configuration to the given value +func (b *CronJobSpecApplyConfiguration) WithAssociativeList(values ...AssociativeTypeApplyConfiguration) *CronJobSpecApplyConfiguration { + for i := range values { + b.AssociativeList = append(b.AssociativeList, values[i]) + } + return b +} + +// CronJobSpecApplyConfiguration represents a declarative configuration of the CronJobSpec type for use +// with apply. +func CronJobSpec() *CronJobSpecApplyConfiguration { + return &CronJobSpecApplyConfiguration{} +} + +// CronJobStatusApplyConfiguration represents a declarative configuration of the CronJobStatus type for use +// with apply. +type CronJobStatusApplyConfiguration struct { + Active []v1.ObjectReferenceApplyConfiguration `json:"active,omitempty"` + LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty"` + LastScheduleMicroTime *metav1.MicroTime `json:"lastScheduleMicroTime,omitempty"` +} + +// WithActive sets the Active field in the declarative configuration to the given value +func (b *CronJobStatusApplyConfiguration) WithActive(values ...v1.ObjectReferenceApplyConfiguration) *CronJobStatusApplyConfiguration { + for i := range values { + b.Active = append(b.Active, values[i]) + } + return b +} + +// WithLastScheduleTime sets the LastScheduleTime field in the declarative configuration to the given value +func (b *CronJobStatusApplyConfiguration) WithLastScheduleTime(value *metav1.Time) *CronJobStatusApplyConfiguration { + b.LastScheduleTime = value + return b +} + +// WithLastScheduleMicroTime sets the LastScheduleMicroTime field in the declarative configuration to the given value +func (b *CronJobStatusApplyConfiguration) WithLastScheduleMicroTime(value *metav1.MicroTime) *CronJobStatusApplyConfiguration { + b.LastScheduleMicroTime = value + return b +} + +// CronJobStatusApplyConfiguration represents a declarative configuration of the CronJobStatus type for use +// with apply. +func CronJobStatus() *CronJobStatusApplyConfiguration { + return &CronJobStatusApplyConfiguration{} +} + +// ExampleStructApplyConfiguration represents a declarative configuration of the ExampleStruct type for use +// with apply. +type ExampleStructApplyConfiguration struct { + ExampleField *string `json:"string,omitempty"` +} + +// WithExampleField sets the ExampleField field in the declarative configuration to the given value +func (b *ExampleStructApplyConfiguration) WithExampleField(value string) *ExampleStructApplyConfiguration { + b.ExampleField = &value + return b +} + +// ExampleStructApplyConfiguration represents a declarative configuration of the ExampleStruct type for use +// with apply. +func ExampleStruct() *ExampleStructApplyConfiguration { + return &ExampleStructApplyConfiguration{} +} diff --git a/pkg/applyconfigurations/testdata/cronjob/cronjob_types.go b/pkg/applyconfigurations/testdata/cronjob/cronjob_types.go new file mode 100644 index 000000000..60129b189 --- /dev/null +++ b/pkg/applyconfigurations/testdata/cronjob/cronjob_types.go @@ -0,0 +1,178 @@ +/* + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +//go:generate ../../../.run-controller-gen.sh paths=. output:dir=. + +package testdata + +import ( + batchv1beta1 "k8s.io/api/batch/v1beta1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. + +// CronJobSpec defines the desired state of CronJob +type CronJobSpec struct { + // The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron. + Schedule string `json:"schedule"` + + // Optional deadline in seconds for starting the job if it misses scheduled + // time for any reason. Missed jobs executions will be counted as failed ones. + // +optional + StartingDeadlineSeconds *int64 `json:"startingDeadlineSeconds,omitempty"` + + // Specifies how to treat concurrent executions of a Job. + // Valid values are: + // - "Allow" (default): allows CronJobs to run concurrently; + // - "Forbid": forbids concurrent runs, skipping next run if previous run hasn't finished yet; + // - "Replace": cancels currently running job and replaces it with a new one + // +optional + ConcurrencyPolicy ConcurrencyPolicy `json:"concurrencyPolicy,omitempty"` + + // This flag tells the controller to suspend subsequent executions, it does + // not apply to already started executions. Defaults to false. + // +optional + Suspend *bool `json:"suspend,omitempty"` + + // This tests that non-serialized fields aren't included in the schema. + InternalData string `json:"-"` + + // This tests byte slice schema generation. + BinaryName []byte `json:"binaryName"` + + // This tests that nullable works correctly + // +nullable + CanBeNull string `json:"canBeNull"` + + // Specifies the job that will be created when executing a CronJob. + JobTemplate batchv1beta1.JobTemplateSpec `json:"jobTemplate"` + + // The number of successful finished jobs to retain. + // This is a pointer to distinguish between explicit zero and not specified. + // +optional + SuccessfulJobsHistoryLimit *int32 `json:"successfulJobsHistoryLimit,omitempty"` + + // The number of failed finished jobs to retain. + // This is a pointer to distinguish between explicit zero and not specified. + // +optional + FailedJobsHistoryLimit *int32 `json:"failedJobsHistoryLimit,omitempty"` + + // This tests string slices are allowed as map values. + StringSliceData map[string][]string `json:"stringSliceData,omitempty"` + + // This tests pointers are allowed as map values. + PtrData map[string]*string `json:"ptrData,omitempty"` + + // This tests that slice has the proper ac generation + // +kubebuilder:default={a,b} + Slice []string `json:"slice"` + + // This tests that slice with pointers has the proper ac generation + // +kubebuilder:default={a,b} + SlicePtr []*string `json:"slicePtr"` + + // This tests that slice with structs has the proper ac generation + // +kubebuilder:default={a,b} + SliceStruct []*ExampleStruct `json:"sliceStruct"` + + // This tests that references to built in types have the proper ac generation + // Built in types are generated under "k8s.io/client-go/applyconfigurations" + BuiltInReference *corev1.PodSpec `json:"builtInReference"` + + // This tests that non-pointer ints have the proper ac generation + Int int `json:"int"` + + // This tests that associative lists work. + // +listType=map + // +listMapKey=name + // +listMapKey=secondary + AssociativeList []AssociativeType `json:"associativeList"` +} + +type AssociativeType struct { + Name string `json:"name"` + Secondary int `json:"secondary"` + Foo string `json:"foo"` +} + +// ConcurrencyPolicy describes how the job will be handled. +// Only one of the following concurrent policies may be specified. +// If none of the following policies is specified, the default one +// is AllowConcurrent. +// +kubebuilder:validation:Enum=Allow;Forbid;Replace +type ConcurrencyPolicy string + +const ( + // AllowConcurrent allows CronJobs to run concurrently. + AllowConcurrent ConcurrencyPolicy = "Allow" + + // ForbidConcurrent forbids concurrent runs, skipping next run if previous + // hasn't finished yet. + ForbidConcurrent ConcurrencyPolicy = "Forbid" + + // ReplaceConcurrent cancels currently running job and replaces it with a new one. + ReplaceConcurrent ConcurrencyPolicy = "Replace" +) + +// CronJobStatus defines the observed state of CronJob +type CronJobStatus struct { + // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster + // Important: Run "make" to regenerate code after modifying this file + + // A list of pointers to currently running jobs. + // +optional + Active []corev1.ObjectReference `json:"active,omitempty"` + + // Information when was the last time the job was successfully scheduled. + // +optional + LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty"` + + // Information about the last time the job was successfully scheduled, + // with microsecond precision. + // +optional + LastScheduleMicroTime *metav1.MicroTime `json:"lastScheduleMicroTime,omitempty"` +} + +type ExampleStruct struct { + ExampleField string `json:"string"` +} + +// +kubebuilder:subresource:status +// +kubebuilder:resource:singular=mycronjob + +// CronJob is the Schema for the cronjobs API +type CronJob struct { + /* + */ + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec CronJobSpec `json:"spec,omitempty"` + Status CronJobStatus `json:"status,omitempty"` +} + +// CronJobList contains a list of CronJob +type CronJobList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []CronJob `json:"items"` +} + +func init() { + SchemeBuilder.Register(&CronJob{}, &CronJobList{}) +} diff --git a/pkg/applyconfigurations/testdata/cronjob/go.mod b/pkg/applyconfigurations/testdata/cronjob/go.mod new file mode 100644 index 000000000..d30f47ff0 --- /dev/null +++ b/pkg/applyconfigurations/testdata/cronjob/go.mod @@ -0,0 +1,49 @@ +module sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob + +go 1.19 + +require ( + k8s.io/api v0.25.0 + k8s.io/apimachinery v0.25.0 + k8s.io/client-go v0.25.0 +) + +require ( + github.com/PuerkitoBio/purell v1.1.1 // indirect + github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/emicklei/go-restful/v3 v3.8.0 // indirect + github.com/go-logr/logr v1.2.3 // indirect + github.com/go-openapi/jsonpointer v0.19.5 // indirect + github.com/go-openapi/jsonreference v0.19.5 // indirect + github.com/go-openapi/swag v0.19.15 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/gnostic v0.5.7-v3refs // indirect + github.com/google/go-cmp v0.5.9 // indirect + github.com/google/gofuzz v1.2.0 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/mailru/easyjson v0.7.7 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/stretchr/testify v1.8.0 // indirect + golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect + golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect + golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect + golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect + golang.org/x/text v0.3.7 // indirect + golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 // indirect + google.golang.org/appengine v1.6.7 // indirect + google.golang.org/protobuf v1.28.0 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + k8s.io/klog/v2 v2.70.2-0.20220707122935-0990e81f1a8f // indirect + k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect + k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect + sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect + sigs.k8s.io/yaml v1.3.0 // indirect +) diff --git a/pkg/applyconfigurations/testdata/cronjob/go.sum b/pkg/applyconfigurations/testdata/cronjob/go.sum new file mode 100644 index 000000000..2251073c2 --- /dev/null +++ b/pkg/applyconfigurations/testdata/cronjob/go.sum @@ -0,0 +1,484 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= +cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= +cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= +github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= +github.com/emicklei/go-restful/v3 v3.8.0 h1:eCZ8ulSerjdAiaNpF7GxXIE7ZCMo1moN1qX+S609eVw= +github.com/emicklei/go-restful/v3 v3.8.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= +github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= +github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= +github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonreference v0.19.5 h1:1WJP/wi4OjB4iV8KVbH73rQaoialJrqv8gitZLxGLtM= +github.com/go-openapi/jsonreference v0.19.5/go.mod h1:RdybgQwPxbL4UEjuAruzK1x3nE69AqPYEJeo/TWfEeg= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= +github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/gnostic v0.5.7-v3refs h1:FhTMOKj2VhjpouxvWJAV1TL304uMlb9zcDqkl6cEI54= +github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/onsi/ginkgo/v2 v2.1.4 h1:GNapqRSid3zijZ9H77KrgVG4/8KqiyRsxcSxe+7ApXY= +github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 h1:OSnWWcOd/CtWQC2cYSBgbTSJv3ciqd8r54ySIW2y3RE= +golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 h1:M73Iuj3xbbb9Uk1DYhzydthsj6oOd6l9bpuFcNoUvTs= +golang.org/x/time v0.0.0-20220224211638-0e9765cccd65/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +k8s.io/api v0.25.0 h1:H+Q4ma2U/ww0iGB78ijZx6DRByPz6/733jIuFpX70e0= +k8s.io/api v0.25.0/go.mod h1:ttceV1GyV1i1rnmvzT3BST08N6nGt+dudGrquzVQWPk= +k8s.io/apimachinery v0.25.0 h1:MlP0r6+3XbkUG2itd6vp3oxbtdQLQI94fD5gCS+gnoU= +k8s.io/apimachinery v0.25.0/go.mod h1:qMx9eAk0sZQGsXGu86fab8tZdffHbwUfsvzqKn4mfB0= +k8s.io/client-go v0.25.0 h1:CVWIaCETLMBNiTUta3d5nzRbXvY5Hy9Dpl+VvREpu5E= +k8s.io/client-go v0.25.0/go.mod h1:lxykvypVfKilxhTklov0wz1FoaUZ8X4EwbhS6rpRfN8= +k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= +k8s.io/klog/v2 v2.70.2-0.20220707122935-0990e81f1a8f h1:dltw7bAn8bCrQ2CmzzhgoieUZEbWqrvIGVdHGioP5nY= +k8s.io/klog/v2 v2.70.2-0.20220707122935-0990e81f1a8f/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= +k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 h1:MQ8BAZPZlWk3S9K4a9NCkIFQtZShWqoha7snGixVgEA= +k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1/go.mod h1:C/N6wCaBHeBHkHUesQOQy2/MZqGgMAFPqGsGQLdbZBU= +k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed h1:jAne/RjBTyawwAy0utX5eqigAwz/lQhTmy+Hr/Cpue4= +k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k= +sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= +sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= +sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= +sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/pkg/applyconfigurations/testdata/cronjob/groupversion_info.go b/pkg/applyconfigurations/testdata/cronjob/groupversion_info.go new file mode 100644 index 000000000..c1f850329 --- /dev/null +++ b/pkg/applyconfigurations/testdata/cronjob/groupversion_info.go @@ -0,0 +1,20 @@ +/* +Copyright 2022 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +groupName=testdata.kubebuilder.io +// +versionName=v1 +// +kubebuilder:ac:generate=true +package testdata diff --git a/pkg/applyconfigurations/traverse.go b/pkg/applyconfigurations/traverse.go index 3c8bb1bb9..6c5364936 100644 --- a/pkg/applyconfigurations/traverse.go +++ b/pkg/applyconfigurations/traverse.go @@ -1,5 +1,5 @@ /* -Copyright 2019 The Kubernetes Authors. +Copyright 2021 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -20,112 +20,15 @@ import ( "fmt" "go/ast" "go/types" - "io" - "path" - "strings" - "unicode" - "unicode/utf8" "sigs.k8s.io/controller-tools/pkg/loader" "sigs.k8s.io/controller-tools/pkg/markers" + "sigs.k8s.io/controller-tools/pkg/util" ) -// TODO(jpbetz): This was copied from deepcopy-gen - -// codeWriter assists in writing out Go code lines and blocks to a writer. -type codeWriter struct { - out io.Writer -} - -// Line writes a single line. -func (c *codeWriter) Line(line string) { - if _, err := fmt.Fprintln(c.out, line); err != nil { - panic(err) - } -} - -// Linef writes a single line with formatting (as per fmt.Sprintf). -func (c *codeWriter) Linef(line string, args ...interface{}) { - if _, err := fmt.Fprintf(c.out, line+"\n", args...); err != nil { - panic(err) - } -} - -// importsList keeps track of required imports, automatically assigning aliases -// to import statement. -type importsList struct { - byPath map[string]string - byAlias map[string]string - - pkg *loader.Package -} - -// NeedImport marks that the given package is needed in the list of imports, -// returning the ident (import alias) that should be used to reference the package. -func (l *importsList) NeedImport(importPath string) string { - // we get an actual path from Package, which might include venddored - // packages if running on a package in vendor. - if ind := strings.LastIndex(importPath, "/vendor/"); ind != -1 { - importPath = importPath[ind+8: /* len("/vendor/") */] - } - - // check to see if we've already assigned an alias, and just return that. - alias, exists := l.byPath[importPath] - if exists { - return alias - } - - // otherwise, calculate an import alias by joining path parts till we get something unique - restPath, nextWord := path.Split(importPath) - - for otherPath, exists := "", true; exists && otherPath != importPath; otherPath, exists = l.byAlias[alias] { - if restPath == "" { - // do something else to disambiguate if we're run out of parts and - // still have duplicates, somehow - alias += "x" - } - - // can't have a first digit, per Go identifier rules, so just skip them - for firstRune, runeLen := utf8.DecodeRuneInString(nextWord); unicode.IsDigit(firstRune); firstRune, runeLen = utf8.DecodeRuneInString(nextWord) { - nextWord = nextWord[runeLen:] - } - - // make a valid identifier by replacing "bad" characters with underscores - nextWord = strings.Map(func(r rune) rune { - if unicode.IsLetter(r) || unicode.IsDigit(r) || r == '_' { - return r - } - return '_' - }, nextWord) - - alias = nextWord + alias - if len(restPath) > 0 { - restPath, nextWord = path.Split(restPath[:len(restPath)-1] /* chop off final slash */) - } - } - - l.byPath[importPath] = alias - l.byAlias[alias] = importPath - return alias -} - -// ImportSpecs returns a string form of each import spec -// (i.e. `alias "path/to/import"). Aliases are only present -// when they don't match the package name. -func (l *importsList) ImportSpecs() []string { - res := make([]string, 0, len(l.byPath)) - for importPath, alias := range l.byPath { - pkg := l.pkg.Imports()[importPath] - if pkg != nil && pkg.Name == alias { - // don't print if alias is the same as package name - // (we've already taken care of duplicates). - res = append(res, fmt.Sprintf("%q", importPath)) - } else { - res = append(res, fmt.Sprintf("%s %q", alias, importPath)) - } - } - return res -} +var ( + applyConfigAppendString = "ApplyConfiguration" +) // namingInfo holds package and syntax for referencing a field, type, // etc. It's used to allow lazily marking import usage. @@ -137,39 +40,56 @@ type namingInfo struct { } // Syntax calculates the code representation of the given type or name, -// and marks that is used (potentially marking an import as used). -func (n *namingInfo) Syntax(basePkg *loader.Package, imports *importsList) string { +// and returns the apply representation +func (n *namingInfo) Syntax(universe *Universe, basePkg *loader.Package, imports *util.ImportsList) string { if n.nameOverride != "" { return n.nameOverride } - - // NB(directxman12): typeInfo.String gets us most of the way there, - // but fails (for us) on named imports, since it uses the full package path. switch typeInfo := n.typeInfo.(type) { case *types.Named: // register that we need an import for this type, // so we can get the appropriate alias to use. + + var lastType types.Type + appendString := applyConfigAppendString + for underlyingType := typeInfo.Underlying(); underlyingType != lastType; lastType, underlyingType = underlyingType, underlyingType.Underlying() { + // ApplyConfigurations are not necessary for basic types + if _, ok := underlyingType.(*types.Basic); ok { + appendString = "" + } + } + typeName := typeInfo.Obj() otherPkg := typeName.Pkg() - if otherPkg == basePkg.Types { - // local import - return typeName.Name() + + // ApplyConfiguration is in the same package + if otherPkg == basePkg.Types && universe.IsApplyConfigGenerated(typeInfo, otherPkg.Path()) { + return typeName.Name() + appendString + } + + // ApplyConfiguration is in different package + path, isAc := universe.GetApplyConfigPath(typeInfo, otherPkg.Path()) + alias := imports.NeedImport(path) + if !isAc { + appendString = "" } - alias := imports.NeedImport(loader.NonVendorPath(otherPkg.Path())) - return alias + "." + typeName.Name() + return alias + "." + typeName.Name() + appendString case *types.Basic: return typeInfo.String() case *types.Pointer: - return "*" + (&namingInfo{typeInfo: typeInfo.Elem()}).Syntax(basePkg, imports) + return "*" + (&namingInfo{typeInfo: typeInfo.Elem()}).Syntax(universe, basePkg, imports) case *types.Slice: - return "[]" + (&namingInfo{typeInfo: typeInfo.Elem()}).Syntax(basePkg, imports) + return "[]" + (&namingInfo{typeInfo: typeInfo.Elem()}).Syntax(universe, basePkg, imports) case *types.Map: return fmt.Sprintf( "map[%s]%s", - (&namingInfo{typeInfo: typeInfo.Key()}).Syntax(basePkg, imports), - (&namingInfo{typeInfo: typeInfo.Elem()}).Syntax(basePkg, imports)) + (&namingInfo{typeInfo: typeInfo.Key()}).Syntax(universe, basePkg, imports), + (&namingInfo{typeInfo: typeInfo.Elem()}).Syntax(universe, basePkg, imports)) + case *types.Interface: + return "interface{}" + case *types.Signature: + return typeInfo.String() default: - basePkg.AddError(fmt.Errorf("name requested for invalid type: %s", typeInfo)) return typeInfo.String() } } @@ -178,20 +98,242 @@ func (n *namingInfo) Syntax(basePkg *loader.Package, imports *importsList) strin // writing them to its codeWriter. type applyConfigurationMaker struct { pkg *loader.Package - *importsList + *util.ImportsList *codeWriter } // GenerateTypesFor makes makes apply configuration types for the given type, when appropriate -func (c *applyConfigurationMaker) GenerateTypesFor(root *loader.Package, info *markers.TypeInfo) { +func (c *applyConfigurationMaker) GenerateTypesFor(universe *Universe, root *loader.Package, info *markers.TypeInfo) { typeInfo := root.TypesInfo.TypeOf(info.RawSpec.Name) if typeInfo == types.Typ[types.Invalid] { root.AddError(loader.ErrFromNode(fmt.Errorf("unknown type: %s", info.Name), info.RawSpec)) } + if len(info.Fields) == 0 { + return + } - // TODO(jpbetz): Generate output here + c.Linef("// %sApplyConfiguration represents a declarative configuration of the %s type for use", info.Name, info.Name) + c.Linef("// with apply.") + c.Linef("type %sApplyConfiguration struct {", info.Name) + for _, field := range info.Fields { + fieldName := field.Name + fieldType := root.TypesInfo.TypeOf(field.RawField.Type) + fieldNamingInfo := namingInfo{typeInfo: fieldType} + fieldTypeString := fieldNamingInfo.Syntax(universe, root, c.ImportsList) + + if tags, ok := lookupJSONTags(field); ok { + if tags.inline { + c.Linef("%s %s `json:\"%s\"`", fieldName, fieldTypeString, tags.String()) + } else if isPointer(fieldNamingInfo.typeInfo) || isMap(fieldNamingInfo.typeInfo) || isList(fieldNamingInfo.typeInfo) { + tags.omitempty = true + c.Linef("%s %s `json:\"%s\"`", fieldName, fieldTypeString, tags.String()) + } else { + tags.omitempty = true + c.Linef("%s *%s `json:\"%s\"`", fieldName, fieldTypeString, tags.String()) + } + } + } + c.Linef("}") +} + +// These functions implement a specific interface as required by controller-runtime +func (c *applyConfigurationMaker) GenerateRootFunctions(universe *Universe, root *loader.Package, info *markers.TypeInfo) { + // For TypeMeta + c.Linef("func (ac * %[1]sApplyConfiguration) WithKind (value string) *%[1]sApplyConfiguration {", info.Name) + c.Linef("ac.Kind = &value") + c.Linef("return ac") + c.Linef("}") + + c.Linef("func (ac * %[1]sApplyConfiguration) WithAPIVersion (value string) *%[1]sApplyConfiguration {", info.Name) + c.Linef("ac.APIVersion = &value") + c.Linef("return ac") + c.Linef("}") + + metav1ac := c.NeedImport("k8s.io/client-go/applyconfigurations/meta/v1") + c.Linef("func (ac * %[1]sApplyConfiguration) ensureObjectMetaApplyConfigurationExists () {", info.Name) + c.Linef("if ac.ObjectMetaApplyConfiguration == nil {") + c.Linef("ac.ObjectMetaApplyConfiguration = &%s.ObjectMetaApplyConfiguration{}", metav1ac) + c.Linef("}") + c.Linef("}") + + // For ObjectMeta + c.Linef("func (ac * %[1]sApplyConfiguration) WithName(value string) *%[1]sApplyConfiguration {", info.Name) + c.Linef("ac.ensureObjectMetaApplyConfigurationExists()") + c.Linef("ac.Name = &value") + c.Linef("return ac") + c.Linef("}") + + c.Linef("func (ac * %[1]sApplyConfiguration) WithNamespace(value string) *%[1]sApplyConfiguration {", info.Name) + c.Linef("ac.Namespace = &value") + c.Linef("return ac") + c.Linef("}") + + c.Linef("func (ac * %[1]sApplyConfiguration) GetName() string {", info.Name) + c.Linef("ac.ensureObjectMetaApplyConfigurationExists()") + c.Linef("return *ac.Name") + c.Linef("}") + + c.Linef("func (ac * %[1]sApplyConfiguration) GetNamespace() string {", info.Name) + c.Linef("ac.ensureObjectMetaApplyConfigurationExists()") + c.Linef("return *ac.Namespace") + c.Linef("}") - c.Linef("type %sApplyConfiguration struct {}", info.Name) +} + +func (c *applyConfigurationMaker) GenerateStructConstructor(root *loader.Package, info *markers.TypeInfo) { + c.Linef("// %sApplyConfiguration represents a declarative configuration of the %s type for use", info.Name, info.Name) + c.Linef("// with apply.") + c.Linef("func %s() *%sApplyConfiguration {", info.Name, info.Name) + c.Linef("return &%sApplyConfiguration{}", info.Name) + c.Linef("}") +} + +func (c *applyConfigurationMaker) GenerateRootStructConstructor(root *loader.Package, info *markers.TypeInfo, clusterScope bool, group, version string) { + c.Linef("// %sApplyConfiguration represents a declarative configuration of the %s type for use", info.Name, info.Name) + c.Linef("// with apply.") + if clusterScope { + c.Linef("func %s(name string) *%sApplyConfiguration {", info.Name, info.Name) + } else { + c.Linef("func %s(name, namespace string) *%sApplyConfiguration {", info.Name, info.Name) + } + c.Linef("ac := &%sApplyConfiguration{}", info.Name) + c.Linef("ac.WithName(name)") + if !clusterScope { + c.Linef("ac.WithNamespace(namespace)") + } + c.Linef("ac.WithKind(\"%s\")", info.Name) + c.Linef("ac.WithAPIVersion(\"%s/%s\")", group, version) + c.Linef("return ac") + c.Linef("}") +} + +func isApplyConfig(t types.Type) bool { + switch typeInfo := t.(type) { + case *types.Named: + return isApplyConfig(typeInfo.Underlying()) + case *types.Struct: + return true + case *types.Pointer: + return isApplyConfig(typeInfo.Elem()) + default: + return false + } +} + +func isList(t types.Type) bool { + switch t.(type) { + case *types.Slice: + return true + default: + return false + } +} + +func isMap(t types.Type) bool { + switch t.(type) { + case *types.Map: + return true + default: + return false + } +} + +func isPointer(t types.Type) bool { + switch t.(type) { + case *types.Pointer: + return true + default: + return false + } +} + +func (c *applyConfigurationMaker) GenerateMemberSet(universe *Universe, field markers.FieldInfo, root *loader.Package, info *markers.TypeInfo) { + fieldType := root.TypesInfo.TypeOf(field.RawField.Type) + fieldNamingInfo := namingInfo{typeInfo: fieldType} + fieldTypeString := fieldNamingInfo.Syntax(universe, root, c.ImportsList) + + c.Linef("// With%s sets the %s field in the declarative configuration to the given value", field.Name, field.Name) + if isApplyConfig(fieldNamingInfo.typeInfo) && !isPointer(fieldNamingInfo.typeInfo) { + fieldTypeString = "*" + fieldTypeString + } + c.Linef("func (b *%sApplyConfiguration) With%s(value %s) *%sApplyConfiguration {", info.Name, field.Name, fieldTypeString, info.Name) + + if tags, ok := lookupJSONTags(field); ok { + if tags.inline { + c.Linef("if value != nil {") + c.Linef("b.%s = *value", field.Name) + c.Linef("}") + } else if isApplyConfig(fieldNamingInfo.typeInfo) { + c.Linef("b.%s = value", field.Name) + } else if isPointer(fieldNamingInfo.typeInfo) { + c.Linef("b.%s = value", field.Name) + } else { + c.Linef("b.%s = &value", field.Name) + } + } + c.Linef("return b") + c.Linef("}") +} + +func (c *applyConfigurationMaker) GenerateMemberSetForSlice(universe *Universe, field markers.FieldInfo, root *loader.Package, info *markers.TypeInfo) { + fieldType := root.TypesInfo.TypeOf(field.RawField.Type) + fieldNamingInfo := namingInfo{typeInfo: fieldType} + + sliceType := fieldType.(*types.Slice) + listVal := (&namingInfo{typeInfo: sliceType.Elem()}).Syntax(universe, root, c.ImportsList) + + c.Linef("// With%s sets the %s field in the declarative configuration to the given value", field.Name, field.Name) + c.Linef("func (b *%sApplyConfiguration) With%s(values ...%s) *%sApplyConfiguration {", info.Name, field.Name, listVal, info.Name) + + c.Linef("for i := range values {") + if isApplyConfig(fieldNamingInfo.typeInfo) || isPointer(fieldNamingInfo.typeInfo) { + c.Linef("if values[i] == nil {") + c.Linef("panic(\"nil value passed to With%s\")", field.Name) + c.Linef("}") + c.Linef("b.%s[1] = append(b.%s[1], values[i]", field.Name) + } + c.Linef("b.%[1]s = append(b.%[1]s, values[i])", field.Name) + c.Linef("}") + c.Linef("return b") + c.Linef("}") +} + +func (c *applyConfigurationMaker) GenerateMemberSetForMap(universe *Universe, field markers.FieldInfo, root *loader.Package, info *markers.TypeInfo) { + fieldType := root.TypesInfo.TypeOf(field.RawField.Type) + fieldNamingInfo := namingInfo{typeInfo: fieldType} + fieldTypeString := fieldNamingInfo.Syntax(universe, root, c.ImportsList) + + mapType := fieldType.(*types.Map) + k := (&namingInfo{typeInfo: mapType.Key()}).Syntax(universe, root, c.ImportsList) + v := (&namingInfo{typeInfo: mapType.Elem()}).Syntax(universe, root, c.ImportsList) + + c.Linef("// With%s sets the %s field in the declarative configuration to the given value", field.Name, field.Name) + if isApplyConfig(fieldNamingInfo.typeInfo) && !isPointer(fieldNamingInfo.typeInfo) { + fieldTypeString = "*" + fieldTypeString + } + c.Linef("func (b *%sApplyConfiguration) With%s(entries %s) *%sApplyConfiguration {", info.Name, field.Name, fieldTypeString, info.Name) + c.Linef("if b.%s == nil && len(entries) > 0 {", field.Name) + c.Linef("b.%s = make(map[%s]%s, len(entries))", field.Name, k, v) + c.Linef("}") + c.Linef("for k, v := range entries {") + c.Linef("b.%s[k] = v", field.Name) + c.Linef("}") + c.Linef("return b") + c.Linef("}") +} + +func (c *applyConfigurationMaker) GenerateListMapAlias(root *loader.Package, info *markers.TypeInfo) { + var listAlias = ` +// %[1]sList represents a listAlias of %[1]sApplyConfiguration. +type %[1]sList []*%[1]sApplyConfiguration +` + var mapAlias = ` +// %[1]sMap represents a map of %[1]sApplyConfiguration. +type %[1]sMap map[string]%[1]sApplyConfiguration +` + + c.Linef(listAlias, info.Name) + c.Linef(mapAlias, info.Name) } // shouldBeApplyConfiguration checks if we're supposed to make apply configurations for the given type. @@ -217,11 +359,6 @@ func shouldBeApplyConfiguration(pkg *loader.Package, info *markers.TypeInfo) boo lastType := typeInfo if _, isNamed := typeInfo.(*types.Named); isNamed { for underlyingType := typeInfo.Underlying(); underlyingType != lastType; lastType, underlyingType = underlyingType, underlyingType.Underlying() { - // aliases to other things besides basics need copy methods - // (basics can be straight-up shallow-copied) - if _, isBasic := underlyingType.(*types.Basic); !isBasic { - return true - } } } @@ -233,19 +370,20 @@ func shouldBeApplyConfiguration(pkg *loader.Package, info *markers.TypeInfo) boo if _, ok := excludeTypes[info.Name]; ok { // TODO(jpbetz): What to do here? return false } - var hasJsonTaggedMembers bool + var hasJSONTaggedMembers bool for _, field := range info.Fields { - if _, ok := lookupJsonTags(field); ok { - hasJsonTaggedMembers = true + if _, ok := lookupJSONTags(field); ok { + hasJSONTaggedMembers = true } } - return hasJsonTaggedMembers + return hasJSONTaggedMembers } var ( - rawExtension = "k8s.io/apimachinery/pkg/runtime/RawExtension" - unknown = "k8s.io/apimachinery/pkg/runtime/Unknown" + rawExtension = "k8s.io/apimachinery/pkg/runtime/RawExtension" + unknown = "k8s.io/apimachinery/pkg/runtime/Unknown" ) + // excludeTypes contains well known types that we do not generate apply configurations for. // Hard coding because we only have two, very specific types that serve a special purpose // in the type system here. diff --git a/pkg/applyconfigurations/zz_generated.markerhelp.go b/pkg/applyconfigurations/zz_generated.markerhelp.go index 84ef16fc2..9b76ea32f 100644 --- a/pkg/applyconfigurations/zz_generated.markerhelp.go +++ b/pkg/applyconfigurations/zz_generated.markerhelp.go @@ -1,7 +1,8 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated /* -Copyright2020 The Kubernetes Authors. +Copyright2019 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -32,11 +33,11 @@ func (Generator) Help() *markers.DefinitionHelp { Details: "", }, FieldHelp: map[string]markers.DetailedHelp{ - "HeaderFile": markers.DetailedHelp{ + "HeaderFile": { Summary: "specifies the header text (e.g. license) to prepend to generated files.", Details: "", }, - "Year": markers.DetailedHelp{ + "Year": { Summary: "specifies the year to substitute for \" YEAR\" in the header file.", Details: "", }, diff --git a/pkg/deepcopy/testdata/go.sum b/pkg/deepcopy/testdata/go.sum index 965a7973c..eb76c6bed 100644 --- a/pkg/deepcopy/testdata/go.sum +++ b/pkg/deepcopy/testdata/go.sum @@ -151,6 +151,7 @@ gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/pkg/genall/output.go b/pkg/genall/output.go index 3eb43b0c2..9531e82fa 100644 --- a/pkg/genall/output.go +++ b/pkg/genall/output.go @@ -154,6 +154,12 @@ func (o OutputArtifacts) Open(pkg *loader.Package, itemPath string) (io.WriteClo return nil, fmt.Errorf("cannot output to a package with no path on disk") } outDir := filepath.Dir(pkg.CompiledGoFiles[0]) + if _, err := os.Stat(outDir); os.IsNotExist(err) { + if err := os.MkdirAll(outDir, os.ModePerm); err != nil { + return nil, err + } + } + outPath := filepath.Join(outDir, itemPath) return os.Create(outPath) } From d81dfba8b3a31e650b28acf9eb611ecad7420e20 Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Tue, 24 Jan 2023 13:13:55 +0000 Subject: [PATCH 03/22] Add code-generator to go.mod --- go.mod | 11 ++++++++++- go.sum | 23 +++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 1c660bd0c..0d9ea779f 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,8 @@ require ( k8s.io/api v0.33.0-beta.0 k8s.io/apiextensions-apiserver v0.33.0-beta.0 k8s.io/apimachinery v0.33.0-beta.0 + k8s.io/code-generator v0.33.0-beta.0 + k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7 k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 sigs.k8s.io/yaml v1.4.0 ) @@ -24,10 +26,15 @@ require ( github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/fxamacker/cbor/v2 v2.7.0 // indirect github.com/go-logr/logr v1.4.2 // indirect + github.com/go-openapi/jsonpointer v0.21.0 // indirect + github.com/go-openapi/jsonreference v0.20.2 // indirect + github.com/go-openapi/swag v0.23.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/google/gnostic-models v0.6.9 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/kr/text v0.2.0 // indirect + github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -39,9 +46,11 @@ require ( golang.org/x/sync v0.12.0 // indirect golang.org/x/sys v0.31.0 // indirect golang.org/x/text v0.23.0 // indirect + google.golang.org/protobuf v1.36.5 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect k8s.io/klog/v2 v2.130.1 // indirect + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect sigs.k8s.io/randfill v1.0.0 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect diff --git a/go.sum b/go.sum index 3ed093e62..1836a2213 100644 --- a/go.sum +++ b/go.sum @@ -13,6 +13,14 @@ github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= +github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= +github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= +github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= +github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= +github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= +github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= @@ -28,6 +36,8 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/google/gnostic-models v0.6.9 h1:MU/8wDLif2qCXZmzncUQ/BOfxWfthHi63KqpoNbWqVw= +github.com/google/gnostic-models v0.6.9/go.mod h1:CiWsm0s6BSQd1hRn8/QmxqB6BesYcbSZxsz9b0KuDBw= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -40,14 +50,21 @@ github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad/go.mod h1:vavhavw2zAx github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -173,8 +190,14 @@ k8s.io/apiextensions-apiserver v0.33.0-beta.0 h1:3oqBvfd26IOekt96KEfE8A0wA/k1wDS k8s.io/apiextensions-apiserver v0.33.0-beta.0/go.mod h1:TKTeoFcmGvtiDNV+wj8wJfZhamZNOhvi9yOIE2d1iWs= k8s.io/apimachinery v0.33.0-beta.0 h1:vLDBChfQwyimk6AbuT7OZOIqxSg/44JlXuxqBk85j68= k8s.io/apimachinery v0.33.0-beta.0/go.mod h1:S2OIkExGqJOXYSYcAJwQ9zWcc6BkBUdTJUu4M7z0cvo= +k8s.io/code-generator v0.33.0-beta.0 h1:QYiWYFUT9G7lnF1ucDYr/sZUaG/kptrooX2PJxEL+Go= +k8s.io/code-generator v0.33.0-beta.0/go.mod h1:RBvFpvqtyQygCBjMayNyYqdzy+89LdzqAx0Th+dgmzQ= +k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7 h1:2OX19X59HxDprNCVrWi6jb7LW1PoqTlYqEq5H2oetog= +k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= From d91f503ad0050d91be54ffe3a70469936504d9d2 Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Tue, 24 Jan 2023 16:59:16 +0000 Subject: [PATCH 04/22] Integrate upstream apply config generator --- pkg/applyconfigurations/gen.go | 171 ++++++++------------------------- 1 file changed, 40 insertions(+), 131 deletions(-) diff --git a/pkg/applyconfigurations/gen.go b/pkg/applyconfigurations/gen.go index dc7c2162b..866d0d634 100644 --- a/pkg/applyconfigurations/gen.go +++ b/pkg/applyconfigurations/gen.go @@ -17,21 +17,23 @@ limitations under the License. package applyconfigurations import ( - "bytes" + "fmt" "go/ast" - "go/format" "go/types" "io" + "os" "path/filepath" "sort" "strings" "golang.org/x/tools/go/packages" + generatorargs "k8s.io/code-generator/cmd/applyconfiguration-gen/args" + applygenerator "k8s.io/code-generator/cmd/applyconfiguration-gen/generators" + "k8s.io/gengo/generator" crdmarkers "sigs.k8s.io/controller-tools/pkg/crd/markers" "sigs.k8s.io/controller-tools/pkg/genall" "sigs.k8s.io/controller-tools/pkg/loader" "sigs.k8s.io/controller-tools/pkg/markers" - "sigs.k8s.io/controller-tools/pkg/util" ) // Based on deepcopy gen but with legacy marker support removed. @@ -136,61 +138,30 @@ func createApplyConfigPackage(pkg *loader.Package) *loader.Package { } func (d Generator) Generate(ctx *genall.GenerationContext) error { - var headerText string + headerFilePath := d.HeaderFile - if d.HeaderFile != "" { - headerBytes, err := ctx.ReadFile(d.HeaderFile) + if headerFilePath == "" { + tmpFile, err := os.CreateTemp("", "applyconfig-header-*.txt") if err != nil { - return err + return fmt.Errorf("failed to create temporary file: %w", err) } - headerText = string(headerBytes) - } - headerText = strings.ReplaceAll(headerText, " YEAR", " "+d.Year) + tmpFile.Close() - objGenCtx := ObjectGenCtx{ - Collector: ctx.Collector, - Checker: ctx.Checker, - HeaderText: headerText, - } - - var pkgList []*loader.Package - visited := make(map[string]*loader.Package) - - for _, root := range ctx.Roots { - visited[root.PkgPath] = root - pkgList = append(pkgList, root) - } + defer os.Remove(tmpFile.Name()) - for _, pkg := range pkgList { - for _, imp := range pkg.Imports() { - if _, ok := visited[imp.PkgPath]; ok { - continue - } - visited[imp.PkgPath] = imp - } + headerFilePath = tmpFile.Name() } - universe := &Universe{typeMetadata: make(map[types.Type]*typeMetadata)} - - // Multiple traverses are required so that cross package imports are able - // to be resolved. - // generateEligibleTypes creates the universe for generateUsedTypes to perform a - // breadth first search across all CRDs that need ac generation. - // generateForPackage is final step and performs the code generation. - for _, pkg := range visited { - objGenCtx.generateEligibleTypes(pkg, universe) - } - for _, pkg := range visited { - objGenCtx.generateUsedTypes(pkg, universe) + objGenCtx := ObjectGenCtx{ + Collector: ctx.Collector, + Checker: ctx.Checker, + HeaderFilePath: headerFilePath, } - for _, pkg := range pkgList { - outContents := objGenCtx.generateForPackage(universe, pkg) - if outContents == nil { - continue + for _, pkg := range ctx.Roots { + if err := objGenCtx.generateForPackage(pkg); err != nil { + return err } - newPkg := createApplyConfigPackage(pkg) - writeOut(ctx, newPkg, outContents) } return nil } @@ -199,9 +170,9 @@ func (d Generator) Generate(ctx *genall.GenerationContext) error { // It mostly exists so that generating for a package can be easily tested without // requiring a full set of output rules, etc. type ObjectGenCtx struct { - Collector *markers.Collector - Checker *loader.TypeChecker - HeaderText string + Collector *markers.Collector + Checker *loader.TypeChecker + HeaderFilePath string } // generateEligibleTypes generates a universe of all possible ApplyConfiguration types. @@ -331,99 +302,37 @@ func (u *Universe) GetApplyConfigPath(typeInfo *types.Named, pkgPath string) (st // generateForPackage generates apply configuration implementations for // types in the given package, writing the formatted result to given writer. // May return nil if source could not be generated. -func (ctx *ObjectGenCtx) generateForPackage(universe *Universe, root *loader.Package) []byte { - pkgMarkers, err := markers.PackageMarkers(ctx.Collector, root) - if err != nil { - root.AddError(err) - } - group := "" - if val := pkgMarkers.Get("groupName"); val != nil { - group = val.(string) - } - - version := root.Name - if val := pkgMarkers.Get("versionName"); val != nil { - version = val.(string) - } - - byType := make(map[string][]byte) - imports := util.NewImportsList(root) - +func (ctx *ObjectGenCtx) generateForPackage(root *loader.Package) error { enabled, _ := enabledOnPackage(ctx.Collector, root) if !enabled { return nil } - if err := markers.EachType(ctx.Collector, root, func(info *markers.TypeInfo) { - outContent := new(bytes.Buffer) - - if t, ok := universe.typeMetadata[root.TypesInfo.TypeOf(info.RawSpec.Name)]; ok { - if !t.used { - return - } - } + genericArgs, _ := generatorargs.NewDefaults() + genericArgs.InputDirs = []string{root.PkgPath} + genericArgs.OutputPackagePath = filepath.Join(root.PkgPath, importPathSuffix) + genericArgs.GoHeaderFilePath = ctx.HeaderFilePath - if !shouldBeApplyConfiguration(root, info) { - return - } - - copyCtx := &applyConfigurationMaker{ - pkg: root, - ImportsList: imports, - codeWriter: &codeWriter{out: outContent}, - } - - copyCtx.GenerateTypesFor(universe, root, info) - for _, field := range info.Fields { - if field.Name != "" { - switch root.TypesInfo.TypeOf(field.RawField.Type).(type) { - case *types.Slice: - copyCtx.GenerateMemberSetForSlice(universe, field, root, info) - case *types.Map: - copyCtx.GenerateMemberSetForMap(universe, field, root, info) - default: - copyCtx.GenerateMemberSet(universe, field, root, info) - } - } - } - - if enabledOnType(info) { - copyCtx.GenerateRootStructConstructor(root, info, isCRDClusterScope(info), group, version) - } else { - copyCtx.GenerateStructConstructor(root, info) - } - - if enabledOnType(info) { - copyCtx.GenerateRootFunctions(universe, root, info) - } - - outBytes := outContent.Bytes() - if len(outBytes) > 0 { - byType[info.Name] = outBytes - } - }); err != nil { - root.AddError(err) - return nil + if err := generatorargs.Validate(genericArgs); err != nil { + return err } - if len(byType) == 0 { - return nil + b, err := genericArgs.NewBuilder() + if err != nil { + return err } - outContent := new(bytes.Buffer) - util.WriteHeader(root, outContent, root.Name, imports, ctx.HeaderText) - writeTypes(root, outContent, byType) - - outBytes := outContent.Bytes() - formattedBytes, err := format.Source(outBytes) + c, err := generator.NewContext(b, applygenerator.NameSystems(), applygenerator.DefaultNameSystem()) if err != nil { - root.AddError(err) - // we still write the invalid source to disk to figure out what went wrong - } else { - outBytes = formattedBytes + return err } - return outBytes + packages := applygenerator.Packages(c, genericArgs) + if err := c.ExecutePackages(genericArgs.OutputBase, packages); err != nil { + return fmt.Errorf("error executing packages: %w", err) + } + + return nil } // writeTypes writes each method to the file, sorted by type name. From c521047f6463d7c148ad137a5bc9e1affa483bdd Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Fri, 19 May 2023 10:03:09 +0100 Subject: [PATCH 05/22] Cleanup unused code from previous implementation --- cmd/controller-gen/main.go | 2 +- pkg/applyconfigurations/codewriter.go | 41 --- pkg/applyconfigurations/gen.go | 149 +--------- pkg/applyconfigurations/jsontagutil.go | 96 ------ pkg/applyconfigurations/traverse.go | 395 ------------------------- 5 files changed, 4 insertions(+), 679 deletions(-) delete mode 100644 pkg/applyconfigurations/codewriter.go delete mode 100644 pkg/applyconfigurations/jsontagutil.go delete mode 100644 pkg/applyconfigurations/traverse.go diff --git a/cmd/controller-gen/main.go b/cmd/controller-gen/main.go index 0dd85ce13..5204538dc 100644 --- a/cmd/controller-gen/main.go +++ b/cmd/controller-gen/main.go @@ -151,7 +151,7 @@ func main() { controller-gen crd -ww # Generate applyconfigurations for CRDs for use with Server Side Apply. They will be placed - # into a "ac/" subdirectory + # into a "applyconfiguration/" subdirectory controller-gen apply paths=./apis/... `, diff --git a/pkg/applyconfigurations/codewriter.go b/pkg/applyconfigurations/codewriter.go deleted file mode 100644 index 431de8081..000000000 --- a/pkg/applyconfigurations/codewriter.go +++ /dev/null @@ -1,41 +0,0 @@ -/* -Copyright 2021 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package applyconfigurations - -import ( - "fmt" - "io" -) - -// codeWriter assists in writing out Go code lines and blocks to a writer. -type codeWriter struct { - out io.Writer -} - -// Line writes a single line. -func (c *codeWriter) Line(line string) { - if _, err := fmt.Fprintln(c.out, line); err != nil { - panic(err) - } -} - -// Linef writes a single line with formatting (as per fmt.Sprintf). -func (c *codeWriter) Linef(line string, args ...interface{}) { - if _, err := fmt.Fprintf(c.out, line+"\n", args...); err != nil { - panic(err) - } -} diff --git a/pkg/applyconfigurations/gen.go b/pkg/applyconfigurations/gen.go index 866d0d634..6356663b1 100644 --- a/pkg/applyconfigurations/gen.go +++ b/pkg/applyconfigurations/gen.go @@ -20,13 +20,10 @@ import ( "fmt" "go/ast" "go/types" - "io" "os" "path/filepath" - "sort" "strings" - "golang.org/x/tools/go/packages" generatorargs "k8s.io/code-generator/cmd/applyconfiguration-gen/args" applygenerator "k8s.io/code-generator/cmd/applyconfiguration-gen/generators" "k8s.io/gengo/generator" @@ -51,8 +48,7 @@ var importMapping = map[string]string{ "k8s.io/api/": "k8s.io/client-go/applyconfigurations/", } -const importPathSuffix = "ac" -const packageFileName = "zz_generated.applyconfigurations.go" +const importPathSuffix = "applyconfiguration" // +controllertools:marker:generateHelp @@ -60,8 +56,6 @@ const packageFileName = "zz_generated.applyconfigurations.go" type Generator struct { // HeaderFile specifies the header text (e.g. license) to prepend to generated files. HeaderFile string `marker:",optional"` - // Year specifies the year to substitute for " YEAR" in the header file. - Year string `marker:",optional"` } func (Generator) CheckFilter() loader.NodeFilter { @@ -116,25 +110,7 @@ func enabledOnType(info *markers.TypeInfo) bool { // isCRD marks whether the type is a CRD based on the +kubebuilder:resource marker. func isCRD(info *markers.TypeInfo) bool { objectEnabled := info.Markers.Get(isCRDMarker.Name) - if objectEnabled != nil { - return true - } - return false -} - -func isCRDClusterScope(info *markers.TypeInfo) bool { - if o := info.Markers.Get(isCRDMarker.Name); o != nil { - crd := o.(crdmarkers.Resource) - return crd.Scope == "Cluster" - } - return false -} - -func createApplyConfigPackage(pkg *loader.Package) *loader.Package { - newPkg := &loader.Package{Package: &packages.Package{}} - dir := filepath.Dir(pkg.CompiledGoFiles[0]) - newPkg.CompiledGoFiles = append(newPkg.CompiledGoFiles, dir+"/"+importPathSuffix+"/") - return newPkg + return objectEnabled != nil } func (d Generator) Generate(ctx *genall.GenerationContext) error { @@ -175,96 +151,12 @@ type ObjectGenCtx struct { HeaderFilePath string } -// generateEligibleTypes generates a universe of all possible ApplyConfiguration types. -// The function also scans all imported packages for types that are eligible to be ApplyConfigurations. -// This first pass is necessary because the loader package is not able to follow references between packages -// and this universe constructs the necessary references. -func (ctx *ObjectGenCtx) generateEligibleTypes(root *loader.Package, universe *Universe) { - ctx.Checker.Check(root) - root.NeedTypesInfo() - - if err := markers.EachType(ctx.Collector, root, func(info *markers.TypeInfo) { - // not all types required a generate apply configuration. For example, no apply configuration - // type is needed for Quantity, IntOrString, RawExtension or Unknown. - - if shouldBeApplyConfiguration(root, info) { - typeInfo := root.TypesInfo.TypeOf(info.RawSpec.Name) - universe.typeMetadata[typeInfo] = &typeMetadata{ - info: info, - root: root, - eligible: true, - used: false, - } - } - - }); err != nil { - root.AddError(err) - return - } - return -} - -// generateUsedTypes does a breadth first search from each top level root object -// to find all ApplyConfiguration types that must be generated based on the fields -// that the object references. -func (ctx *ObjectGenCtx) generateUsedTypes(root *loader.Package, universe *Universe) { - ctx.Checker.Check(root) - root.NeedTypesInfo() - - if err := markers.EachType(ctx.Collector, root, func(info *markers.TypeInfo) { - if !enabledOnType(info) { - return - } - - var q []types.Type - q = append(q, root.TypesInfo.TypeOf(info.RawSpec.Name)) - - for len(q) > 0 { - node := universe.typeMetadata[q[0]] - q = q[1:] - if node.used { - continue - } - node.used = true - if len(node.info.Fields) > 0 { - for _, field := range node.info.Fields { - fieldType := node.root.TypesInfo.TypeOf(field.RawField.Type) - resolved := false - // TODO: Are these all the types that need to be resolved? - for !resolved { - resolved = true - switch typeInfo := fieldType.(type) { - case *types.Pointer: - fieldType = typeInfo.Elem() - resolved = false - case *types.Slice: - fieldType = typeInfo.Elem() - resolved = false - } - } - - if _, ok := universe.typeMetadata[fieldType]; ok { - q = append(q, fieldType) - } - } - } - } - }); err != nil { - root.AddError(err) - return - } - return -} - type Universe struct { typeMetadata map[types.Type]*typeMetadata } type typeMetadata struct { - info *markers.TypeInfo - root *loader.Package - eligible bool - used bool + used bool } func (u *Universe) existingApplyConfigPath(_ *types.Named, pkgPath string) (string, bool) { @@ -334,38 +226,3 @@ func (ctx *ObjectGenCtx) generateForPackage(root *loader.Package) error { return nil } - -// writeTypes writes each method to the file, sorted by type name. -func writeTypes(pkg *loader.Package, out io.Writer, byType map[string][]byte) { - sortedNames := make([]string, 0, len(byType)) - for name := range byType { - sortedNames = append(sortedNames, name) - } - sort.Strings(sortedNames) - - for _, name := range sortedNames { - _, err := out.Write(byType[name]) - if err != nil { - pkg.AddError(err) - } - } -} - -// writeFormatted outputs the given code, after gofmt-ing it. If we couldn't gofmt, -// we write the unformatted code for debugging purposes. -func writeOut(ctx *genall.GenerationContext, root *loader.Package, outBytes []byte) { - outputFile, err := ctx.Open(root, packageFileName) - if err != nil { - root.AddError(err) - return - } - defer outputFile.Close() - n, err := outputFile.Write(outBytes) - if err != nil { - root.AddError(err) - return - } - if n < len(outBytes) { - root.AddError(io.ErrShortWrite) - } -} diff --git a/pkg/applyconfigurations/jsontagutil.go b/pkg/applyconfigurations/jsontagutil.go deleted file mode 100644 index fa37243aa..000000000 --- a/pkg/applyconfigurations/jsontagutil.go +++ /dev/null @@ -1,96 +0,0 @@ -/* -Copyright 2019 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package applyconfigurations - -import ( - "strings" - - "sigs.k8s.io/controller-tools/pkg/markers" -) - -// TODO(jefftree): Import from k8s.io/code-generator/cmd/applyconfiguration-gen/generators/jsontagutil.go instead. - -type jsonTags struct { - name string - omit bool - inline bool - omitempty bool -} - -func (t jsonTags) String() string { - var tag string - if !t.inline { - tag += t.name - } - if t.omitempty { - tag += ",omitempty" - } - if t.inline { - tag += ",inline" - } - return tag -} - -func lookupJSONTags(field markers.FieldInfo) (jsonTags, bool) { - tag := field.Tag.Get("json") - if tag == "" || tag == "-" { - return jsonTags{}, false - } - name, opts := parseTag(tag) - if name == "" { - name = field.Name - } - return jsonTags{ - name: name, - omit: false, - inline: opts.Contains("inline"), - omitempty: opts.Contains("omitempty"), - }, true -} - -type tagOptions string - -// parseTag splits a struct field's json tag into its name and -// comma-separated options. -func parseTag(tag string) (string, tagOptions) { - if idx := strings.Index(tag, ","); idx != -1 { - return tag[:idx], tagOptions(tag[idx+1:]) - } - return tag, "" -} - -// Contains reports whether a comma-separated listAlias of options -// contains a particular substr flag. substr must be surrounded by a -// string boundary or commas. -func (o tagOptions) Contains(optionName string) bool { - if len(o) == 0 { - return false - } - s := string(o) - for s != "" { - var next string - i := strings.Index(s, ",") - if i >= 0 { - s, next = s[:i], s[i+1:] - } - if s == optionName { - return true - } - s = next - } - return false -} diff --git a/pkg/applyconfigurations/traverse.go b/pkg/applyconfigurations/traverse.go deleted file mode 100644 index 6c5364936..000000000 --- a/pkg/applyconfigurations/traverse.go +++ /dev/null @@ -1,395 +0,0 @@ -/* -Copyright 2021 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package applyconfigurations - -import ( - "fmt" - "go/ast" - "go/types" - - "sigs.k8s.io/controller-tools/pkg/loader" - "sigs.k8s.io/controller-tools/pkg/markers" - "sigs.k8s.io/controller-tools/pkg/util" -) - -var ( - applyConfigAppendString = "ApplyConfiguration" -) - -// namingInfo holds package and syntax for referencing a field, type, -// etc. It's used to allow lazily marking import usage. -// You should generally retrieve the syntax using Syntax. -type namingInfo struct { - // typeInfo is the type being named. - typeInfo types.Type - nameOverride string -} - -// Syntax calculates the code representation of the given type or name, -// and returns the apply representation -func (n *namingInfo) Syntax(universe *Universe, basePkg *loader.Package, imports *util.ImportsList) string { - if n.nameOverride != "" { - return n.nameOverride - } - switch typeInfo := n.typeInfo.(type) { - case *types.Named: - // register that we need an import for this type, - // so we can get the appropriate alias to use. - - var lastType types.Type - appendString := applyConfigAppendString - for underlyingType := typeInfo.Underlying(); underlyingType != lastType; lastType, underlyingType = underlyingType, underlyingType.Underlying() { - // ApplyConfigurations are not necessary for basic types - if _, ok := underlyingType.(*types.Basic); ok { - appendString = "" - } - } - - typeName := typeInfo.Obj() - otherPkg := typeName.Pkg() - - // ApplyConfiguration is in the same package - if otherPkg == basePkg.Types && universe.IsApplyConfigGenerated(typeInfo, otherPkg.Path()) { - return typeName.Name() + appendString - } - - // ApplyConfiguration is in different package - path, isAc := universe.GetApplyConfigPath(typeInfo, otherPkg.Path()) - alias := imports.NeedImport(path) - if !isAc { - appendString = "" - } - return alias + "." + typeName.Name() + appendString - case *types.Basic: - return typeInfo.String() - case *types.Pointer: - return "*" + (&namingInfo{typeInfo: typeInfo.Elem()}).Syntax(universe, basePkg, imports) - case *types.Slice: - return "[]" + (&namingInfo{typeInfo: typeInfo.Elem()}).Syntax(universe, basePkg, imports) - case *types.Map: - return fmt.Sprintf( - "map[%s]%s", - (&namingInfo{typeInfo: typeInfo.Key()}).Syntax(universe, basePkg, imports), - (&namingInfo{typeInfo: typeInfo.Elem()}).Syntax(universe, basePkg, imports)) - case *types.Interface: - return "interface{}" - case *types.Signature: - return typeInfo.String() - default: - return typeInfo.String() - } -} - -// copyMethodMakers makes apply configurations for Go types, -// writing them to its codeWriter. -type applyConfigurationMaker struct { - pkg *loader.Package - *util.ImportsList - *codeWriter -} - -// GenerateTypesFor makes makes apply configuration types for the given type, when appropriate -func (c *applyConfigurationMaker) GenerateTypesFor(universe *Universe, root *loader.Package, info *markers.TypeInfo) { - typeInfo := root.TypesInfo.TypeOf(info.RawSpec.Name) - if typeInfo == types.Typ[types.Invalid] { - root.AddError(loader.ErrFromNode(fmt.Errorf("unknown type: %s", info.Name), info.RawSpec)) - } - if len(info.Fields) == 0 { - return - } - - c.Linef("// %sApplyConfiguration represents a declarative configuration of the %s type for use", info.Name, info.Name) - c.Linef("// with apply.") - c.Linef("type %sApplyConfiguration struct {", info.Name) - for _, field := range info.Fields { - fieldName := field.Name - fieldType := root.TypesInfo.TypeOf(field.RawField.Type) - fieldNamingInfo := namingInfo{typeInfo: fieldType} - fieldTypeString := fieldNamingInfo.Syntax(universe, root, c.ImportsList) - - if tags, ok := lookupJSONTags(field); ok { - if tags.inline { - c.Linef("%s %s `json:\"%s\"`", fieldName, fieldTypeString, tags.String()) - } else if isPointer(fieldNamingInfo.typeInfo) || isMap(fieldNamingInfo.typeInfo) || isList(fieldNamingInfo.typeInfo) { - tags.omitempty = true - c.Linef("%s %s `json:\"%s\"`", fieldName, fieldTypeString, tags.String()) - } else { - tags.omitempty = true - c.Linef("%s *%s `json:\"%s\"`", fieldName, fieldTypeString, tags.String()) - } - } - } - c.Linef("}") -} - -// These functions implement a specific interface as required by controller-runtime -func (c *applyConfigurationMaker) GenerateRootFunctions(universe *Universe, root *loader.Package, info *markers.TypeInfo) { - // For TypeMeta - c.Linef("func (ac * %[1]sApplyConfiguration) WithKind (value string) *%[1]sApplyConfiguration {", info.Name) - c.Linef("ac.Kind = &value") - c.Linef("return ac") - c.Linef("}") - - c.Linef("func (ac * %[1]sApplyConfiguration) WithAPIVersion (value string) *%[1]sApplyConfiguration {", info.Name) - c.Linef("ac.APIVersion = &value") - c.Linef("return ac") - c.Linef("}") - - metav1ac := c.NeedImport("k8s.io/client-go/applyconfigurations/meta/v1") - c.Linef("func (ac * %[1]sApplyConfiguration) ensureObjectMetaApplyConfigurationExists () {", info.Name) - c.Linef("if ac.ObjectMetaApplyConfiguration == nil {") - c.Linef("ac.ObjectMetaApplyConfiguration = &%s.ObjectMetaApplyConfiguration{}", metav1ac) - c.Linef("}") - c.Linef("}") - - // For ObjectMeta - c.Linef("func (ac * %[1]sApplyConfiguration) WithName(value string) *%[1]sApplyConfiguration {", info.Name) - c.Linef("ac.ensureObjectMetaApplyConfigurationExists()") - c.Linef("ac.Name = &value") - c.Linef("return ac") - c.Linef("}") - - c.Linef("func (ac * %[1]sApplyConfiguration) WithNamespace(value string) *%[1]sApplyConfiguration {", info.Name) - c.Linef("ac.Namespace = &value") - c.Linef("return ac") - c.Linef("}") - - c.Linef("func (ac * %[1]sApplyConfiguration) GetName() string {", info.Name) - c.Linef("ac.ensureObjectMetaApplyConfigurationExists()") - c.Linef("return *ac.Name") - c.Linef("}") - - c.Linef("func (ac * %[1]sApplyConfiguration) GetNamespace() string {", info.Name) - c.Linef("ac.ensureObjectMetaApplyConfigurationExists()") - c.Linef("return *ac.Namespace") - c.Linef("}") - -} - -func (c *applyConfigurationMaker) GenerateStructConstructor(root *loader.Package, info *markers.TypeInfo) { - c.Linef("// %sApplyConfiguration represents a declarative configuration of the %s type for use", info.Name, info.Name) - c.Linef("// with apply.") - c.Linef("func %s() *%sApplyConfiguration {", info.Name, info.Name) - c.Linef("return &%sApplyConfiguration{}", info.Name) - c.Linef("}") -} - -func (c *applyConfigurationMaker) GenerateRootStructConstructor(root *loader.Package, info *markers.TypeInfo, clusterScope bool, group, version string) { - c.Linef("// %sApplyConfiguration represents a declarative configuration of the %s type for use", info.Name, info.Name) - c.Linef("// with apply.") - if clusterScope { - c.Linef("func %s(name string) *%sApplyConfiguration {", info.Name, info.Name) - } else { - c.Linef("func %s(name, namespace string) *%sApplyConfiguration {", info.Name, info.Name) - } - c.Linef("ac := &%sApplyConfiguration{}", info.Name) - c.Linef("ac.WithName(name)") - if !clusterScope { - c.Linef("ac.WithNamespace(namespace)") - } - c.Linef("ac.WithKind(\"%s\")", info.Name) - c.Linef("ac.WithAPIVersion(\"%s/%s\")", group, version) - c.Linef("return ac") - c.Linef("}") -} - -func isApplyConfig(t types.Type) bool { - switch typeInfo := t.(type) { - case *types.Named: - return isApplyConfig(typeInfo.Underlying()) - case *types.Struct: - return true - case *types.Pointer: - return isApplyConfig(typeInfo.Elem()) - default: - return false - } -} - -func isList(t types.Type) bool { - switch t.(type) { - case *types.Slice: - return true - default: - return false - } -} - -func isMap(t types.Type) bool { - switch t.(type) { - case *types.Map: - return true - default: - return false - } -} - -func isPointer(t types.Type) bool { - switch t.(type) { - case *types.Pointer: - return true - default: - return false - } -} - -func (c *applyConfigurationMaker) GenerateMemberSet(universe *Universe, field markers.FieldInfo, root *loader.Package, info *markers.TypeInfo) { - fieldType := root.TypesInfo.TypeOf(field.RawField.Type) - fieldNamingInfo := namingInfo{typeInfo: fieldType} - fieldTypeString := fieldNamingInfo.Syntax(universe, root, c.ImportsList) - - c.Linef("// With%s sets the %s field in the declarative configuration to the given value", field.Name, field.Name) - if isApplyConfig(fieldNamingInfo.typeInfo) && !isPointer(fieldNamingInfo.typeInfo) { - fieldTypeString = "*" + fieldTypeString - } - c.Linef("func (b *%sApplyConfiguration) With%s(value %s) *%sApplyConfiguration {", info.Name, field.Name, fieldTypeString, info.Name) - - if tags, ok := lookupJSONTags(field); ok { - if tags.inline { - c.Linef("if value != nil {") - c.Linef("b.%s = *value", field.Name) - c.Linef("}") - } else if isApplyConfig(fieldNamingInfo.typeInfo) { - c.Linef("b.%s = value", field.Name) - } else if isPointer(fieldNamingInfo.typeInfo) { - c.Linef("b.%s = value", field.Name) - } else { - c.Linef("b.%s = &value", field.Name) - } - } - c.Linef("return b") - c.Linef("}") -} - -func (c *applyConfigurationMaker) GenerateMemberSetForSlice(universe *Universe, field markers.FieldInfo, root *loader.Package, info *markers.TypeInfo) { - fieldType := root.TypesInfo.TypeOf(field.RawField.Type) - fieldNamingInfo := namingInfo{typeInfo: fieldType} - - sliceType := fieldType.(*types.Slice) - listVal := (&namingInfo{typeInfo: sliceType.Elem()}).Syntax(universe, root, c.ImportsList) - - c.Linef("// With%s sets the %s field in the declarative configuration to the given value", field.Name, field.Name) - c.Linef("func (b *%sApplyConfiguration) With%s(values ...%s) *%sApplyConfiguration {", info.Name, field.Name, listVal, info.Name) - - c.Linef("for i := range values {") - if isApplyConfig(fieldNamingInfo.typeInfo) || isPointer(fieldNamingInfo.typeInfo) { - c.Linef("if values[i] == nil {") - c.Linef("panic(\"nil value passed to With%s\")", field.Name) - c.Linef("}") - c.Linef("b.%s[1] = append(b.%s[1], values[i]", field.Name) - } - c.Linef("b.%[1]s = append(b.%[1]s, values[i])", field.Name) - c.Linef("}") - c.Linef("return b") - c.Linef("}") -} - -func (c *applyConfigurationMaker) GenerateMemberSetForMap(universe *Universe, field markers.FieldInfo, root *loader.Package, info *markers.TypeInfo) { - fieldType := root.TypesInfo.TypeOf(field.RawField.Type) - fieldNamingInfo := namingInfo{typeInfo: fieldType} - fieldTypeString := fieldNamingInfo.Syntax(universe, root, c.ImportsList) - - mapType := fieldType.(*types.Map) - k := (&namingInfo{typeInfo: mapType.Key()}).Syntax(universe, root, c.ImportsList) - v := (&namingInfo{typeInfo: mapType.Elem()}).Syntax(universe, root, c.ImportsList) - - c.Linef("// With%s sets the %s field in the declarative configuration to the given value", field.Name, field.Name) - if isApplyConfig(fieldNamingInfo.typeInfo) && !isPointer(fieldNamingInfo.typeInfo) { - fieldTypeString = "*" + fieldTypeString - } - c.Linef("func (b *%sApplyConfiguration) With%s(entries %s) *%sApplyConfiguration {", info.Name, field.Name, fieldTypeString, info.Name) - c.Linef("if b.%s == nil && len(entries) > 0 {", field.Name) - c.Linef("b.%s = make(map[%s]%s, len(entries))", field.Name, k, v) - c.Linef("}") - c.Linef("for k, v := range entries {") - c.Linef("b.%s[k] = v", field.Name) - c.Linef("}") - c.Linef("return b") - c.Linef("}") -} - -func (c *applyConfigurationMaker) GenerateListMapAlias(root *loader.Package, info *markers.TypeInfo) { - var listAlias = ` -// %[1]sList represents a listAlias of %[1]sApplyConfiguration. -type %[1]sList []*%[1]sApplyConfiguration -` - var mapAlias = ` -// %[1]sMap represents a map of %[1]sApplyConfiguration. -type %[1]sMap map[string]%[1]sApplyConfiguration -` - - c.Linef(listAlias, info.Name) - c.Linef(mapAlias, info.Name) -} - -// shouldBeApplyConfiguration checks if we're supposed to make apply configurations for the given type. -// -// TODO(jpbetz): Copy over logic for inclusion from requiresApplyConfiguration -func shouldBeApplyConfiguration(pkg *loader.Package, info *markers.TypeInfo) bool { - if !ast.IsExported(info.Name) { - return false - } - - typeInfo := pkg.TypesInfo.TypeOf(info.RawSpec.Name) - if typeInfo == types.Typ[types.Invalid] { - pkg.AddError(loader.ErrFromNode(fmt.Errorf("unknown type: %s", info.Name), info.RawSpec)) - return false - } - - // according to gengo, everything named is an alias, except for an alias to a pointer, - // which is just a pointer, afaict. Just roll with it. - if asPtr, isPtr := typeInfo.(*types.Named).Underlying().(*types.Pointer); isPtr { - typeInfo = asPtr - } - - lastType := typeInfo - if _, isNamed := typeInfo.(*types.Named); isNamed { - for underlyingType := typeInfo.Underlying(); underlyingType != lastType; lastType, underlyingType = underlyingType, underlyingType.Underlying() { - } - } - - // structs are the only thing that's not a basic that apply configurations are generated for - _, isStruct := lastType.(*types.Struct) - if !isStruct { - return false - } - if _, ok := excludeTypes[info.Name]; ok { // TODO(jpbetz): What to do here? - return false - } - var hasJSONTaggedMembers bool - for _, field := range info.Fields { - if _, ok := lookupJSONTags(field); ok { - hasJSONTaggedMembers = true - } - } - return hasJSONTaggedMembers -} - -var ( - rawExtension = "k8s.io/apimachinery/pkg/runtime/RawExtension" - unknown = "k8s.io/apimachinery/pkg/runtime/Unknown" -) - -// excludeTypes contains well known types that we do not generate apply configurations for. -// Hard coding because we only have two, very specific types that serve a special purpose -// in the type system here. -var excludeTypes = map[string]struct{}{ - rawExtension: {}, - unknown: {}, - // DO NOT ADD TO THIS LIST. If we need to exclude other types, we should consider allowing the - // go type declarations to be annotated as excluded from this generator. -} From 2711c92e75756c72a4c5aa3f2e21079d2401447f Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Tue, 24 Jan 2023 17:16:27 +0000 Subject: [PATCH 06/22] Convert controller-tools tags to genclient --- pkg/applyconfigurations/gen.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/pkg/applyconfigurations/gen.go b/pkg/applyconfigurations/gen.go index 6356663b1..d51bd3a0f 100644 --- a/pkg/applyconfigurations/gen.go +++ b/pkg/applyconfigurations/gen.go @@ -24,6 +24,7 @@ import ( "path/filepath" "strings" + "k8s.io/apimachinery/pkg/util/sets" generatorargs "k8s.io/code-generator/cmd/applyconfiguration-gen/args" applygenerator "k8s.io/code-generator/cmd/applyconfiguration-gen/generators" "k8s.io/gengo/generator" @@ -219,6 +220,33 @@ func (ctx *ObjectGenCtx) generateForPackage(root *loader.Package) error { return err } + pkg, ok := c.Universe[root.PkgPath] + if !ok { + return fmt.Errorf("package %q not found in universe", root.Name) + } + + // For each type we think should be generated, make sure it has a genclient + // marker else the apply generator will not generate it. + if err := markers.EachType(ctx.Collector, root, func(info *markers.TypeInfo) { + if !enabledOnType(info) { + return + } + + typ, ok := pkg.Types[info.Name] + if !ok { + return + } + + comments := sets.NewString(typ.CommentLines...) + comments.Insert(typ.SecondClosestCommentLines...) + + if !comments.Has("// +genclient") { + typ.CommentLines = append(typ.CommentLines, "+genclient") + } + }); err != nil { + return err + } + packages := applygenerator.Packages(c, genericArgs) if err := c.ExecutePackages(genericArgs.OutputBase, packages); err != nil { return fmt.Errorf("error executing packages: %w", err) From ba99f7a3d76dc806f92805d6c7670f415c0374de Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Tue, 24 Jan 2023 17:17:37 +0000 Subject: [PATCH 07/22] Add generated clients --- .../ac/zz_generated.applyconfigurations.go | 331 ------------------ .../applyconfiguration/internal/internal.go | 46 +++ .../testdata/cronjob/associativetype.go | 41 +++ .../testdata/cronjob/cronjob.go | 203 +++++++++++ .../testdata/cronjob/cronjobspec.go | 204 +++++++++++ .../testdata/cronjob/cronjobstatus.go | 48 +++ .../testdata/cronjob/examplestruct.go | 23 ++ .../cronjob/applyconfiguration/utils.go | 29 ++ 8 files changed, 594 insertions(+), 331 deletions(-) delete mode 100644 pkg/applyconfigurations/testdata/cronjob/ac/zz_generated.applyconfigurations.go create mode 100644 pkg/applyconfigurations/testdata/cronjob/applyconfiguration/internal/internal.go create mode 100644 pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/associativetype.go create mode 100644 pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjob.go create mode 100644 pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go create mode 100644 pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go create mode 100644 pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go create mode 100644 pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go diff --git a/pkg/applyconfigurations/testdata/cronjob/ac/zz_generated.applyconfigurations.go b/pkg/applyconfigurations/testdata/cronjob/ac/zz_generated.applyconfigurations.go deleted file mode 100644 index 1d6133a79..000000000 --- a/pkg/applyconfigurations/testdata/cronjob/ac/zz_generated.applyconfigurations.go +++ /dev/null @@ -1,331 +0,0 @@ -//go:build !ignore_autogenerated -// +build !ignore_autogenerated - -/* -Copyright 2022 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by controller-gen. DO NOT EDIT. - -package testdata - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - v1beta1 "k8s.io/client-go/applyconfigurations/batch/v1beta1" - v1 "k8s.io/client-go/applyconfigurations/core/v1" - applyconfigurationsmetav1 "k8s.io/client-go/applyconfigurations/meta/v1" - cronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob" -) - -// AssociativeTypeApplyConfiguration represents a declarative configuration of the AssociativeType type for use -// with apply. -type AssociativeTypeApplyConfiguration struct { - Name *string `json:"name,omitempty"` - Secondary *int `json:"secondary,omitempty"` - Foo *string `json:"foo,omitempty"` -} - -// WithName sets the Name field in the declarative configuration to the given value -func (b *AssociativeTypeApplyConfiguration) WithName(value string) *AssociativeTypeApplyConfiguration { - b.Name = &value - return b -} - -// WithSecondary sets the Secondary field in the declarative configuration to the given value -func (b *AssociativeTypeApplyConfiguration) WithSecondary(value int) *AssociativeTypeApplyConfiguration { - b.Secondary = &value - return b -} - -// WithFoo sets the Foo field in the declarative configuration to the given value -func (b *AssociativeTypeApplyConfiguration) WithFoo(value string) *AssociativeTypeApplyConfiguration { - b.Foo = &value - return b -} - -// AssociativeTypeApplyConfiguration represents a declarative configuration of the AssociativeType type for use -// with apply. -func AssociativeType() *AssociativeTypeApplyConfiguration { - return &AssociativeTypeApplyConfiguration{} -} - -// CronJobApplyConfiguration represents a declarative configuration of the CronJob type for use -// with apply. -type CronJobApplyConfiguration struct { - applyconfigurationsmetav1.TypeMetaApplyConfiguration `json:",inline"` - *applyconfigurationsmetav1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` - Spec *CronJobSpecApplyConfiguration `json:"spec,omitempty"` - Status *CronJobStatusApplyConfiguration `json:"status,omitempty"` -} - -// WithSpec sets the Spec field in the declarative configuration to the given value -func (b *CronJobApplyConfiguration) WithSpec(value *CronJobSpecApplyConfiguration) *CronJobApplyConfiguration { - b.Spec = value - return b -} - -// WithStatus sets the Status field in the declarative configuration to the given value -func (b *CronJobApplyConfiguration) WithStatus(value *CronJobStatusApplyConfiguration) *CronJobApplyConfiguration { - b.Status = value - return b -} - -// CronJobApplyConfiguration represents a declarative configuration of the CronJob type for use -// with apply. -func CronJob(name, namespace string) *CronJobApplyConfiguration { - ac := &CronJobApplyConfiguration{} - ac.WithName(name) - ac.WithNamespace(namespace) - ac.WithKind("CronJob") - ac.WithAPIVersion("testdata.kubebuilder.io/v1") - return ac -} -func (ac *CronJobApplyConfiguration) WithKind(value string) *CronJobApplyConfiguration { - ac.Kind = &value - return ac -} -func (ac *CronJobApplyConfiguration) WithAPIVersion(value string) *CronJobApplyConfiguration { - ac.APIVersion = &value - return ac -} -func (ac *CronJobApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { - if ac.ObjectMetaApplyConfiguration == nil { - ac.ObjectMetaApplyConfiguration = &applyconfigurationsmetav1.ObjectMetaApplyConfiguration{} - } -} -func (ac *CronJobApplyConfiguration) WithName(value string) *CronJobApplyConfiguration { - ac.ensureObjectMetaApplyConfigurationExists() - ac.Name = &value - return ac -} -func (ac *CronJobApplyConfiguration) WithNamespace(value string) *CronJobApplyConfiguration { - ac.Namespace = &value - return ac -} -func (ac *CronJobApplyConfiguration) GetName() string { - ac.ensureObjectMetaApplyConfigurationExists() - return *ac.Name -} -func (ac *CronJobApplyConfiguration) GetNamespace() string { - ac.ensureObjectMetaApplyConfigurationExists() - return *ac.Namespace -} - -// CronJobSpecApplyConfiguration represents a declarative configuration of the CronJobSpec type for use -// with apply. -type CronJobSpecApplyConfiguration struct { - Schedule *string `json:"schedule,omitempty"` - StartingDeadlineSeconds *int64 `json:"startingDeadlineSeconds,omitempty"` - ConcurrencyPolicy *cronjob.ConcurrencyPolicy `json:"concurrencyPolicy,omitempty"` - Suspend *bool `json:"suspend,omitempty"` - BinaryName []byte `json:"binaryName,omitempty"` - CanBeNull *string `json:"canBeNull,omitempty"` - JobTemplate *v1beta1.JobTemplateSpecApplyConfiguration `json:"jobTemplate,omitempty"` - SuccessfulJobsHistoryLimit *int32 `json:"successfulJobsHistoryLimit,omitempty"` - FailedJobsHistoryLimit *int32 `json:"failedJobsHistoryLimit,omitempty"` - StringSliceData map[string][]string `json:"stringSliceData,omitempty"` - PtrData map[string]*string `json:"ptrData,omitempty"` - Slice []string `json:"slice,omitempty"` - SlicePtr []*string `json:"slicePtr,omitempty"` - SliceStruct []*ExampleStructApplyConfiguration `json:"sliceStruct,omitempty"` - BuiltInReference *v1.PodSpecApplyConfiguration `json:"builtInReference,omitempty"` - Int *int `json:"int,omitempty"` - AssociativeList []AssociativeTypeApplyConfiguration `json:"associativeList,omitempty"` -} - -// WithSchedule sets the Schedule field in the declarative configuration to the given value -func (b *CronJobSpecApplyConfiguration) WithSchedule(value string) *CronJobSpecApplyConfiguration { - b.Schedule = &value - return b -} - -// WithStartingDeadlineSeconds sets the StartingDeadlineSeconds field in the declarative configuration to the given value -func (b *CronJobSpecApplyConfiguration) WithStartingDeadlineSeconds(value *int64) *CronJobSpecApplyConfiguration { - b.StartingDeadlineSeconds = value - return b -} - -// WithConcurrencyPolicy sets the ConcurrencyPolicy field in the declarative configuration to the given value -func (b *CronJobSpecApplyConfiguration) WithConcurrencyPolicy(value cronjob.ConcurrencyPolicy) *CronJobSpecApplyConfiguration { - b.ConcurrencyPolicy = &value - return b -} - -// WithSuspend sets the Suspend field in the declarative configuration to the given value -func (b *CronJobSpecApplyConfiguration) WithSuspend(value *bool) *CronJobSpecApplyConfiguration { - b.Suspend = value - return b -} - -// WithInternalData sets the InternalData field in the declarative configuration to the given value -func (b *CronJobSpecApplyConfiguration) WithInternalData(value string) *CronJobSpecApplyConfiguration { - return b -} - -// WithBinaryName sets the BinaryName field in the declarative configuration to the given value -func (b *CronJobSpecApplyConfiguration) WithBinaryName(values ...byte) *CronJobSpecApplyConfiguration { - for i := range values { - b.BinaryName = append(b.BinaryName, values[i]) - } - return b -} - -// WithCanBeNull sets the CanBeNull field in the declarative configuration to the given value -func (b *CronJobSpecApplyConfiguration) WithCanBeNull(value string) *CronJobSpecApplyConfiguration { - b.CanBeNull = &value - return b -} - -// WithJobTemplate sets the JobTemplate field in the declarative configuration to the given value -func (b *CronJobSpecApplyConfiguration) WithJobTemplate(value *v1beta1.JobTemplateSpecApplyConfiguration) *CronJobSpecApplyConfiguration { - b.JobTemplate = value - return b -} - -// WithSuccessfulJobsHistoryLimit sets the SuccessfulJobsHistoryLimit field in the declarative configuration to the given value -func (b *CronJobSpecApplyConfiguration) WithSuccessfulJobsHistoryLimit(value *int32) *CronJobSpecApplyConfiguration { - b.SuccessfulJobsHistoryLimit = value - return b -} - -// WithFailedJobsHistoryLimit sets the FailedJobsHistoryLimit field in the declarative configuration to the given value -func (b *CronJobSpecApplyConfiguration) WithFailedJobsHistoryLimit(value *int32) *CronJobSpecApplyConfiguration { - b.FailedJobsHistoryLimit = value - return b -} - -// WithStringSliceData sets the StringSliceData field in the declarative configuration to the given value -func (b *CronJobSpecApplyConfiguration) WithStringSliceData(entries map[string][]string) *CronJobSpecApplyConfiguration { - if b.StringSliceData == nil && len(entries) > 0 { - b.StringSliceData = make(map[string][]string, len(entries)) - } - for k, v := range entries { - b.StringSliceData[k] = v - } - return b -} - -// WithPtrData sets the PtrData field in the declarative configuration to the given value -func (b *CronJobSpecApplyConfiguration) WithPtrData(entries map[string]*string) *CronJobSpecApplyConfiguration { - if b.PtrData == nil && len(entries) > 0 { - b.PtrData = make(map[string]*string, len(entries)) - } - for k, v := range entries { - b.PtrData[k] = v - } - return b -} - -// WithSlice sets the Slice field in the declarative configuration to the given value -func (b *CronJobSpecApplyConfiguration) WithSlice(values ...string) *CronJobSpecApplyConfiguration { - for i := range values { - b.Slice = append(b.Slice, values[i]) - } - return b -} - -// WithSlicePtr sets the SlicePtr field in the declarative configuration to the given value -func (b *CronJobSpecApplyConfiguration) WithSlicePtr(values ...*string) *CronJobSpecApplyConfiguration { - for i := range values { - b.SlicePtr = append(b.SlicePtr, values[i]) - } - return b -} - -// WithSliceStruct sets the SliceStruct field in the declarative configuration to the given value -func (b *CronJobSpecApplyConfiguration) WithSliceStruct(values ...*ExampleStructApplyConfiguration) *CronJobSpecApplyConfiguration { - for i := range values { - b.SliceStruct = append(b.SliceStruct, values[i]) - } - return b -} - -// WithBuiltInReference sets the BuiltInReference field in the declarative configuration to the given value -func (b *CronJobSpecApplyConfiguration) WithBuiltInReference(value *v1.PodSpecApplyConfiguration) *CronJobSpecApplyConfiguration { - b.BuiltInReference = value - return b -} - -// WithInt sets the Int field in the declarative configuration to the given value -func (b *CronJobSpecApplyConfiguration) WithInt(value int) *CronJobSpecApplyConfiguration { - b.Int = &value - return b -} - -// WithAssociativeList sets the AssociativeList field in the declarative configuration to the given value -func (b *CronJobSpecApplyConfiguration) WithAssociativeList(values ...AssociativeTypeApplyConfiguration) *CronJobSpecApplyConfiguration { - for i := range values { - b.AssociativeList = append(b.AssociativeList, values[i]) - } - return b -} - -// CronJobSpecApplyConfiguration represents a declarative configuration of the CronJobSpec type for use -// with apply. -func CronJobSpec() *CronJobSpecApplyConfiguration { - return &CronJobSpecApplyConfiguration{} -} - -// CronJobStatusApplyConfiguration represents a declarative configuration of the CronJobStatus type for use -// with apply. -type CronJobStatusApplyConfiguration struct { - Active []v1.ObjectReferenceApplyConfiguration `json:"active,omitempty"` - LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty"` - LastScheduleMicroTime *metav1.MicroTime `json:"lastScheduleMicroTime,omitempty"` -} - -// WithActive sets the Active field in the declarative configuration to the given value -func (b *CronJobStatusApplyConfiguration) WithActive(values ...v1.ObjectReferenceApplyConfiguration) *CronJobStatusApplyConfiguration { - for i := range values { - b.Active = append(b.Active, values[i]) - } - return b -} - -// WithLastScheduleTime sets the LastScheduleTime field in the declarative configuration to the given value -func (b *CronJobStatusApplyConfiguration) WithLastScheduleTime(value *metav1.Time) *CronJobStatusApplyConfiguration { - b.LastScheduleTime = value - return b -} - -// WithLastScheduleMicroTime sets the LastScheduleMicroTime field in the declarative configuration to the given value -func (b *CronJobStatusApplyConfiguration) WithLastScheduleMicroTime(value *metav1.MicroTime) *CronJobStatusApplyConfiguration { - b.LastScheduleMicroTime = value - return b -} - -// CronJobStatusApplyConfiguration represents a declarative configuration of the CronJobStatus type for use -// with apply. -func CronJobStatus() *CronJobStatusApplyConfiguration { - return &CronJobStatusApplyConfiguration{} -} - -// ExampleStructApplyConfiguration represents a declarative configuration of the ExampleStruct type for use -// with apply. -type ExampleStructApplyConfiguration struct { - ExampleField *string `json:"string,omitempty"` -} - -// WithExampleField sets the ExampleField field in the declarative configuration to the given value -func (b *ExampleStructApplyConfiguration) WithExampleField(value string) *ExampleStructApplyConfiguration { - b.ExampleField = &value - return b -} - -// ExampleStructApplyConfiguration represents a declarative configuration of the ExampleStruct type for use -// with apply. -func ExampleStruct() *ExampleStructApplyConfiguration { - return &ExampleStructApplyConfiguration{} -} diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/internal/internal.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/internal/internal.go new file mode 100644 index 000000000..c121b9b3f --- /dev/null +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/internal/internal.go @@ -0,0 +1,46 @@ +// Code generated by controller-gen. DO NOT EDIT. + +package internal + +import ( + "fmt" + "sync" + + typed "sigs.k8s.io/structured-merge-diff/v4/typed" +) + +func Parser() *typed.Parser { + parserOnce.Do(func() { + var err error + parser, err = typed.NewParser(schemaYAML) + if err != nil { + panic(fmt.Sprintf("Failed to parse schema: %v", err)) + } + }) + return parser +} + +var parserOnce sync.Once +var parser *typed.Parser +var schemaYAML = typed.YAMLObject(`types: +- name: __untyped_atomic_ + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic +- name: __untyped_deduced_ + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +`) diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/associativetype.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/associativetype.go new file mode 100644 index 000000000..fe677b8ca --- /dev/null +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/associativetype.go @@ -0,0 +1,41 @@ +// Code generated by controller-gen. DO NOT EDIT. + +package cronjob + +// AssociativeTypeApplyConfiguration represents an declarative configuration of the AssociativeType type for use +// with apply. +type AssociativeTypeApplyConfiguration struct { + Name *string `json:"name,omitempty"` + Secondary *int `json:"secondary,omitempty"` + Foo *string `json:"foo,omitempty"` +} + +// AssociativeTypeApplyConfiguration constructs an declarative configuration of the AssociativeType type for use with +// apply. +func AssociativeType() *AssociativeTypeApplyConfiguration { + return &AssociativeTypeApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *AssociativeTypeApplyConfiguration) WithName(value string) *AssociativeTypeApplyConfiguration { + b.Name = &value + return b +} + +// WithSecondary sets the Secondary field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Secondary field is set to the value of the last call. +func (b *AssociativeTypeApplyConfiguration) WithSecondary(value int) *AssociativeTypeApplyConfiguration { + b.Secondary = &value + return b +} + +// WithFoo sets the Foo field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Foo field is set to the value of the last call. +func (b *AssociativeTypeApplyConfiguration) WithFoo(value string) *AssociativeTypeApplyConfiguration { + b.Foo = &value + return b +} diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjob.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjob.go new file mode 100644 index 000000000..257677ede --- /dev/null +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjob.go @@ -0,0 +1,203 @@ +// Code generated by controller-gen. DO NOT EDIT. + +package cronjob + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// CronJobApplyConfiguration represents an declarative configuration of the CronJob type for use +// with apply. +type CronJobApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *CronJobSpecApplyConfiguration `json:"spec,omitempty"` + Status *CronJobStatusApplyConfiguration `json:"status,omitempty"` +} + +// CronJob constructs an declarative configuration of the CronJob type for use with +// apply. +func CronJob(name, namespace string) *CronJobApplyConfiguration { + b := &CronJobApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("CronJob") + b.WithAPIVersion("testdata/cronjob") + return b +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithKind(value string) *CronJobApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithAPIVersion(value string) *CronJobApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithName(value string) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithGenerateName(value string) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithNamespace(value string) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithUID(value types.UID) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithResourceVersion(value string) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithGeneration(value int64) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithCreationTimestamp(value metav1.Time) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *CronJobApplyConfiguration) WithLabels(entries map[string]string) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *CronJobApplyConfiguration) WithAnnotations(entries map[string]string) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *CronJobApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *CronJobApplyConfiguration) WithFinalizers(values ...string) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *CronJobApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithSpec(value *CronJobSpecApplyConfiguration) *CronJobApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithStatus(value *CronJobStatusApplyConfiguration) *CronJobApplyConfiguration { + b.Status = value + return b +} diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go new file mode 100644 index 000000000..43720b7a4 --- /dev/null +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go @@ -0,0 +1,204 @@ +// Code generated by controller-gen. DO NOT EDIT. + +package cronjob + +import ( + v1beta1 "k8s.io/api/batch/v1beta1" + v1 "k8s.io/api/core/v1" + cronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob" +) + +// CronJobSpecApplyConfiguration represents an declarative configuration of the CronJobSpec type for use +// with apply. +type CronJobSpecApplyConfiguration struct { + Schedule *string `json:"schedule,omitempty"` + StartingDeadlineSeconds *int64 `json:"startingDeadlineSeconds,omitempty"` + ConcurrencyPolicy *cronjob.ConcurrencyPolicy `json:"concurrencyPolicy,omitempty"` + Suspend *bool `json:"suspend,omitempty"` + BinaryName []byte `json:"binaryName,omitempty"` + CanBeNull *string `json:"canBeNull,omitempty"` + JobTemplate *v1beta1.JobTemplateSpec `json:"jobTemplate,omitempty"` + SuccessfulJobsHistoryLimit *int32 `json:"successfulJobsHistoryLimit,omitempty"` + FailedJobsHistoryLimit *int32 `json:"failedJobsHistoryLimit,omitempty"` + StringSliceData map[string][]string `json:"stringSliceData,omitempty"` + PtrData map[string]*string `json:"ptrData,omitempty"` + Slice []string `json:"slice,omitempty"` + SlicePtr []*string `json:"slicePtr,omitempty"` + SliceStruct []*cronjob.ExampleStruct `json:"sliceStruct,omitempty"` + BuiltInReference *v1.PodSpec `json:"builtInReference,omitempty"` + Int *int `json:"int,omitempty"` + AssociativeList []AssociativeTypeApplyConfiguration `json:"associativeList,omitempty"` +} + +// CronJobSpecApplyConfiguration constructs an declarative configuration of the CronJobSpec type for use with +// apply. +func CronJobSpec() *CronJobSpecApplyConfiguration { + return &CronJobSpecApplyConfiguration{} +} + +// WithSchedule sets the Schedule field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Schedule field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithSchedule(value string) *CronJobSpecApplyConfiguration { + b.Schedule = &value + return b +} + +// WithStartingDeadlineSeconds sets the StartingDeadlineSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the StartingDeadlineSeconds field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithStartingDeadlineSeconds(value int64) *CronJobSpecApplyConfiguration { + b.StartingDeadlineSeconds = &value + return b +} + +// WithConcurrencyPolicy sets the ConcurrencyPolicy field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ConcurrencyPolicy field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithConcurrencyPolicy(value cronjob.ConcurrencyPolicy) *CronJobSpecApplyConfiguration { + b.ConcurrencyPolicy = &value + return b +} + +// WithSuspend sets the Suspend field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Suspend field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithSuspend(value bool) *CronJobSpecApplyConfiguration { + b.Suspend = &value + return b +} + +// WithBinaryName adds the given value to the BinaryName field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the BinaryName field. +func (b *CronJobSpecApplyConfiguration) WithBinaryName(values ...byte) *CronJobSpecApplyConfiguration { + for i := range values { + b.BinaryName = append(b.BinaryName, values[i]) + } + return b +} + +// WithCanBeNull sets the CanBeNull field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CanBeNull field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithCanBeNull(value string) *CronJobSpecApplyConfiguration { + b.CanBeNull = &value + return b +} + +// WithJobTemplate sets the JobTemplate field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the JobTemplate field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithJobTemplate(value v1beta1.JobTemplateSpec) *CronJobSpecApplyConfiguration { + b.JobTemplate = &value + return b +} + +// WithSuccessfulJobsHistoryLimit sets the SuccessfulJobsHistoryLimit field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the SuccessfulJobsHistoryLimit field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithSuccessfulJobsHistoryLimit(value int32) *CronJobSpecApplyConfiguration { + b.SuccessfulJobsHistoryLimit = &value + return b +} + +// WithFailedJobsHistoryLimit sets the FailedJobsHistoryLimit field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the FailedJobsHistoryLimit field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithFailedJobsHistoryLimit(value int32) *CronJobSpecApplyConfiguration { + b.FailedJobsHistoryLimit = &value + return b +} + +// WithStringSliceData puts the entries into the StringSliceData field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the StringSliceData field, +// overwriting an existing map entries in StringSliceData field with the same key. +func (b *CronJobSpecApplyConfiguration) WithStringSliceData(entries map[string][]string) *CronJobSpecApplyConfiguration { + if b.StringSliceData == nil && len(entries) > 0 { + b.StringSliceData = make(map[string][]string, len(entries)) + } + for k, v := range entries { + b.StringSliceData[k] = v + } + return b +} + +// WithPtrData puts the entries into the PtrData field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the PtrData field, +// overwriting an existing map entries in PtrData field with the same key. +func (b *CronJobSpecApplyConfiguration) WithPtrData(entries map[string]*string) *CronJobSpecApplyConfiguration { + if b.PtrData == nil && len(entries) > 0 { + b.PtrData = make(map[string]*string, len(entries)) + } + for k, v := range entries { + b.PtrData[k] = v + } + return b +} + +// WithSlice adds the given value to the Slice field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Slice field. +func (b *CronJobSpecApplyConfiguration) WithSlice(values ...string) *CronJobSpecApplyConfiguration { + for i := range values { + b.Slice = append(b.Slice, values[i]) + } + return b +} + +// WithSlicePtr adds the given value to the SlicePtr field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the SlicePtr field. +func (b *CronJobSpecApplyConfiguration) WithSlicePtr(values ...*string) *CronJobSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithSlicePtr") + } + b.SlicePtr = append(b.SlicePtr, *values[i]) + } + return b +} + +// WithSliceStruct adds the given value to the SliceStruct field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the SliceStruct field. +func (b *CronJobSpecApplyConfiguration) WithSliceStruct(values ...**cronjob.ExampleStruct) *CronJobSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithSliceStruct") + } + b.SliceStruct = append(b.SliceStruct, *values[i]) + } + return b +} + +// WithBuiltInReference sets the BuiltInReference field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the BuiltInReference field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithBuiltInReference(value v1.PodSpec) *CronJobSpecApplyConfiguration { + b.BuiltInReference = &value + return b +} + +// WithInt sets the Int field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Int field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithInt(value int) *CronJobSpecApplyConfiguration { + b.Int = &value + return b +} + +// WithAssociativeList adds the given value to the AssociativeList field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the AssociativeList field. +func (b *CronJobSpecApplyConfiguration) WithAssociativeList(values ...*AssociativeTypeApplyConfiguration) *CronJobSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithAssociativeList") + } + b.AssociativeList = append(b.AssociativeList, *values[i]) + } + return b +} diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go new file mode 100644 index 000000000..738e0927f --- /dev/null +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go @@ -0,0 +1,48 @@ +// Code generated by controller-gen. DO NOT EDIT. + +package cronjob + +import ( + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// CronJobStatusApplyConfiguration represents an declarative configuration of the CronJobStatus type for use +// with apply. +type CronJobStatusApplyConfiguration struct { + Active []v1.ObjectReference `json:"active,omitempty"` + LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty"` + LastScheduleMicroTime *metav1.MicroTime `json:"lastScheduleMicroTime,omitempty"` +} + +// CronJobStatusApplyConfiguration constructs an declarative configuration of the CronJobStatus type for use with +// apply. +func CronJobStatus() *CronJobStatusApplyConfiguration { + return &CronJobStatusApplyConfiguration{} +} + +// WithActive adds the given value to the Active field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Active field. +func (b *CronJobStatusApplyConfiguration) WithActive(values ...v1.ObjectReference) *CronJobStatusApplyConfiguration { + for i := range values { + b.Active = append(b.Active, values[i]) + } + return b +} + +// WithLastScheduleTime sets the LastScheduleTime field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LastScheduleTime field is set to the value of the last call. +func (b *CronJobStatusApplyConfiguration) WithLastScheduleTime(value metav1.Time) *CronJobStatusApplyConfiguration { + b.LastScheduleTime = &value + return b +} + +// WithLastScheduleMicroTime sets the LastScheduleMicroTime field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LastScheduleMicroTime field is set to the value of the last call. +func (b *CronJobStatusApplyConfiguration) WithLastScheduleMicroTime(value metav1.MicroTime) *CronJobStatusApplyConfiguration { + b.LastScheduleMicroTime = &value + return b +} diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go new file mode 100644 index 000000000..9b0dad9bd --- /dev/null +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go @@ -0,0 +1,23 @@ +// Code generated by controller-gen. DO NOT EDIT. + +package cronjob + +// ExampleStructApplyConfiguration represents an declarative configuration of the ExampleStruct type for use +// with apply. +type ExampleStructApplyConfiguration struct { + ExampleField *string `json:"string,omitempty"` +} + +// ExampleStructApplyConfiguration constructs an declarative configuration of the ExampleStruct type for use with +// apply. +func ExampleStruct() *ExampleStructApplyConfiguration { + return &ExampleStructApplyConfiguration{} +} + +// WithExampleField sets the ExampleField field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ExampleField field is set to the value of the last call. +func (b *ExampleStructApplyConfiguration) WithExampleField(value string) *ExampleStructApplyConfiguration { + b.ExampleField = &value + return b +} diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go new file mode 100644 index 000000000..9ae8d1b49 --- /dev/null +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go @@ -0,0 +1,29 @@ +// Code generated by controller-gen. DO NOT EDIT. + +package applyconfiguration + +import ( + schema "k8s.io/apimachinery/pkg/runtime/schema" + cronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob" + testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob" +) + +// ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no +// apply configuration type exists for the given GroupVersionKind. +func ForKind(kind schema.GroupVersionKind) interface{} { + switch kind { + // Group=testdata, Version=cronjob + case cronjob.SchemeGroupVersion.WithKind("AssociativeType"): + return &testdatacronjob.AssociativeTypeApplyConfiguration{} + case cronjob.SchemeGroupVersion.WithKind("CronJob"): + return &testdatacronjob.CronJobApplyConfiguration{} + case cronjob.SchemeGroupVersion.WithKind("CronJobSpec"): + return &testdatacronjob.CronJobSpecApplyConfiguration{} + case cronjob.SchemeGroupVersion.WithKind("CronJobStatus"): + return &testdatacronjob.CronJobStatusApplyConfiguration{} + case cronjob.SchemeGroupVersion.WithKind("ExampleStruct"): + return &testdatacronjob.ExampleStructApplyConfiguration{} + + } + return nil +} From d93d1cbf4e22666f9f0719fe2258415d8d6e96c4 Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Fri, 19 May 2023 10:38:05 +0100 Subject: [PATCH 08/22] Cleanup markers, ensure correct path for non GOPATH --- pkg/applyconfigurations/gen.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/pkg/applyconfigurations/gen.go b/pkg/applyconfigurations/gen.go index d51bd3a0f..4166420af 100644 --- a/pkg/applyconfigurations/gen.go +++ b/pkg/applyconfigurations/gen.go @@ -37,11 +37,9 @@ import ( // Based on deepcopy gen but with legacy marker support removed. var ( - groupNameMarker = markers.Must(markers.MakeDefinition("groupName", markers.DescribesPackage, "")) - versionNameMarker = markers.Must(markers.MakeDefinition("versionName", markers.DescribesPackage, "")) - isCRDMarker = markers.Must(markers.MakeDefinition("kubebuilder:resource", markers.DescribesType, crdmarkers.Resource{})) - enablePkgMarker = markers.Must(markers.MakeDefinition("kubebuilder:ac:generate", markers.DescribesPackage, false)) - enableTypeMarker = markers.Must(markers.MakeDefinition("kubebuilder:ac:generate", markers.DescribesType, false)) + isCRDMarker = markers.Must(markers.MakeDefinition("kubebuilder:resource", markers.DescribesType, crdmarkers.Resource{})) + enablePkgMarker = markers.Must(markers.MakeDefinition("kubebuilder:ac:generate", markers.DescribesPackage, false)) + enableTypeMarker = markers.Must(markers.MakeDefinition("kubebuilder:ac:generate", markers.DescribesType, false)) ) var importMapping = map[string]string{ @@ -69,14 +67,10 @@ func (Generator) CheckFilter() loader.NodeFilter { func (Generator) RegisterMarkers(into *markers.Registry) error { if err := markers.RegisterAll(into, - groupNameMarker, versionNameMarker, isCRDMarker, enablePkgMarker, enableTypeMarker); err != nil { + isCRDMarker, enablePkgMarker, enableTypeMarker); err != nil { return err } - into.AddHelp(groupNameMarker, - markers.SimpleHelp("apply", "specifies the API group name for this package.")) - into.AddHelp(versionNameMarker, - markers.SimpleHelp("apply", "overrides the API group version for this package (defaults to the package name).")) into.AddHelp(isCRDMarker, markers.SimpleHelp("apply", "enables apply configuration generation for this type")) into.AddHelp( @@ -220,6 +214,9 @@ func (ctx *ObjectGenCtx) generateForPackage(root *loader.Package) error { return err } + // This allows the correct output location when GOPATH is unset. + c.TrimPathPrefix = root.PkgPath + "/" + pkg, ok := c.Universe[root.PkgPath] if !ok { return fmt.Errorf("package %q not found in universe", root.Name) From 0a5f81a14ede5fe8420a39b1a2384e02b3ccb036 Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Fri, 19 May 2023 16:38:00 +0100 Subject: [PATCH 09/22] Add test to check generated content against generated master --- .../applyconfiguration_integration_test.go | 144 +++++++++++++ .../applyconfiguration_suite_test.go | 29 +++ pkg/applyconfigurations/gen.go | 3 + .../internal/internal.go | 46 ++++ .../testdata/cronjob/associativetype.go | 41 ++++ .../testdata/cronjob/cronjob.go | 203 +++++++++++++++++ .../testdata/cronjob/cronjobspec.go | 204 ++++++++++++++++++ .../testdata/cronjob/cronjobstatus.go | 48 +++++ .../testdata/cronjob/examplestruct.go | 23 ++ .../applyconfiguration-master/utils.go | 29 +++ .../applyconfiguration/internal/internal.go | 2 +- .../testdata/cronjob/associativetype.go | 2 +- .../testdata/cronjob/cronjob.go | 2 +- .../testdata/cronjob/cronjobspec.go | 2 +- .../testdata/cronjob/cronjobstatus.go | 2 +- .../testdata/cronjob/examplestruct.go | 2 +- .../cronjob/applyconfiguration/utils.go | 2 +- 17 files changed, 777 insertions(+), 7 deletions(-) create mode 100644 pkg/applyconfigurations/applyconfiguration_integration_test.go create mode 100644 pkg/applyconfigurations/applyconfiguration_suite_test.go create mode 100644 pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/internal/internal.go create mode 100644 pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/associativetype.go create mode 100644 pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/cronjob.go create mode 100644 pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/cronjobspec.go create mode 100644 pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/cronjobstatus.go create mode 100644 pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/examplestruct.go create mode 100644 pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/utils.go diff --git a/pkg/applyconfigurations/applyconfiguration_integration_test.go b/pkg/applyconfigurations/applyconfiguration_integration_test.go new file mode 100644 index 000000000..3c8696143 --- /dev/null +++ b/pkg/applyconfigurations/applyconfiguration_integration_test.go @@ -0,0 +1,144 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package applyconfigurations + +import ( + "fmt" + "io" + "io/fs" + "os" + "strings" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "k8s.io/apimachinery/pkg/util/sets" + + "sigs.k8s.io/controller-tools/pkg/crd" + "sigs.k8s.io/controller-tools/pkg/genall" + "sigs.k8s.io/controller-tools/pkg/loader" + "sigs.k8s.io/controller-tools/pkg/markers" +) + +type outputToMap map[string]*outputFile + +// Open implements genall.OutputRule. +func (m outputToMap) Open(_ *loader.Package, path string) (io.WriteCloser, error) { + if _, ok := m[path]; !ok { + m[path] = &outputFile{} + } + return m[path], nil +} + +type outputFile struct { + contents []byte +} + +func (o *outputFile) Write(p []byte) (int, error) { + o.contents = append(o.contents, p...) + return len(p), nil +} + +func (o *outputFile) Close() error { + return nil +} + +var _ = Describe("ApplyConfiguration generation from API types", func() { + It("should be able to verify generated ApplyConfiguration types for the CronJob schema", func() { + By("switching into testdata to appease go modules") + cwd, err := os.Getwd() + Expect(err).NotTo(HaveOccurred()) + Expect(os.Chdir("./testdata/cronjob")).To(Succeed()) // go modules are directory-sensitive + defer func() { Expect(os.Chdir(cwd)).To(Succeed()) }() + + output := make(outputToMap) + + By("initializing the runtime") + optionsRegistry := &markers.Registry{} + Expect(optionsRegistry.Register(markers.Must(markers.MakeDefinition("crd", markers.DescribesPackage, crd.Generator{})))).To(Succeed()) + // Add the applyconfigurations generator but set it to verify only. + // This allows us to check if there's a diff between the checked in generated data and what it would generate now. + Expect(optionsRegistry.Register(markers.Must(markers.MakeDefinition("apply", markers.DescribesPackage, Generator{})))).To(Succeed()) + rt, err := genall.FromOptions(optionsRegistry, []string{ + "crd", // Run another generator first to make sure they don't interfere; see also: the comment on cronjob_types.go:UntypedBlob + "apply", + }) + Expect(err).NotTo(HaveOccurred()) + rt.OutputRules = genall.OutputRules{Default: output} + + By("running the generator and checking for errors") + hadErrs := rt.Run() + + By("checking for errors") + Expect(hadErrs).To(BeFalse(), "Generator should run without errors") + + filesInMaster := make(map[string][]byte) + masterFileNames := sets.New[string]() + cronJobFS := os.DirFS(".") + masterPath := "applyconfiguration-master" + Expect(fs.WalkDir(cronJobFS, masterPath, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + + if d.IsDir() { + return nil + } + + data, err := os.ReadFile(path) + if err != nil { + return fmt.Errorf("error reading file %s: %w", path, err) + } + + // Record the path without the path prefix for comparison later. + path = strings.TrimPrefix(path, masterPath+"/") + masterFileNames.Insert(path) + filesInMaster[path] = data + return nil + })).To(Succeed()) + + filesInOutput := make(map[string][]byte) + outputFileNames := sets.New[string]() + outputPath := "applyconfiguration" + Expect(fs.WalkDir(cronJobFS, outputPath, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + + if d.IsDir() { + return nil + } + + data, err := os.ReadFile(path) + if err != nil { + return fmt.Errorf("error reading file %s: %w", path, err) + } + + // Record the path without the path prefix for comparison later. + path = strings.TrimPrefix(path, outputPath+"/") + outputFileNames.Insert(path) + filesInOutput[path] = data + return nil + })).To(Succeed()) + + // Every file should be in both sets, check for files not in both sets. + Expect(masterFileNames.SymmetricDifference(outputFileNames).UnsortedList()).To(BeEmpty(), "Generated files should match the checked in files") + + for name, content := range filesInMaster { + Expect(string(filesInOutput[name])).To(Equal(string(content)), "Generated files should match the checked in files, diff found in %s", name) + } + }) +}) diff --git a/pkg/applyconfigurations/applyconfiguration_suite_test.go b/pkg/applyconfigurations/applyconfiguration_suite_test.go new file mode 100644 index 000000000..0f4409d56 --- /dev/null +++ b/pkg/applyconfigurations/applyconfiguration_suite_test.go @@ -0,0 +1,29 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package applyconfigurations + +import ( + "testing" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +func TestObjectGeneration(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "ApplyConfiguration Generation Suite") +} diff --git a/pkg/applyconfigurations/gen.go b/pkg/applyconfigurations/gen.go index 4166420af..66b84181c 100644 --- a/pkg/applyconfigurations/gen.go +++ b/pkg/applyconfigurations/gen.go @@ -200,6 +200,9 @@ func (ctx *ObjectGenCtx) generateForPackage(root *loader.Package) error { genericArgs.OutputPackagePath = filepath.Join(root.PkgPath, importPathSuffix) genericArgs.GoHeaderFilePath = ctx.HeaderFilePath + // Make the generated header static so that it doesn't rely on the compiled binary name. + genericArgs.GeneratedByCommentTemplate = "// Code generated by applyconfiguration-gen. DO NOT EDIT.\n" + if err := generatorargs.Validate(genericArgs); err != nil { return err } diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/internal/internal.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/internal/internal.go new file mode 100644 index 000000000..47f29e51b --- /dev/null +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/internal/internal.go @@ -0,0 +1,46 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package internal + +import ( + "fmt" + "sync" + + typed "sigs.k8s.io/structured-merge-diff/v4/typed" +) + +func Parser() *typed.Parser { + parserOnce.Do(func() { + var err error + parser, err = typed.NewParser(schemaYAML) + if err != nil { + panic(fmt.Sprintf("Failed to parse schema: %v", err)) + } + }) + return parser +} + +var parserOnce sync.Once +var parser *typed.Parser +var schemaYAML = typed.YAMLObject(`types: +- name: __untyped_atomic_ + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic +- name: __untyped_deduced_ + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +`) diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/associativetype.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/associativetype.go new file mode 100644 index 000000000..70574307e --- /dev/null +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/associativetype.go @@ -0,0 +1,41 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package cronjob + +// AssociativeTypeApplyConfiguration represents an declarative configuration of the AssociativeType type for use +// with apply. +type AssociativeTypeApplyConfiguration struct { + Name *string `json:"name,omitempty"` + Secondary *int `json:"secondary,omitempty"` + Foo *string `json:"foo,omitempty"` +} + +// AssociativeTypeApplyConfiguration constructs an declarative configuration of the AssociativeType type for use with +// apply. +func AssociativeType() *AssociativeTypeApplyConfiguration { + return &AssociativeTypeApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *AssociativeTypeApplyConfiguration) WithName(value string) *AssociativeTypeApplyConfiguration { + b.Name = &value + return b +} + +// WithSecondary sets the Secondary field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Secondary field is set to the value of the last call. +func (b *AssociativeTypeApplyConfiguration) WithSecondary(value int) *AssociativeTypeApplyConfiguration { + b.Secondary = &value + return b +} + +// WithFoo sets the Foo field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Foo field is set to the value of the last call. +func (b *AssociativeTypeApplyConfiguration) WithFoo(value string) *AssociativeTypeApplyConfiguration { + b.Foo = &value + return b +} diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/cronjob.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/cronjob.go new file mode 100644 index 000000000..a1de7251c --- /dev/null +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/cronjob.go @@ -0,0 +1,203 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package cronjob + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// CronJobApplyConfiguration represents an declarative configuration of the CronJob type for use +// with apply. +type CronJobApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *CronJobSpecApplyConfiguration `json:"spec,omitempty"` + Status *CronJobStatusApplyConfiguration `json:"status,omitempty"` +} + +// CronJob constructs an declarative configuration of the CronJob type for use with +// apply. +func CronJob(name, namespace string) *CronJobApplyConfiguration { + b := &CronJobApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("CronJob") + b.WithAPIVersion("testdata/cronjob") + return b +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithKind(value string) *CronJobApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithAPIVersion(value string) *CronJobApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithName(value string) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithGenerateName(value string) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithNamespace(value string) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithUID(value types.UID) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithResourceVersion(value string) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithGeneration(value int64) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithCreationTimestamp(value metav1.Time) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *CronJobApplyConfiguration) WithLabels(entries map[string]string) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *CronJobApplyConfiguration) WithAnnotations(entries map[string]string) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *CronJobApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *CronJobApplyConfiguration) WithFinalizers(values ...string) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *CronJobApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithSpec(value *CronJobSpecApplyConfiguration) *CronJobApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithStatus(value *CronJobStatusApplyConfiguration) *CronJobApplyConfiguration { + b.Status = value + return b +} diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/cronjobspec.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/cronjobspec.go new file mode 100644 index 000000000..71a3330a7 --- /dev/null +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/cronjobspec.go @@ -0,0 +1,204 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package cronjob + +import ( + v1beta1 "k8s.io/api/batch/v1beta1" + v1 "k8s.io/api/core/v1" + cronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob" +) + +// CronJobSpecApplyConfiguration represents an declarative configuration of the CronJobSpec type for use +// with apply. +type CronJobSpecApplyConfiguration struct { + Schedule *string `json:"schedule,omitempty"` + StartingDeadlineSeconds *int64 `json:"startingDeadlineSeconds,omitempty"` + ConcurrencyPolicy *cronjob.ConcurrencyPolicy `json:"concurrencyPolicy,omitempty"` + Suspend *bool `json:"suspend,omitempty"` + BinaryName []byte `json:"binaryName,omitempty"` + CanBeNull *string `json:"canBeNull,omitempty"` + JobTemplate *v1beta1.JobTemplateSpec `json:"jobTemplate,omitempty"` + SuccessfulJobsHistoryLimit *int32 `json:"successfulJobsHistoryLimit,omitempty"` + FailedJobsHistoryLimit *int32 `json:"failedJobsHistoryLimit,omitempty"` + StringSliceData map[string][]string `json:"stringSliceData,omitempty"` + PtrData map[string]*string `json:"ptrData,omitempty"` + Slice []string `json:"slice,omitempty"` + SlicePtr []*string `json:"slicePtr,omitempty"` + SliceStruct []*cronjob.ExampleStruct `json:"sliceStruct,omitempty"` + BuiltInReference *v1.PodSpec `json:"builtInReference,omitempty"` + Int *int `json:"int,omitempty"` + AssociativeList []AssociativeTypeApplyConfiguration `json:"associativeList,omitempty"` +} + +// CronJobSpecApplyConfiguration constructs an declarative configuration of the CronJobSpec type for use with +// apply. +func CronJobSpec() *CronJobSpecApplyConfiguration { + return &CronJobSpecApplyConfiguration{} +} + +// WithSchedule sets the Schedule field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Schedule field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithSchedule(value string) *CronJobSpecApplyConfiguration { + b.Schedule = &value + return b +} + +// WithStartingDeadlineSeconds sets the StartingDeadlineSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the StartingDeadlineSeconds field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithStartingDeadlineSeconds(value int64) *CronJobSpecApplyConfiguration { + b.StartingDeadlineSeconds = &value + return b +} + +// WithConcurrencyPolicy sets the ConcurrencyPolicy field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ConcurrencyPolicy field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithConcurrencyPolicy(value cronjob.ConcurrencyPolicy) *CronJobSpecApplyConfiguration { + b.ConcurrencyPolicy = &value + return b +} + +// WithSuspend sets the Suspend field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Suspend field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithSuspend(value bool) *CronJobSpecApplyConfiguration { + b.Suspend = &value + return b +} + +// WithBinaryName adds the given value to the BinaryName field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the BinaryName field. +func (b *CronJobSpecApplyConfiguration) WithBinaryName(values ...byte) *CronJobSpecApplyConfiguration { + for i := range values { + b.BinaryName = append(b.BinaryName, values[i]) + } + return b +} + +// WithCanBeNull sets the CanBeNull field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CanBeNull field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithCanBeNull(value string) *CronJobSpecApplyConfiguration { + b.CanBeNull = &value + return b +} + +// WithJobTemplate sets the JobTemplate field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the JobTemplate field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithJobTemplate(value v1beta1.JobTemplateSpec) *CronJobSpecApplyConfiguration { + b.JobTemplate = &value + return b +} + +// WithSuccessfulJobsHistoryLimit sets the SuccessfulJobsHistoryLimit field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the SuccessfulJobsHistoryLimit field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithSuccessfulJobsHistoryLimit(value int32) *CronJobSpecApplyConfiguration { + b.SuccessfulJobsHistoryLimit = &value + return b +} + +// WithFailedJobsHistoryLimit sets the FailedJobsHistoryLimit field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the FailedJobsHistoryLimit field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithFailedJobsHistoryLimit(value int32) *CronJobSpecApplyConfiguration { + b.FailedJobsHistoryLimit = &value + return b +} + +// WithStringSliceData puts the entries into the StringSliceData field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the StringSliceData field, +// overwriting an existing map entries in StringSliceData field with the same key. +func (b *CronJobSpecApplyConfiguration) WithStringSliceData(entries map[string][]string) *CronJobSpecApplyConfiguration { + if b.StringSliceData == nil && len(entries) > 0 { + b.StringSliceData = make(map[string][]string, len(entries)) + } + for k, v := range entries { + b.StringSliceData[k] = v + } + return b +} + +// WithPtrData puts the entries into the PtrData field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the PtrData field, +// overwriting an existing map entries in PtrData field with the same key. +func (b *CronJobSpecApplyConfiguration) WithPtrData(entries map[string]*string) *CronJobSpecApplyConfiguration { + if b.PtrData == nil && len(entries) > 0 { + b.PtrData = make(map[string]*string, len(entries)) + } + for k, v := range entries { + b.PtrData[k] = v + } + return b +} + +// WithSlice adds the given value to the Slice field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Slice field. +func (b *CronJobSpecApplyConfiguration) WithSlice(values ...string) *CronJobSpecApplyConfiguration { + for i := range values { + b.Slice = append(b.Slice, values[i]) + } + return b +} + +// WithSlicePtr adds the given value to the SlicePtr field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the SlicePtr field. +func (b *CronJobSpecApplyConfiguration) WithSlicePtr(values ...*string) *CronJobSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithSlicePtr") + } + b.SlicePtr = append(b.SlicePtr, *values[i]) + } + return b +} + +// WithSliceStruct adds the given value to the SliceStruct field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the SliceStruct field. +func (b *CronJobSpecApplyConfiguration) WithSliceStruct(values ...**cronjob.ExampleStruct) *CronJobSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithSliceStruct") + } + b.SliceStruct = append(b.SliceStruct, *values[i]) + } + return b +} + +// WithBuiltInReference sets the BuiltInReference field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the BuiltInReference field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithBuiltInReference(value v1.PodSpec) *CronJobSpecApplyConfiguration { + b.BuiltInReference = &value + return b +} + +// WithInt sets the Int field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Int field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithInt(value int) *CronJobSpecApplyConfiguration { + b.Int = &value + return b +} + +// WithAssociativeList adds the given value to the AssociativeList field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the AssociativeList field. +func (b *CronJobSpecApplyConfiguration) WithAssociativeList(values ...*AssociativeTypeApplyConfiguration) *CronJobSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithAssociativeList") + } + b.AssociativeList = append(b.AssociativeList, *values[i]) + } + return b +} diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/cronjobstatus.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/cronjobstatus.go new file mode 100644 index 000000000..80c2d34bc --- /dev/null +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/cronjobstatus.go @@ -0,0 +1,48 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package cronjob + +import ( + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// CronJobStatusApplyConfiguration represents an declarative configuration of the CronJobStatus type for use +// with apply. +type CronJobStatusApplyConfiguration struct { + Active []v1.ObjectReference `json:"active,omitempty"` + LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty"` + LastScheduleMicroTime *metav1.MicroTime `json:"lastScheduleMicroTime,omitempty"` +} + +// CronJobStatusApplyConfiguration constructs an declarative configuration of the CronJobStatus type for use with +// apply. +func CronJobStatus() *CronJobStatusApplyConfiguration { + return &CronJobStatusApplyConfiguration{} +} + +// WithActive adds the given value to the Active field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Active field. +func (b *CronJobStatusApplyConfiguration) WithActive(values ...v1.ObjectReference) *CronJobStatusApplyConfiguration { + for i := range values { + b.Active = append(b.Active, values[i]) + } + return b +} + +// WithLastScheduleTime sets the LastScheduleTime field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LastScheduleTime field is set to the value of the last call. +func (b *CronJobStatusApplyConfiguration) WithLastScheduleTime(value metav1.Time) *CronJobStatusApplyConfiguration { + b.LastScheduleTime = &value + return b +} + +// WithLastScheduleMicroTime sets the LastScheduleMicroTime field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LastScheduleMicroTime field is set to the value of the last call. +func (b *CronJobStatusApplyConfiguration) WithLastScheduleMicroTime(value metav1.MicroTime) *CronJobStatusApplyConfiguration { + b.LastScheduleMicroTime = &value + return b +} diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/examplestruct.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/examplestruct.go new file mode 100644 index 000000000..33eaf6cfd --- /dev/null +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/examplestruct.go @@ -0,0 +1,23 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package cronjob + +// ExampleStructApplyConfiguration represents an declarative configuration of the ExampleStruct type for use +// with apply. +type ExampleStructApplyConfiguration struct { + ExampleField *string `json:"string,omitempty"` +} + +// ExampleStructApplyConfiguration constructs an declarative configuration of the ExampleStruct type for use with +// apply. +func ExampleStruct() *ExampleStructApplyConfiguration { + return &ExampleStructApplyConfiguration{} +} + +// WithExampleField sets the ExampleField field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ExampleField field is set to the value of the last call. +func (b *ExampleStructApplyConfiguration) WithExampleField(value string) *ExampleStructApplyConfiguration { + b.ExampleField = &value + return b +} diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/utils.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/utils.go new file mode 100644 index 000000000..3814a6bc0 --- /dev/null +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/utils.go @@ -0,0 +1,29 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package applyconfiguration + +import ( + schema "k8s.io/apimachinery/pkg/runtime/schema" + cronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob" + testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob" +) + +// ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no +// apply configuration type exists for the given GroupVersionKind. +func ForKind(kind schema.GroupVersionKind) interface{} { + switch kind { + // Group=testdata, Version=cronjob + case cronjob.SchemeGroupVersion.WithKind("AssociativeType"): + return &testdatacronjob.AssociativeTypeApplyConfiguration{} + case cronjob.SchemeGroupVersion.WithKind("CronJob"): + return &testdatacronjob.CronJobApplyConfiguration{} + case cronjob.SchemeGroupVersion.WithKind("CronJobSpec"): + return &testdatacronjob.CronJobSpecApplyConfiguration{} + case cronjob.SchemeGroupVersion.WithKind("CronJobStatus"): + return &testdatacronjob.CronJobStatusApplyConfiguration{} + case cronjob.SchemeGroupVersion.WithKind("ExampleStruct"): + return &testdatacronjob.ExampleStructApplyConfiguration{} + + } + return nil +} diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/internal/internal.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/internal/internal.go index c121b9b3f..47f29e51b 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/internal/internal.go +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/internal/internal.go @@ -1,4 +1,4 @@ -// Code generated by controller-gen. DO NOT EDIT. +// Code generated by applyconfiguration-gen. DO NOT EDIT. package internal diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/associativetype.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/associativetype.go index fe677b8ca..70574307e 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/associativetype.go +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/associativetype.go @@ -1,4 +1,4 @@ -// Code generated by controller-gen. DO NOT EDIT. +// Code generated by applyconfiguration-gen. DO NOT EDIT. package cronjob diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjob.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjob.go index 257677ede..a1de7251c 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjob.go +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjob.go @@ -1,4 +1,4 @@ -// Code generated by controller-gen. DO NOT EDIT. +// Code generated by applyconfiguration-gen. DO NOT EDIT. package cronjob diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go index 43720b7a4..71a3330a7 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go @@ -1,4 +1,4 @@ -// Code generated by controller-gen. DO NOT EDIT. +// Code generated by applyconfiguration-gen. DO NOT EDIT. package cronjob diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go index 738e0927f..80c2d34bc 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go @@ -1,4 +1,4 @@ -// Code generated by controller-gen. DO NOT EDIT. +// Code generated by applyconfiguration-gen. DO NOT EDIT. package cronjob diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go index 9b0dad9bd..33eaf6cfd 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go @@ -1,4 +1,4 @@ -// Code generated by controller-gen. DO NOT EDIT. +// Code generated by applyconfiguration-gen. DO NOT EDIT. package cronjob diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go index 9ae8d1b49..3814a6bc0 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go @@ -1,4 +1,4 @@ -// Code generated by controller-gen. DO NOT EDIT. +// Code generated by applyconfiguration-gen. DO NOT EDIT. package applyconfiguration From 8d0a89993c36be2019a6bbff688988ea2aaed1e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakob=20M=C3=B6ller?= Date: Fri, 15 Sep 2023 16:15:10 +0200 Subject: [PATCH 10/22] chore: resolve applyconfig gen correctly --- .../applyconfiguration_integration_test.go | 13 ++- pkg/applyconfigurations/gen.go | 88 ++++++++----------- .../cronjob/applyconfiguration/utils.go | 4 +- .../testdata/cronjob/groupversion_info.go | 1 + .../internal/internal.go | 0 .../testdata/cronjob/associativetype.go | 0 .../testdata/cronjob/cronjob.go | 0 .../testdata/cronjob/cronjobspec.go | 0 .../testdata/cronjob/cronjobstatus.go | 0 .../testdata/cronjob/examplestruct.go | 0 .../utils.go | 4 +- .../zz_generated.markerhelp.go | 5 -- 12 files changed, 50 insertions(+), 65 deletions(-) rename pkg/applyconfigurations/testdata/cronjob/{applyconfiguration-master => testapplyconfiguration}/internal/internal.go (100%) rename pkg/applyconfigurations/testdata/cronjob/{applyconfiguration-master => testapplyconfiguration}/testdata/cronjob/associativetype.go (100%) rename pkg/applyconfigurations/testdata/cronjob/{applyconfiguration-master => testapplyconfiguration}/testdata/cronjob/cronjob.go (100%) rename pkg/applyconfigurations/testdata/cronjob/{applyconfiguration-master => testapplyconfiguration}/testdata/cronjob/cronjobspec.go (100%) rename pkg/applyconfigurations/testdata/cronjob/{applyconfiguration-master => testapplyconfiguration}/testdata/cronjob/cronjobstatus.go (100%) rename pkg/applyconfigurations/testdata/cronjob/{applyconfiguration-master => testapplyconfiguration}/testdata/cronjob/examplestruct.go (100%) rename pkg/applyconfigurations/testdata/cronjob/{applyconfiguration-master => testapplyconfiguration}/utils.go (92%) diff --git a/pkg/applyconfigurations/applyconfiguration_integration_test.go b/pkg/applyconfigurations/applyconfiguration_integration_test.go index 3c8696143..d097bd572 100644 --- a/pkg/applyconfigurations/applyconfiguration_integration_test.go +++ b/pkg/applyconfigurations/applyconfiguration_integration_test.go @@ -21,6 +21,7 @@ import ( "io" "io/fs" "os" + "path/filepath" "strings" . "github.com/onsi/ginkgo" @@ -57,6 +58,13 @@ func (o *outputFile) Close() error { } var _ = Describe("ApplyConfiguration generation from API types", func() { + outputPath := "testapplyconfiguration" + masterPath := "applyconfiguration" + By("resetting the test directory") + // not using after each to allow for inspection of failed tests + BeforeEach(func() { + Expect(os.RemoveAll(filepath.Join(".", outputPath))).To(Succeed()) + }) It("should be able to verify generated ApplyConfiguration types for the CronJob schema", func() { By("switching into testdata to appease go modules") cwd, err := os.Getwd() @@ -79,6 +87,8 @@ var _ = Describe("ApplyConfiguration generation from API types", func() { Expect(err).NotTo(HaveOccurred()) rt.OutputRules = genall.OutputRules{Default: output} + cronJobFS := os.DirFS(".") + By("running the generator and checking for errors") hadErrs := rt.Run() @@ -87,8 +97,6 @@ var _ = Describe("ApplyConfiguration generation from API types", func() { filesInMaster := make(map[string][]byte) masterFileNames := sets.New[string]() - cronJobFS := os.DirFS(".") - masterPath := "applyconfiguration-master" Expect(fs.WalkDir(cronJobFS, masterPath, func(path string, d fs.DirEntry, err error) error { if err != nil { return err @@ -112,7 +120,6 @@ var _ = Describe("ApplyConfiguration generation from API types", func() { filesInOutput := make(map[string][]byte) outputFileNames := sets.New[string]() - outputPath := "applyconfiguration" Expect(fs.WalkDir(cronJobFS, outputPath, func(path string, d fs.DirEntry, err error) error { if err != nil { return err diff --git a/pkg/applyconfigurations/gen.go b/pkg/applyconfigurations/gen.go index 66b84181c..b32004d7c 100644 --- a/pkg/applyconfigurations/gen.go +++ b/pkg/applyconfigurations/gen.go @@ -19,10 +19,8 @@ package applyconfigurations import ( "fmt" "go/ast" - "go/types" "os" "path/filepath" - "strings" "k8s.io/apimachinery/pkg/util/sets" generatorargs "k8s.io/code-generator/cmd/applyconfiguration-gen/args" @@ -39,14 +37,10 @@ import ( var ( isCRDMarker = markers.Must(markers.MakeDefinition("kubebuilder:resource", markers.DescribesType, crdmarkers.Resource{})) enablePkgMarker = markers.Must(markers.MakeDefinition("kubebuilder:ac:generate", markers.DescribesPackage, false)) + outputPkgMarker = markers.Must(markers.MakeDefinition("kubebuilder:ac:output:package", markers.DescribesPackage, "")) enableTypeMarker = markers.Must(markers.MakeDefinition("kubebuilder:ac:generate", markers.DescribesType, false)) ) -var importMapping = map[string]string{ - "k8s.io/apimachinery/pkg/apis/": "k8s.io/client-go/applyconfigurations/", - "k8s.io/api/": "k8s.io/client-go/applyconfigurations/", -} - const importPathSuffix = "applyconfiguration" // +controllertools:marker:generateHelp @@ -67,7 +61,7 @@ func (Generator) CheckFilter() loader.NodeFilter { func (Generator) RegisterMarkers(into *markers.Registry) error { if err := markers.RegisterAll(into, - isCRDMarker, enablePkgMarker, enableTypeMarker); err != nil { + isCRDMarker, enablePkgMarker, enableTypeMarker, outputPkgMarker); err != nil { return err } @@ -75,9 +69,10 @@ func (Generator) RegisterMarkers(into *markers.Registry) error { markers.SimpleHelp("apply", "enables apply configuration generation for this type")) into.AddHelp( enableTypeMarker, markers.SimpleHelp("apply", "overrides enabling or disabling applyconfigurations generation for the type")) - into.AddHelp( enablePkgMarker, markers.SimpleHelp("apply", "overrides enabling or disabling applyconfigurations generation for the package")) + into.AddHelp( + outputPkgMarker, markers.SimpleHelp("apply", "overrides the default output package for the applyconfigurations generation")) return nil } @@ -102,6 +97,18 @@ func enabledOnType(info *markers.TypeInfo) bool { return isCRD(info) } +func outputPkg(col *markers.Collector, pkg *loader.Package) (string, error) { + pkgMarkers, err := markers.PackageMarkers(col, pkg) + if err != nil { + return "", err + } + pkgMarker := pkgMarkers.Get(outputPkgMarker.Name) + if pkgMarker != nil { + return pkgMarker.(string), nil + } + return "", nil +} + // isCRD marks whether the type is a CRD based on the +kubebuilder:resource marker. func isCRD(info *markers.TypeInfo) bool { objectEnabled := info.Markers.Get(isCRDMarker.Name) @@ -146,46 +153,6 @@ type ObjectGenCtx struct { HeaderFilePath string } -type Universe struct { - typeMetadata map[types.Type]*typeMetadata -} - -type typeMetadata struct { - used bool -} - -func (u *Universe) existingApplyConfigPath(_ *types.Named, pkgPath string) (string, bool) { - for prefix, replacePath := range importMapping { - if strings.HasPrefix(pkgPath, prefix) { - path := replacePath + strings.TrimPrefix(pkgPath, prefix) - return path, true - } - } - return "", false -} - -func (u *Universe) IsApplyConfigGenerated(typeInfo *types.Named) bool { - if t, ok := u.typeMetadata[typeInfo]; ok { - return t.used - } - return false -} - -func (u *Universe) GetApplyConfigPath(typeInfo *types.Named, pkgPath string) (string, bool) { - isApplyConfigGenerated := u.IsApplyConfigGenerated(typeInfo) - if path, ok := u.existingApplyConfigPath(typeInfo, pkgPath); ok { - if isApplyConfigGenerated { - return path, true - } - return pkgPath, false - } - // ApplyConfig is necessary but location is not explicitly specified. Assume the ApplyConfig exists at the below directory - if isApplyConfigGenerated { - return pkgPath + "/" + importPathSuffix, true - } - return pkgPath, false -} - // generateForPackage generates apply configuration implementations for // types in the given package, writing the formatted result to given writer. // May return nil if source could not be generated. @@ -194,12 +161,27 @@ func (ctx *ObjectGenCtx) generateForPackage(root *loader.Package) error { if !enabled { return nil } + if len(root.GoFiles) == 0 { + return nil + } genericArgs, _ := generatorargs.NewDefaults() genericArgs.InputDirs = []string{root.PkgPath} - genericArgs.OutputPackagePath = filepath.Join(root.PkgPath, importPathSuffix) genericArgs.GoHeaderFilePath = ctx.HeaderFilePath + outpkg, _ := outputPkg(ctx.Collector, root) + if outpkg == "" { + outpkg = importPathSuffix + } + genericArgs.OutputPackagePath = filepath.Join(root.PkgPath, outpkg) + + // attempts to retrieve the correct base directory to output apply configurations to by + // looking into the package and retrieving the first go file it finds, and using that as the output base. + // this is because we cannot rely on gogen calculating the correct output base. + // if we leave this empty, gogen will attempt to use GOPATH to write the files which is not wanted + genericArgs.OutputBase = filepath.Dir(root.GoFiles[0]) + trimPathPrefix := filepath.Join(genericArgs.OutputBase, root.PkgPath) + "/" + // Make the generated header static so that it doesn't rely on the compiled binary name. genericArgs.GeneratedByCommentTemplate = "// Code generated by applyconfiguration-gen. DO NOT EDIT.\n" @@ -216,9 +198,9 @@ func (ctx *ObjectGenCtx) generateForPackage(root *loader.Package) error { if err != nil { return err } - - // This allows the correct output location when GOPATH is unset. - c.TrimPathPrefix = root.PkgPath + "/" + // The output package path is fully qualified. It contains the OutputBase (which is the module directory) + // that means we will have to trim the fully qualified pkg down again. + c.TrimPathPrefix = trimPathPrefix pkg, ok := c.Universe[root.PkgPath] if !ok { diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go index 3814a6bc0..ae82c00a1 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go @@ -1,11 +1,11 @@ // Code generated by applyconfiguration-gen. DO NOT EDIT. -package applyconfiguration +package testapplyconfiguration import ( schema "k8s.io/apimachinery/pkg/runtime/schema" cronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob" - testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob" + testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob" ) // ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no diff --git a/pkg/applyconfigurations/testdata/cronjob/groupversion_info.go b/pkg/applyconfigurations/testdata/cronjob/groupversion_info.go index c1f850329..d3e12759d 100644 --- a/pkg/applyconfigurations/testdata/cronjob/groupversion_info.go +++ b/pkg/applyconfigurations/testdata/cronjob/groupversion_info.go @@ -17,4 +17,5 @@ limitations under the License. // +groupName=testdata.kubebuilder.io // +versionName=v1 // +kubebuilder:ac:generate=true +// +kubebuilder:ac:output:package="testapplyconfiguration" package testdata diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/internal/internal.go b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/internal/internal.go similarity index 100% rename from pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/internal/internal.go rename to pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/internal/internal.go diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/associativetype.go b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/associativetype.go similarity index 100% rename from pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/associativetype.go rename to pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/associativetype.go diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/cronjob.go b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjob.go similarity index 100% rename from pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/cronjob.go rename to pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjob.go diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/cronjobspec.go b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobspec.go similarity index 100% rename from pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/cronjobspec.go rename to pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobspec.go diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/cronjobstatus.go b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobstatus.go similarity index 100% rename from pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/cronjobstatus.go rename to pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobstatus.go diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/examplestruct.go b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/examplestruct.go similarity index 100% rename from pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/testdata/cronjob/examplestruct.go rename to pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/examplestruct.go diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/utils.go b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/utils.go similarity index 92% rename from pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/utils.go rename to pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/utils.go index 3814a6bc0..ae82c00a1 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/utils.go +++ b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/utils.go @@ -1,11 +1,11 @@ // Code generated by applyconfiguration-gen. DO NOT EDIT. -package applyconfiguration +package testapplyconfiguration import ( schema "k8s.io/apimachinery/pkg/runtime/schema" cronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob" - testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob" + testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob" ) // ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no diff --git a/pkg/applyconfigurations/zz_generated.markerhelp.go b/pkg/applyconfigurations/zz_generated.markerhelp.go index 9b76ea32f..e21bbf34a 100644 --- a/pkg/applyconfigurations/zz_generated.markerhelp.go +++ b/pkg/applyconfigurations/zz_generated.markerhelp.go @@ -1,5 +1,4 @@ //go:build !ignore_autogenerated -// +build !ignore_autogenerated /* Copyright2019 The Kubernetes Authors. @@ -37,10 +36,6 @@ func (Generator) Help() *markers.DefinitionHelp { Summary: "specifies the header text (e.g. license) to prepend to generated files.", Details: "", }, - "Year": { - Summary: "specifies the year to substitute for \" YEAR\" in the header file.", - Details: "", - }, }, } } From 740e0ae570031a39dc8cb76b28ae22f723de29ff Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Fri, 28 Feb 2025 12:46:51 +0000 Subject: [PATCH 11/22] Migrate to gengo v2 --- pkg/applyconfigurations/gen.go | 56 +++++++++++++++------------------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/pkg/applyconfigurations/gen.go b/pkg/applyconfigurations/gen.go index b32004d7c..5be4562ce 100644 --- a/pkg/applyconfigurations/gen.go +++ b/pkg/applyconfigurations/gen.go @@ -23,9 +23,13 @@ import ( "path/filepath" "k8s.io/apimachinery/pkg/util/sets" - generatorargs "k8s.io/code-generator/cmd/applyconfiguration-gen/args" - applygenerator "k8s.io/code-generator/cmd/applyconfiguration-gen/generators" - "k8s.io/gengo/generator" + "k8s.io/code-generator/cmd/applyconfiguration-gen/args" + "k8s.io/code-generator/cmd/applyconfiguration-gen/generators" + + "k8s.io/gengo/v2" + "k8s.io/gengo/v2/generator" + "k8s.io/gengo/v2/parser" + crdmarkers "sigs.k8s.io/controller-tools/pkg/crd/markers" "sigs.k8s.io/controller-tools/pkg/genall" "sigs.k8s.io/controller-tools/pkg/loader" @@ -74,7 +78,6 @@ func (Generator) RegisterMarkers(into *markers.Registry) error { into.AddHelp( outputPkgMarker, markers.SimpleHelp("apply", "overrides the default output package for the applyconfigurations generation")) return nil - } func enabledOnPackage(col *markers.Collector, pkg *loader.Package) (bool, error) { @@ -165,42 +168,31 @@ func (ctx *ObjectGenCtx) generateForPackage(root *loader.Package) error { return nil } - genericArgs, _ := generatorargs.NewDefaults() - genericArgs.InputDirs = []string{root.PkgPath} - genericArgs.GoHeaderFilePath = ctx.HeaderFilePath + arguments := args.New() + arguments.GoHeaderFile = ctx.HeaderFilePath outpkg, _ := outputPkg(ctx.Collector, root) if outpkg == "" { outpkg = importPathSuffix } - genericArgs.OutputPackagePath = filepath.Join(root.PkgPath, outpkg) - - // attempts to retrieve the correct base directory to output apply configurations to by - // looking into the package and retrieving the first go file it finds, and using that as the output base. - // this is because we cannot rely on gogen calculating the correct output base. - // if we leave this empty, gogen will attempt to use GOPATH to write the files which is not wanted - genericArgs.OutputBase = filepath.Dir(root.GoFiles[0]) - trimPathPrefix := filepath.Join(genericArgs.OutputBase, root.PkgPath) + "/" - - // Make the generated header static so that it doesn't rely on the compiled binary name. - genericArgs.GeneratedByCommentTemplate = "// Code generated by applyconfiguration-gen. DO NOT EDIT.\n" - if err := generatorargs.Validate(genericArgs); err != nil { - return err - } + arguments.OutputDir = filepath.Join(root.Dir, outpkg) + arguments.OutputPkg = filepath.Join(root.Package.PkgPath, outpkg) - b, err := genericArgs.NewBuilder() - if err != nil { - return err + // The following code is based on gengo/v2.Execute. + // We have lifted it from there so that we can adjust the markers on the types to make sure + // that Kubebuilder generation markers are converted into the genclient marker + // prior to executing the targets. + buildTags := []string{gengo.StdBuildTag} + p := parser.NewWithOptions(parser.Options{BuildTags: buildTags}) + if err := p.LoadPackages(root.PkgPath); err != nil { + return fmt.Errorf("failed making a parser: %w", err) } - c, err := generator.NewContext(b, applygenerator.NameSystems(), applygenerator.DefaultNameSystem()) + c, err := generator.NewContext(p, generators.NameSystems(), generators.DefaultNameSystem()) if err != nil { - return err + return fmt.Errorf("failed making a context: %w", err) } - // The output package path is fully qualified. It contains the OutputBase (which is the module directory) - // that means we will have to trim the fully qualified pkg down again. - c.TrimPathPrefix = trimPathPrefix pkg, ok := c.Universe[root.PkgPath] if !ok { @@ -229,9 +221,9 @@ func (ctx *ObjectGenCtx) generateForPackage(root *loader.Package) error { return err } - packages := applygenerator.Packages(c, genericArgs) - if err := c.ExecutePackages(genericArgs.OutputBase, packages); err != nil { - return fmt.Errorf("error executing packages: %w", err) + targets := generators.GetTargets(c, arguments) + if err := c.ExecuteTargets(targets); err != nil { + return fmt.Errorf("failed executing generator: %w", err) } return nil From 5647ec5ac941688ef0704b2db986671fa53225ab Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Fri, 28 Feb 2025 12:47:18 +0000 Subject: [PATCH 12/22] Update generated test data --- .../applyconfiguration/internal/internal.go | 6 +- .../testdata/cronjob/associativetype.go | 6 +- .../testdata/cronjob/cronjob.go | 50 +- .../testdata/cronjob/cronjobspec.go | 16 +- .../testdata/cronjob/cronjobstatus.go | 6 +- .../testdata/cronjob/examplestruct.go | 6 +- .../cronjob/applyconfiguration/utils.go | 9 +- .../testdata/cronjob/cronjob_types.go | 4 - .../testdata/cronjob/go.mod | 61 ++- .../testdata/cronjob/go.sum | 502 +++--------------- .../testdata/cronjob/groupversion_info.go | 34 ++ .../internal/internal.go | 6 +- .../testdata/cronjob/associativetype.go | 6 +- .../testdata/cronjob/cronjob.go | 50 +- .../testdata/cronjob/cronjobspec.go | 16 +- .../testdata/cronjob/cronjobstatus.go | 6 +- .../testdata/cronjob/examplestruct.go | 6 +- .../cronjob/testapplyconfiguration/utils.go | 9 +- 18 files changed, 262 insertions(+), 537 deletions(-) diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/internal/internal.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/internal/internal.go index 47f29e51b..bdb4d8566 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/internal/internal.go +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/internal/internal.go @@ -1,10 +1,10 @@ -// Code generated by applyconfiguration-gen. DO NOT EDIT. +// Code generated by applyconfigurations. DO NOT EDIT. package internal import ( - "fmt" - "sync" + fmt "fmt" + sync "sync" typed "sigs.k8s.io/structured-merge-diff/v4/typed" ) diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/associativetype.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/associativetype.go index 70574307e..9247c255f 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/associativetype.go +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/associativetype.go @@ -1,8 +1,8 @@ -// Code generated by applyconfiguration-gen. DO NOT EDIT. +// Code generated by applyconfigurations. DO NOT EDIT. package cronjob -// AssociativeTypeApplyConfiguration represents an declarative configuration of the AssociativeType type for use +// AssociativeTypeApplyConfiguration represents a declarative configuration of the AssociativeType type for use // with apply. type AssociativeTypeApplyConfiguration struct { Name *string `json:"name,omitempty"` @@ -10,7 +10,7 @@ type AssociativeTypeApplyConfiguration struct { Foo *string `json:"foo,omitempty"` } -// AssociativeTypeApplyConfiguration constructs an declarative configuration of the AssociativeType type for use with +// AssociativeTypeApplyConfiguration constructs a declarative configuration of the AssociativeType type for use with // apply. func AssociativeType() *AssociativeTypeApplyConfiguration { return &AssociativeTypeApplyConfiguration{} diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjob.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjob.go index a1de7251c..441f9ea80 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjob.go +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjob.go @@ -1,4 +1,4 @@ -// Code generated by applyconfiguration-gen. DO NOT EDIT. +// Code generated by applyconfigurations. DO NOT EDIT. package cronjob @@ -8,7 +8,7 @@ import ( v1 "k8s.io/client-go/applyconfigurations/meta/v1" ) -// CronJobApplyConfiguration represents an declarative configuration of the CronJob type for use +// CronJobApplyConfiguration represents a declarative configuration of the CronJob type for use // with apply. type CronJobApplyConfiguration struct { v1.TypeMetaApplyConfiguration `json:",inline"` @@ -17,7 +17,7 @@ type CronJobApplyConfiguration struct { Status *CronJobStatusApplyConfiguration `json:"status,omitempty"` } -// CronJob constructs an declarative configuration of the CronJob type for use with +// CronJob constructs a declarative configuration of the CronJob type for use with // apply. func CronJob(name, namespace string) *CronJobApplyConfiguration { b := &CronJobApplyConfiguration{} @@ -32,7 +32,7 @@ func CronJob(name, namespace string) *CronJobApplyConfiguration { // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the Kind field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithKind(value string) *CronJobApplyConfiguration { - b.Kind = &value + b.TypeMetaApplyConfiguration.Kind = &value return b } @@ -40,7 +40,7 @@ func (b *CronJobApplyConfiguration) WithKind(value string) *CronJobApplyConfigur // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the APIVersion field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithAPIVersion(value string) *CronJobApplyConfiguration { - b.APIVersion = &value + b.TypeMetaApplyConfiguration.APIVersion = &value return b } @@ -49,7 +49,7 @@ func (b *CronJobApplyConfiguration) WithAPIVersion(value string) *CronJobApplyCo // If called multiple times, the Name field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithName(value string) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - b.Name = &value + b.ObjectMetaApplyConfiguration.Name = &value return b } @@ -58,7 +58,7 @@ func (b *CronJobApplyConfiguration) WithName(value string) *CronJobApplyConfigur // If called multiple times, the GenerateName field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithGenerateName(value string) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - b.GenerateName = &value + b.ObjectMetaApplyConfiguration.GenerateName = &value return b } @@ -67,7 +67,7 @@ func (b *CronJobApplyConfiguration) WithGenerateName(value string) *CronJobApply // If called multiple times, the Namespace field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithNamespace(value string) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - b.Namespace = &value + b.ObjectMetaApplyConfiguration.Namespace = &value return b } @@ -76,7 +76,7 @@ func (b *CronJobApplyConfiguration) WithNamespace(value string) *CronJobApplyCon // If called multiple times, the UID field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithUID(value types.UID) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - b.UID = &value + b.ObjectMetaApplyConfiguration.UID = &value return b } @@ -85,7 +85,7 @@ func (b *CronJobApplyConfiguration) WithUID(value types.UID) *CronJobApplyConfig // If called multiple times, the ResourceVersion field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithResourceVersion(value string) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - b.ResourceVersion = &value + b.ObjectMetaApplyConfiguration.ResourceVersion = &value return b } @@ -94,7 +94,7 @@ func (b *CronJobApplyConfiguration) WithResourceVersion(value string) *CronJobAp // If called multiple times, the Generation field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithGeneration(value int64) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - b.Generation = &value + b.ObjectMetaApplyConfiguration.Generation = &value return b } @@ -103,7 +103,7 @@ func (b *CronJobApplyConfiguration) WithGeneration(value int64) *CronJobApplyCon // If called multiple times, the CreationTimestamp field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithCreationTimestamp(value metav1.Time) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - b.CreationTimestamp = &value + b.ObjectMetaApplyConfiguration.CreationTimestamp = &value return b } @@ -112,7 +112,7 @@ func (b *CronJobApplyConfiguration) WithCreationTimestamp(value metav1.Time) *Cr // If called multiple times, the DeletionTimestamp field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - b.DeletionTimestamp = &value + b.ObjectMetaApplyConfiguration.DeletionTimestamp = &value return b } @@ -121,7 +121,7 @@ func (b *CronJobApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *Cr // If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - b.DeletionGracePeriodSeconds = &value + b.ObjectMetaApplyConfiguration.DeletionGracePeriodSeconds = &value return b } @@ -131,11 +131,11 @@ func (b *CronJobApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) // overwriting an existing map entries in Labels field with the same key. func (b *CronJobApplyConfiguration) WithLabels(entries map[string]string) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - if b.Labels == nil && len(entries) > 0 { - b.Labels = make(map[string]string, len(entries)) + if b.ObjectMetaApplyConfiguration.Labels == nil && len(entries) > 0 { + b.ObjectMetaApplyConfiguration.Labels = make(map[string]string, len(entries)) } for k, v := range entries { - b.Labels[k] = v + b.ObjectMetaApplyConfiguration.Labels[k] = v } return b } @@ -146,11 +146,11 @@ func (b *CronJobApplyConfiguration) WithLabels(entries map[string]string) *CronJ // overwriting an existing map entries in Annotations field with the same key. func (b *CronJobApplyConfiguration) WithAnnotations(entries map[string]string) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - if b.Annotations == nil && len(entries) > 0 { - b.Annotations = make(map[string]string, len(entries)) + if b.ObjectMetaApplyConfiguration.Annotations == nil && len(entries) > 0 { + b.ObjectMetaApplyConfiguration.Annotations = make(map[string]string, len(entries)) } for k, v := range entries { - b.Annotations[k] = v + b.ObjectMetaApplyConfiguration.Annotations[k] = v } return b } @@ -164,7 +164,7 @@ func (b *CronJobApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerRefer if values[i] == nil { panic("nil value passed to WithOwnerReferences") } - b.OwnerReferences = append(b.OwnerReferences, *values[i]) + b.ObjectMetaApplyConfiguration.OwnerReferences = append(b.ObjectMetaApplyConfiguration.OwnerReferences, *values[i]) } return b } @@ -175,7 +175,7 @@ func (b *CronJobApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerRefer func (b *CronJobApplyConfiguration) WithFinalizers(values ...string) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() for i := range values { - b.Finalizers = append(b.Finalizers, values[i]) + b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i]) } return b } @@ -201,3 +201,9 @@ func (b *CronJobApplyConfiguration) WithStatus(value *CronJobStatusApplyConfigur b.Status = value return b } + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *CronJobApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.ObjectMetaApplyConfiguration.Name +} diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go index 71a3330a7..e62b332af 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go @@ -1,19 +1,19 @@ -// Code generated by applyconfiguration-gen. DO NOT EDIT. +// Code generated by applyconfigurations. DO NOT EDIT. package cronjob import ( v1beta1 "k8s.io/api/batch/v1beta1" v1 "k8s.io/api/core/v1" - cronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob" + testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob" ) -// CronJobSpecApplyConfiguration represents an declarative configuration of the CronJobSpec type for use +// CronJobSpecApplyConfiguration represents a declarative configuration of the CronJobSpec type for use // with apply. type CronJobSpecApplyConfiguration struct { Schedule *string `json:"schedule,omitempty"` StartingDeadlineSeconds *int64 `json:"startingDeadlineSeconds,omitempty"` - ConcurrencyPolicy *cronjob.ConcurrencyPolicy `json:"concurrencyPolicy,omitempty"` + ConcurrencyPolicy *testdatacronjob.ConcurrencyPolicy `json:"concurrencyPolicy,omitempty"` Suspend *bool `json:"suspend,omitempty"` BinaryName []byte `json:"binaryName,omitempty"` CanBeNull *string `json:"canBeNull,omitempty"` @@ -24,13 +24,13 @@ type CronJobSpecApplyConfiguration struct { PtrData map[string]*string `json:"ptrData,omitempty"` Slice []string `json:"slice,omitempty"` SlicePtr []*string `json:"slicePtr,omitempty"` - SliceStruct []*cronjob.ExampleStruct `json:"sliceStruct,omitempty"` + SliceStruct []*testdatacronjob.ExampleStruct `json:"sliceStruct,omitempty"` BuiltInReference *v1.PodSpec `json:"builtInReference,omitempty"` Int *int `json:"int,omitempty"` AssociativeList []AssociativeTypeApplyConfiguration `json:"associativeList,omitempty"` } -// CronJobSpecApplyConfiguration constructs an declarative configuration of the CronJobSpec type for use with +// CronJobSpecApplyConfiguration constructs a declarative configuration of the CronJobSpec type for use with // apply. func CronJobSpec() *CronJobSpecApplyConfiguration { return &CronJobSpecApplyConfiguration{} @@ -55,7 +55,7 @@ func (b *CronJobSpecApplyConfiguration) WithStartingDeadlineSeconds(value int64) // WithConcurrencyPolicy sets the ConcurrencyPolicy field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the ConcurrencyPolicy field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithConcurrencyPolicy(value cronjob.ConcurrencyPolicy) *CronJobSpecApplyConfiguration { +func (b *CronJobSpecApplyConfiguration) WithConcurrencyPolicy(value testdatacronjob.ConcurrencyPolicy) *CronJobSpecApplyConfiguration { b.ConcurrencyPolicy = &value return b } @@ -164,7 +164,7 @@ func (b *CronJobSpecApplyConfiguration) WithSlicePtr(values ...*string) *CronJob // WithSliceStruct adds the given value to the SliceStruct field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. // If called multiple times, values provided by each call will be appended to the SliceStruct field. -func (b *CronJobSpecApplyConfiguration) WithSliceStruct(values ...**cronjob.ExampleStruct) *CronJobSpecApplyConfiguration { +func (b *CronJobSpecApplyConfiguration) WithSliceStruct(values ...**testdatacronjob.ExampleStruct) *CronJobSpecApplyConfiguration { for i := range values { if values[i] == nil { panic("nil value passed to WithSliceStruct") diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go index 80c2d34bc..f696bc514 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go @@ -1,4 +1,4 @@ -// Code generated by applyconfiguration-gen. DO NOT EDIT. +// Code generated by applyconfigurations. DO NOT EDIT. package cronjob @@ -7,7 +7,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// CronJobStatusApplyConfiguration represents an declarative configuration of the CronJobStatus type for use +// CronJobStatusApplyConfiguration represents a declarative configuration of the CronJobStatus type for use // with apply. type CronJobStatusApplyConfiguration struct { Active []v1.ObjectReference `json:"active,omitempty"` @@ -15,7 +15,7 @@ type CronJobStatusApplyConfiguration struct { LastScheduleMicroTime *metav1.MicroTime `json:"lastScheduleMicroTime,omitempty"` } -// CronJobStatusApplyConfiguration constructs an declarative configuration of the CronJobStatus type for use with +// CronJobStatusApplyConfiguration constructs a declarative configuration of the CronJobStatus type for use with // apply. func CronJobStatus() *CronJobStatusApplyConfiguration { return &CronJobStatusApplyConfiguration{} diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go index 33eaf6cfd..70950b1b7 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go @@ -1,14 +1,14 @@ -// Code generated by applyconfiguration-gen. DO NOT EDIT. +// Code generated by applyconfigurations. DO NOT EDIT. package cronjob -// ExampleStructApplyConfiguration represents an declarative configuration of the ExampleStruct type for use +// ExampleStructApplyConfiguration represents a declarative configuration of the ExampleStruct type for use // with apply. type ExampleStructApplyConfiguration struct { ExampleField *string `json:"string,omitempty"` } -// ExampleStructApplyConfiguration constructs an declarative configuration of the ExampleStruct type for use with +// ExampleStructApplyConfiguration constructs a declarative configuration of the ExampleStruct type for use with // apply. func ExampleStruct() *ExampleStructApplyConfiguration { return &ExampleStructApplyConfiguration{} diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go index ae82c00a1..a56703e4b 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go @@ -1,10 +1,13 @@ -// Code generated by applyconfiguration-gen. DO NOT EDIT. +// Code generated by applyconfigurations. DO NOT EDIT. package testapplyconfiguration import ( + runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" + testing "k8s.io/client-go/testing" cronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob" + internal "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/internal" testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob" ) @@ -27,3 +30,7 @@ func ForKind(kind schema.GroupVersionKind) interface{} { } return nil } + +func NewTypeConverter(scheme *runtime.Scheme) *testing.TypeConverter { + return &testing.TypeConverter{Scheme: scheme, TypeResolver: internal.Parser()} +} diff --git a/pkg/applyconfigurations/testdata/cronjob/cronjob_types.go b/pkg/applyconfigurations/testdata/cronjob/cronjob_types.go index 60129b189..6b2438e37 100644 --- a/pkg/applyconfigurations/testdata/cronjob/cronjob_types.go +++ b/pkg/applyconfigurations/testdata/cronjob/cronjob_types.go @@ -172,7 +172,3 @@ type CronJobList struct { metav1.ListMeta `json:"metadata,omitempty"` Items []CronJob `json:"items"` } - -func init() { - SchemeBuilder.Register(&CronJob{}, &CronJobList{}) -} diff --git a/pkg/applyconfigurations/testdata/cronjob/go.mod b/pkg/applyconfigurations/testdata/cronjob/go.mod index d30f47ff0..dc9881bea 100644 --- a/pkg/applyconfigurations/testdata/cronjob/go.mod +++ b/pkg/applyconfigurations/testdata/cronjob/go.mod @@ -1,49 +1,48 @@ module sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob -go 1.19 +go 1.23.0 require ( - k8s.io/api v0.25.0 - k8s.io/apimachinery v0.25.0 - k8s.io/client-go v0.25.0 + k8s.io/api v0.32.0 + k8s.io/apimachinery v0.32.0 + k8s.io/client-go v0.32.0 + sigs.k8s.io/structured-merge-diff/v4 v4.4.2 ) require ( - github.com/PuerkitoBio/purell v1.1.1 // indirect - github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/emicklei/go-restful/v3 v3.8.0 // indirect - github.com/go-logr/logr v1.2.3 // indirect - github.com/go-openapi/jsonpointer v0.19.5 // indirect - github.com/go-openapi/jsonreference v0.19.5 // indirect - github.com/go-openapi/swag v0.19.15 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/emicklei/go-restful/v3 v3.11.0 // indirect + github.com/fxamacker/cbor/v2 v2.7.0 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-openapi/jsonpointer v0.21.0 // indirect + github.com/go-openapi/jsonreference v0.20.2 // indirect + github.com/go-openapi/swag v0.23.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.2 // indirect - github.com/google/gnostic v0.5.7-v3refs // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/google/gnostic-models v0.6.8 // indirect github.com/google/gofuzz v1.2.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/stretchr/testify v1.8.0 // indirect - golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect - golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect - golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect - golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect - golang.org/x/text v0.3.7 // indirect - golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 // indirect - google.golang.org/appengine v1.6.7 // indirect - google.golang.org/protobuf v1.28.0 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/x448/float16 v0.8.4 // indirect + golang.org/x/net v0.30.0 // indirect + golang.org/x/oauth2 v0.23.0 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/term v0.25.0 // indirect + golang.org/x/text v0.19.0 // indirect + golang.org/x/time v0.7.0 // indirect + google.golang.org/protobuf v1.35.1 // indirect + gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/klog/v2 v2.70.2-0.20220707122935-0990e81f1a8f // indirect - k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect - k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect - sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect + k8s.io/klog/v2 v2.130.1 // indirect + k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect + k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect + sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect + sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/pkg/applyconfigurations/testdata/cronjob/go.sum b/pkg/applyconfigurations/testdata/cronjob/go.sum index 2251073c2..7b7596d1d 100644 --- a/pkg/applyconfigurations/testdata/cronjob/go.sum +++ b/pkg/applyconfigurations/testdata/cronjob/go.sum @@ -1,152 +1,53 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= -github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= -github.com/emicklei/go-restful/v3 v3.8.0 h1:eCZ8ulSerjdAiaNpF7GxXIE7ZCMo1moN1qX+S609eVw= -github.com/emicklei/go-restful/v3 v3.8.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= -github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= -github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonreference v0.19.5 h1:1WJP/wi4OjB4iV8KVbH73rQaoialJrqv8gitZLxGLtM= -github.com/go-openapi/jsonreference v0.19.5/go.mod h1:RdybgQwPxbL4UEjuAruzK1x3nE69AqPYEJeo/TWfEeg= -github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= -github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= +github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= +github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= +github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= +github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= +github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= +github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= +github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= +github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= +github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= +github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/gnostic v0.5.7-v3refs h1:FhTMOKj2VhjpouxvWJAV1TL304uMlb9zcDqkl6cEI54= -github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= +github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= +github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -156,329 +57,98 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/onsi/ginkgo/v2 v2.1.4 h1:GNapqRSid3zijZ9H77KrgVG4/8KqiyRsxcSxe+7ApXY= -github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM= +github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo= +github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4= +github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 h1:OSnWWcOd/CtWQC2cYSBgbTSJv3ciqd8r54ySIW2y3RE= -golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= +golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= +golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= +golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 h1:M73Iuj3xbbb9Uk1DYhzydthsj6oOd6l9bpuFcNoUvTs= -golang.org/x/time v0.0.0-20220224211638-0e9765cccd65/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= +golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= +golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= +google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4= +gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.25.0 h1:H+Q4ma2U/ww0iGB78ijZx6DRByPz6/733jIuFpX70e0= -k8s.io/api v0.25.0/go.mod h1:ttceV1GyV1i1rnmvzT3BST08N6nGt+dudGrquzVQWPk= -k8s.io/apimachinery v0.25.0 h1:MlP0r6+3XbkUG2itd6vp3oxbtdQLQI94fD5gCS+gnoU= -k8s.io/apimachinery v0.25.0/go.mod h1:qMx9eAk0sZQGsXGu86fab8tZdffHbwUfsvzqKn4mfB0= -k8s.io/client-go v0.25.0 h1:CVWIaCETLMBNiTUta3d5nzRbXvY5Hy9Dpl+VvREpu5E= -k8s.io/client-go v0.25.0/go.mod h1:lxykvypVfKilxhTklov0wz1FoaUZ8X4EwbhS6rpRfN8= -k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= -k8s.io/klog/v2 v2.70.2-0.20220707122935-0990e81f1a8f h1:dltw7bAn8bCrQ2CmzzhgoieUZEbWqrvIGVdHGioP5nY= -k8s.io/klog/v2 v2.70.2-0.20220707122935-0990e81f1a8f/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= -k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 h1:MQ8BAZPZlWk3S9K4a9NCkIFQtZShWqoha7snGixVgEA= -k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1/go.mod h1:C/N6wCaBHeBHkHUesQOQy2/MZqGgMAFPqGsGQLdbZBU= -k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed h1:jAne/RjBTyawwAy0utX5eqigAwz/lQhTmy+Hr/Cpue4= -k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k= -sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= -sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= +k8s.io/api v0.32.0 h1:OL9JpbvAU5ny9ga2fb24X8H6xQlVp+aJMFlgtQjR9CE= +k8s.io/api v0.32.0/go.mod h1:4LEwHZEf6Q/cG96F3dqR965sYOfmPM7rq81BLgsE0p0= +k8s.io/apimachinery v0.32.0 h1:cFSE7N3rmEEtv4ei5X6DaJPHHX0C+upp+v5lVPiEwpg= +k8s.io/apimachinery v0.32.0/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE= +k8s.io/client-go v0.32.0 h1:DimtMcnN/JIKZcrSrstiwvvZvLjG0aSxy8PxN8IChp8= +k8s.io/client-go v0.32.0/go.mod h1:boDWvdM1Drk4NJj/VddSLnx59X3OPgwrOo0vGbtq9+8= +k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= +k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y= +k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f/go.mod h1:R/HEjbvWI0qdfb8viZUeVZm0X6IZnxAydC7YU42CMw4= +k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= +k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= +sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= +sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= +sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= +sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/pkg/applyconfigurations/testdata/cronjob/groupversion_info.go b/pkg/applyconfigurations/testdata/cronjob/groupversion_info.go index d3e12759d..c8bbdbb82 100644 --- a/pkg/applyconfigurations/testdata/cronjob/groupversion_info.go +++ b/pkg/applyconfigurations/testdata/cronjob/groupversion_info.go @@ -19,3 +19,37 @@ limitations under the License. // +kubebuilder:ac:generate=true // +kubebuilder:ac:output:package="testapplyconfiguration" package testdata + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var ( + GroupName = "testdata.kubebuilder.io" + GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"} + schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + // Install is a function which adds this version to a scheme + Install = schemeBuilder.AddToScheme + + // SchemeGroupVersion generated code relies on this name + // Deprecated + SchemeGroupVersion = GroupVersion + // AddToScheme exists solely to keep the old generators creating valid code + // DEPRECATED + AddToScheme = schemeBuilder.AddToScheme +) + +// Resource generated code relies on this being here, but it logically belongs to the group +// DEPRECATED +func Resource(resource string) schema.GroupResource { + return schema.GroupResource{Group: GroupName, Resource: resource} +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + metav1.AddToGroupVersion(scheme, GroupVersion) + + return nil +} diff --git a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/internal/internal.go b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/internal/internal.go index 47f29e51b..bdb4d8566 100644 --- a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/internal/internal.go +++ b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/internal/internal.go @@ -1,10 +1,10 @@ -// Code generated by applyconfiguration-gen. DO NOT EDIT. +// Code generated by applyconfigurations. DO NOT EDIT. package internal import ( - "fmt" - "sync" + fmt "fmt" + sync "sync" typed "sigs.k8s.io/structured-merge-diff/v4/typed" ) diff --git a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/associativetype.go b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/associativetype.go index 70574307e..9247c255f 100644 --- a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/associativetype.go +++ b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/associativetype.go @@ -1,8 +1,8 @@ -// Code generated by applyconfiguration-gen. DO NOT EDIT. +// Code generated by applyconfigurations. DO NOT EDIT. package cronjob -// AssociativeTypeApplyConfiguration represents an declarative configuration of the AssociativeType type for use +// AssociativeTypeApplyConfiguration represents a declarative configuration of the AssociativeType type for use // with apply. type AssociativeTypeApplyConfiguration struct { Name *string `json:"name,omitempty"` @@ -10,7 +10,7 @@ type AssociativeTypeApplyConfiguration struct { Foo *string `json:"foo,omitempty"` } -// AssociativeTypeApplyConfiguration constructs an declarative configuration of the AssociativeType type for use with +// AssociativeTypeApplyConfiguration constructs a declarative configuration of the AssociativeType type for use with // apply. func AssociativeType() *AssociativeTypeApplyConfiguration { return &AssociativeTypeApplyConfiguration{} diff --git a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjob.go b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjob.go index a1de7251c..441f9ea80 100644 --- a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjob.go +++ b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjob.go @@ -1,4 +1,4 @@ -// Code generated by applyconfiguration-gen. DO NOT EDIT. +// Code generated by applyconfigurations. DO NOT EDIT. package cronjob @@ -8,7 +8,7 @@ import ( v1 "k8s.io/client-go/applyconfigurations/meta/v1" ) -// CronJobApplyConfiguration represents an declarative configuration of the CronJob type for use +// CronJobApplyConfiguration represents a declarative configuration of the CronJob type for use // with apply. type CronJobApplyConfiguration struct { v1.TypeMetaApplyConfiguration `json:",inline"` @@ -17,7 +17,7 @@ type CronJobApplyConfiguration struct { Status *CronJobStatusApplyConfiguration `json:"status,omitempty"` } -// CronJob constructs an declarative configuration of the CronJob type for use with +// CronJob constructs a declarative configuration of the CronJob type for use with // apply. func CronJob(name, namespace string) *CronJobApplyConfiguration { b := &CronJobApplyConfiguration{} @@ -32,7 +32,7 @@ func CronJob(name, namespace string) *CronJobApplyConfiguration { // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the Kind field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithKind(value string) *CronJobApplyConfiguration { - b.Kind = &value + b.TypeMetaApplyConfiguration.Kind = &value return b } @@ -40,7 +40,7 @@ func (b *CronJobApplyConfiguration) WithKind(value string) *CronJobApplyConfigur // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the APIVersion field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithAPIVersion(value string) *CronJobApplyConfiguration { - b.APIVersion = &value + b.TypeMetaApplyConfiguration.APIVersion = &value return b } @@ -49,7 +49,7 @@ func (b *CronJobApplyConfiguration) WithAPIVersion(value string) *CronJobApplyCo // If called multiple times, the Name field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithName(value string) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - b.Name = &value + b.ObjectMetaApplyConfiguration.Name = &value return b } @@ -58,7 +58,7 @@ func (b *CronJobApplyConfiguration) WithName(value string) *CronJobApplyConfigur // If called multiple times, the GenerateName field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithGenerateName(value string) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - b.GenerateName = &value + b.ObjectMetaApplyConfiguration.GenerateName = &value return b } @@ -67,7 +67,7 @@ func (b *CronJobApplyConfiguration) WithGenerateName(value string) *CronJobApply // If called multiple times, the Namespace field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithNamespace(value string) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - b.Namespace = &value + b.ObjectMetaApplyConfiguration.Namespace = &value return b } @@ -76,7 +76,7 @@ func (b *CronJobApplyConfiguration) WithNamespace(value string) *CronJobApplyCon // If called multiple times, the UID field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithUID(value types.UID) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - b.UID = &value + b.ObjectMetaApplyConfiguration.UID = &value return b } @@ -85,7 +85,7 @@ func (b *CronJobApplyConfiguration) WithUID(value types.UID) *CronJobApplyConfig // If called multiple times, the ResourceVersion field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithResourceVersion(value string) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - b.ResourceVersion = &value + b.ObjectMetaApplyConfiguration.ResourceVersion = &value return b } @@ -94,7 +94,7 @@ func (b *CronJobApplyConfiguration) WithResourceVersion(value string) *CronJobAp // If called multiple times, the Generation field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithGeneration(value int64) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - b.Generation = &value + b.ObjectMetaApplyConfiguration.Generation = &value return b } @@ -103,7 +103,7 @@ func (b *CronJobApplyConfiguration) WithGeneration(value int64) *CronJobApplyCon // If called multiple times, the CreationTimestamp field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithCreationTimestamp(value metav1.Time) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - b.CreationTimestamp = &value + b.ObjectMetaApplyConfiguration.CreationTimestamp = &value return b } @@ -112,7 +112,7 @@ func (b *CronJobApplyConfiguration) WithCreationTimestamp(value metav1.Time) *Cr // If called multiple times, the DeletionTimestamp field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - b.DeletionTimestamp = &value + b.ObjectMetaApplyConfiguration.DeletionTimestamp = &value return b } @@ -121,7 +121,7 @@ func (b *CronJobApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *Cr // If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. func (b *CronJobApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - b.DeletionGracePeriodSeconds = &value + b.ObjectMetaApplyConfiguration.DeletionGracePeriodSeconds = &value return b } @@ -131,11 +131,11 @@ func (b *CronJobApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) // overwriting an existing map entries in Labels field with the same key. func (b *CronJobApplyConfiguration) WithLabels(entries map[string]string) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - if b.Labels == nil && len(entries) > 0 { - b.Labels = make(map[string]string, len(entries)) + if b.ObjectMetaApplyConfiguration.Labels == nil && len(entries) > 0 { + b.ObjectMetaApplyConfiguration.Labels = make(map[string]string, len(entries)) } for k, v := range entries { - b.Labels[k] = v + b.ObjectMetaApplyConfiguration.Labels[k] = v } return b } @@ -146,11 +146,11 @@ func (b *CronJobApplyConfiguration) WithLabels(entries map[string]string) *CronJ // overwriting an existing map entries in Annotations field with the same key. func (b *CronJobApplyConfiguration) WithAnnotations(entries map[string]string) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() - if b.Annotations == nil && len(entries) > 0 { - b.Annotations = make(map[string]string, len(entries)) + if b.ObjectMetaApplyConfiguration.Annotations == nil && len(entries) > 0 { + b.ObjectMetaApplyConfiguration.Annotations = make(map[string]string, len(entries)) } for k, v := range entries { - b.Annotations[k] = v + b.ObjectMetaApplyConfiguration.Annotations[k] = v } return b } @@ -164,7 +164,7 @@ func (b *CronJobApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerRefer if values[i] == nil { panic("nil value passed to WithOwnerReferences") } - b.OwnerReferences = append(b.OwnerReferences, *values[i]) + b.ObjectMetaApplyConfiguration.OwnerReferences = append(b.ObjectMetaApplyConfiguration.OwnerReferences, *values[i]) } return b } @@ -175,7 +175,7 @@ func (b *CronJobApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerRefer func (b *CronJobApplyConfiguration) WithFinalizers(values ...string) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() for i := range values { - b.Finalizers = append(b.Finalizers, values[i]) + b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i]) } return b } @@ -201,3 +201,9 @@ func (b *CronJobApplyConfiguration) WithStatus(value *CronJobStatusApplyConfigur b.Status = value return b } + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *CronJobApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.ObjectMetaApplyConfiguration.Name +} diff --git a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobspec.go b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobspec.go index 71a3330a7..e62b332af 100644 --- a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobspec.go +++ b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobspec.go @@ -1,19 +1,19 @@ -// Code generated by applyconfiguration-gen. DO NOT EDIT. +// Code generated by applyconfigurations. DO NOT EDIT. package cronjob import ( v1beta1 "k8s.io/api/batch/v1beta1" v1 "k8s.io/api/core/v1" - cronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob" + testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob" ) -// CronJobSpecApplyConfiguration represents an declarative configuration of the CronJobSpec type for use +// CronJobSpecApplyConfiguration represents a declarative configuration of the CronJobSpec type for use // with apply. type CronJobSpecApplyConfiguration struct { Schedule *string `json:"schedule,omitempty"` StartingDeadlineSeconds *int64 `json:"startingDeadlineSeconds,omitempty"` - ConcurrencyPolicy *cronjob.ConcurrencyPolicy `json:"concurrencyPolicy,omitempty"` + ConcurrencyPolicy *testdatacronjob.ConcurrencyPolicy `json:"concurrencyPolicy,omitempty"` Suspend *bool `json:"suspend,omitempty"` BinaryName []byte `json:"binaryName,omitempty"` CanBeNull *string `json:"canBeNull,omitempty"` @@ -24,13 +24,13 @@ type CronJobSpecApplyConfiguration struct { PtrData map[string]*string `json:"ptrData,omitempty"` Slice []string `json:"slice,omitempty"` SlicePtr []*string `json:"slicePtr,omitempty"` - SliceStruct []*cronjob.ExampleStruct `json:"sliceStruct,omitempty"` + SliceStruct []*testdatacronjob.ExampleStruct `json:"sliceStruct,omitempty"` BuiltInReference *v1.PodSpec `json:"builtInReference,omitempty"` Int *int `json:"int,omitempty"` AssociativeList []AssociativeTypeApplyConfiguration `json:"associativeList,omitempty"` } -// CronJobSpecApplyConfiguration constructs an declarative configuration of the CronJobSpec type for use with +// CronJobSpecApplyConfiguration constructs a declarative configuration of the CronJobSpec type for use with // apply. func CronJobSpec() *CronJobSpecApplyConfiguration { return &CronJobSpecApplyConfiguration{} @@ -55,7 +55,7 @@ func (b *CronJobSpecApplyConfiguration) WithStartingDeadlineSeconds(value int64) // WithConcurrencyPolicy sets the ConcurrencyPolicy field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the ConcurrencyPolicy field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithConcurrencyPolicy(value cronjob.ConcurrencyPolicy) *CronJobSpecApplyConfiguration { +func (b *CronJobSpecApplyConfiguration) WithConcurrencyPolicy(value testdatacronjob.ConcurrencyPolicy) *CronJobSpecApplyConfiguration { b.ConcurrencyPolicy = &value return b } @@ -164,7 +164,7 @@ func (b *CronJobSpecApplyConfiguration) WithSlicePtr(values ...*string) *CronJob // WithSliceStruct adds the given value to the SliceStruct field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. // If called multiple times, values provided by each call will be appended to the SliceStruct field. -func (b *CronJobSpecApplyConfiguration) WithSliceStruct(values ...**cronjob.ExampleStruct) *CronJobSpecApplyConfiguration { +func (b *CronJobSpecApplyConfiguration) WithSliceStruct(values ...**testdatacronjob.ExampleStruct) *CronJobSpecApplyConfiguration { for i := range values { if values[i] == nil { panic("nil value passed to WithSliceStruct") diff --git a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobstatus.go b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobstatus.go index 80c2d34bc..f696bc514 100644 --- a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobstatus.go +++ b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobstatus.go @@ -1,4 +1,4 @@ -// Code generated by applyconfiguration-gen. DO NOT EDIT. +// Code generated by applyconfigurations. DO NOT EDIT. package cronjob @@ -7,7 +7,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// CronJobStatusApplyConfiguration represents an declarative configuration of the CronJobStatus type for use +// CronJobStatusApplyConfiguration represents a declarative configuration of the CronJobStatus type for use // with apply. type CronJobStatusApplyConfiguration struct { Active []v1.ObjectReference `json:"active,omitempty"` @@ -15,7 +15,7 @@ type CronJobStatusApplyConfiguration struct { LastScheduleMicroTime *metav1.MicroTime `json:"lastScheduleMicroTime,omitempty"` } -// CronJobStatusApplyConfiguration constructs an declarative configuration of the CronJobStatus type for use with +// CronJobStatusApplyConfiguration constructs a declarative configuration of the CronJobStatus type for use with // apply. func CronJobStatus() *CronJobStatusApplyConfiguration { return &CronJobStatusApplyConfiguration{} diff --git a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/examplestruct.go b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/examplestruct.go index 33eaf6cfd..70950b1b7 100644 --- a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/examplestruct.go +++ b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/examplestruct.go @@ -1,14 +1,14 @@ -// Code generated by applyconfiguration-gen. DO NOT EDIT. +// Code generated by applyconfigurations. DO NOT EDIT. package cronjob -// ExampleStructApplyConfiguration represents an declarative configuration of the ExampleStruct type for use +// ExampleStructApplyConfiguration represents a declarative configuration of the ExampleStruct type for use // with apply. type ExampleStructApplyConfiguration struct { ExampleField *string `json:"string,omitempty"` } -// ExampleStructApplyConfiguration constructs an declarative configuration of the ExampleStruct type for use with +// ExampleStructApplyConfiguration constructs a declarative configuration of the ExampleStruct type for use with // apply. func ExampleStruct() *ExampleStructApplyConfiguration { return &ExampleStructApplyConfiguration{} diff --git a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/utils.go b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/utils.go index ae82c00a1..a56703e4b 100644 --- a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/utils.go +++ b/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/utils.go @@ -1,10 +1,13 @@ -// Code generated by applyconfiguration-gen. DO NOT EDIT. +// Code generated by applyconfigurations. DO NOT EDIT. package testapplyconfiguration import ( + runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" + testing "k8s.io/client-go/testing" cronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob" + internal "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/internal" testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob" ) @@ -27,3 +30,7 @@ func ForKind(kind schema.GroupVersionKind) interface{} { } return nil } + +func NewTypeConverter(scheme *runtime.Scheme) *testing.TypeConverter { + return &testing.TypeConverter{Scheme: scheme, TypeResolver: internal.Parser()} +} From 9aec9040b155cdc9b91f80e5b295d73df4352668 Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Fri, 28 Feb 2025 13:30:39 +0000 Subject: [PATCH 13/22] Ignore testdata for the purposes of go generate --- .../applyconfiguration_integration_test.go | 6 ++++++ .../testdata/cronjob/applyconfiguration/utils.go | 1 + 2 files changed, 7 insertions(+) diff --git a/pkg/applyconfigurations/applyconfiguration_integration_test.go b/pkg/applyconfigurations/applyconfiguration_integration_test.go index d097bd572..acccb417e 100644 --- a/pkg/applyconfigurations/applyconfiguration_integration_test.go +++ b/pkg/applyconfigurations/applyconfiguration_integration_test.go @@ -34,6 +34,8 @@ import ( "sigs.k8s.io/controller-tools/pkg/markers" ) +const ignoreAutogenerated = "//go:build !ignore_autogenerated\n" + type outputToMap map[string]*outputFile // Open implements genall.OutputRule. @@ -145,6 +147,10 @@ var _ = Describe("ApplyConfiguration generation from API types", func() { Expect(masterFileNames.SymmetricDifference(outputFileNames).UnsortedList()).To(BeEmpty(), "Generated files should match the checked in files") for name, content := range filesInMaster { + if strings.HasPrefix(string(content), ignoreAutogenerated) { + content = []byte(strings.TrimPrefix(string(content), ignoreAutogenerated)) + } + Expect(string(filesInOutput[name])).To(Equal(string(content)), "Generated files should match the checked in files, diff found in %s", name) } }) diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go index a56703e4b..9737baf2b 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go +++ b/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // Code generated by applyconfigurations. DO NOT EDIT. package testapplyconfiguration From 8a7c5ece515106e408b7ffa03e8d63c1c797f61a Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Fri, 21 Mar 2025 12:14:47 +0000 Subject: [PATCH 14/22] Rename apply command to applyconfiguration --- cmd/controller-gen/main.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/controller-gen/main.go b/cmd/controller-gen/main.go index 5204538dc..68bcbb722 100644 --- a/cmd/controller-gen/main.go +++ b/cmd/controller-gen/main.go @@ -50,12 +50,12 @@ var ( // each turns into a command line option, // and has options for output forms. allGenerators = map[string]genall.Generator{ - "crd": crd.Generator{}, - "rbac": rbac.Generator{}, - "object": deepcopy.Generator{}, - "apply": applyconfigurations.Generator{}, - "webhook": webhook.Generator{}, - "schemapatch": schemapatcher.Generator{}, + "crd": crd.Generator{}, + "rbac": rbac.Generator{}, + "object": deepcopy.Generator{}, + "applyconfiguration": applyconfigurations.Generator{}, + "webhook": webhook.Generator{}, + "schemapatch": schemapatcher.Generator{}, } // allOutputRules defines the list of all known output rules, giving @@ -153,7 +153,7 @@ func main() { # Generate applyconfigurations for CRDs for use with Server Side Apply. They will be placed # into a "applyconfiguration/" subdirectory - controller-gen apply paths=./apis/... + controller-gen applyconfiguration paths=./apis/... `, RunE: func(c *cobra.Command, rawOpts []string) error { // print version if asked for it From c343c7d7fbb155ecab7c7c8d2c49199de70cf110 Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Fri, 21 Mar 2025 12:18:19 +0000 Subject: [PATCH 15/22] Rename package to applyconfiguration --- cmd/controller-gen/main.go | 4 ++-- .../applyconfiguration_integration_test.go | 2 +- .../applyconfiguration_suite_test.go | 2 +- pkg/{applyconfigurations => applyconfiguration}/doc.go | 2 +- pkg/{applyconfigurations => applyconfiguration}/gen.go | 2 +- .../cronjob/applyconfiguration/internal/internal.go | 2 +- .../testdata/cronjob/associativetype.go | 2 +- .../applyconfiguration}/testdata/cronjob/cronjob.go | 2 +- .../applyconfiguration}/testdata/cronjob/cronjobspec.go | 4 ++-- .../applyconfiguration/testdata/cronjob/cronjobstatus.go | 2 +- .../applyconfiguration/testdata/cronjob/examplestruct.go | 2 +- .../testdata/cronjob/applyconfiguration/utils.go | 8 ++++---- .../testdata/cronjob/cronjob_types.go | 0 .../testdata/cronjob/go.mod | 2 +- .../testdata/cronjob/go.sum | 0 .../testdata/cronjob/groupversion_info.go | 0 .../cronjob/testapplyconfiguration/internal/internal.go | 2 +- .../testdata/cronjob/associativetype.go | 2 +- .../testapplyconfiguration}/testdata/cronjob/cronjob.go | 2 +- .../testdata/cronjob/cronjobspec.go | 4 ++-- .../testdata/cronjob/cronjobstatus.go | 2 +- .../testdata/cronjob/examplestruct.go | 2 +- .../testdata/cronjob/testapplyconfiguration/utils.go | 8 ++++---- .../zz_generated.markerhelp.go | 2 +- 24 files changed, 30 insertions(+), 30 deletions(-) rename pkg/{applyconfigurations => applyconfiguration}/applyconfiguration_integration_test.go (99%) rename pkg/{applyconfigurations => applyconfiguration}/applyconfiguration_suite_test.go (96%) rename pkg/{applyconfigurations => applyconfiguration}/doc.go (95%) rename pkg/{applyconfigurations => applyconfiguration}/gen.go (99%) rename pkg/{applyconfigurations => applyconfiguration}/testdata/cronjob/applyconfiguration/internal/internal.go (94%) rename pkg/{applyconfigurations/testdata/cronjob/testapplyconfiguration => applyconfiguration/testdata/cronjob/applyconfiguration}/testdata/cronjob/associativetype.go (96%) rename pkg/{applyconfigurations/testdata/cronjob/testapplyconfiguration => applyconfiguration/testdata/cronjob/applyconfiguration}/testdata/cronjob/cronjob.go (99%) rename pkg/{applyconfigurations/testdata/cronjob/testapplyconfiguration => applyconfiguration/testdata/cronjob/applyconfiguration}/testdata/cronjob/cronjobspec.go (99%) rename pkg/{applyconfigurations => applyconfiguration}/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go (97%) rename pkg/{applyconfigurations => applyconfiguration}/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go (94%) rename pkg/{applyconfigurations => applyconfiguration}/testdata/cronjob/applyconfiguration/utils.go (80%) rename pkg/{applyconfigurations => applyconfiguration}/testdata/cronjob/cronjob_types.go (100%) rename pkg/{applyconfigurations => applyconfiguration}/testdata/cronjob/go.mod (96%) rename pkg/{applyconfigurations => applyconfiguration}/testdata/cronjob/go.sum (100%) rename pkg/{applyconfigurations => applyconfiguration}/testdata/cronjob/groupversion_info.go (100%) rename pkg/{applyconfigurations => applyconfiguration}/testdata/cronjob/testapplyconfiguration/internal/internal.go (94%) rename pkg/{applyconfigurations/testdata/cronjob/applyconfiguration => applyconfiguration/testdata/cronjob/testapplyconfiguration}/testdata/cronjob/associativetype.go (96%) rename pkg/{applyconfigurations/testdata/cronjob/applyconfiguration => applyconfiguration/testdata/cronjob/testapplyconfiguration}/testdata/cronjob/cronjob.go (99%) rename pkg/{applyconfigurations/testdata/cronjob/applyconfiguration => applyconfiguration/testdata/cronjob/testapplyconfiguration}/testdata/cronjob/cronjobspec.go (99%) rename pkg/{applyconfigurations => applyconfiguration}/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobstatus.go (97%) rename pkg/{applyconfigurations => applyconfiguration}/testdata/cronjob/testapplyconfiguration/testdata/cronjob/examplestruct.go (94%) rename pkg/{applyconfigurations => applyconfiguration}/testdata/cronjob/testapplyconfiguration/utils.go (80%) rename pkg/{applyconfigurations => applyconfiguration}/zz_generated.markerhelp.go (97%) diff --git a/cmd/controller-gen/main.go b/cmd/controller-gen/main.go index 68bcbb722..f880b04ce 100644 --- a/cmd/controller-gen/main.go +++ b/cmd/controller-gen/main.go @@ -25,7 +25,7 @@ import ( "github.com/spf13/cobra" - "sigs.k8s.io/controller-tools/pkg/applyconfigurations" + "sigs.k8s.io/controller-tools/pkg/applyconfiguration" "sigs.k8s.io/controller-tools/pkg/crd" "sigs.k8s.io/controller-tools/pkg/deepcopy" "sigs.k8s.io/controller-tools/pkg/genall" @@ -53,7 +53,7 @@ var ( "crd": crd.Generator{}, "rbac": rbac.Generator{}, "object": deepcopy.Generator{}, - "applyconfiguration": applyconfigurations.Generator{}, + "applyconfiguration": applyconfiguration.Generator{}, "webhook": webhook.Generator{}, "schemapatch": schemapatcher.Generator{}, } diff --git a/pkg/applyconfigurations/applyconfiguration_integration_test.go b/pkg/applyconfiguration/applyconfiguration_integration_test.go similarity index 99% rename from pkg/applyconfigurations/applyconfiguration_integration_test.go rename to pkg/applyconfiguration/applyconfiguration_integration_test.go index acccb417e..fd25034e2 100644 --- a/pkg/applyconfigurations/applyconfiguration_integration_test.go +++ b/pkg/applyconfiguration/applyconfiguration_integration_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package applyconfigurations +package applyconfiguration import ( "fmt" diff --git a/pkg/applyconfigurations/applyconfiguration_suite_test.go b/pkg/applyconfiguration/applyconfiguration_suite_test.go similarity index 96% rename from pkg/applyconfigurations/applyconfiguration_suite_test.go rename to pkg/applyconfiguration/applyconfiguration_suite_test.go index 0f4409d56..d684590cf 100644 --- a/pkg/applyconfigurations/applyconfiguration_suite_test.go +++ b/pkg/applyconfiguration/applyconfiguration_suite_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package applyconfigurations +package applyconfiguration import ( "testing" diff --git a/pkg/applyconfigurations/doc.go b/pkg/applyconfiguration/doc.go similarity index 95% rename from pkg/applyconfigurations/doc.go rename to pkg/applyconfiguration/doc.go index 82c2c10f5..de9f9206a 100644 --- a/pkg/applyconfigurations/doc.go +++ b/pkg/applyconfiguration/doc.go @@ -15,4 +15,4 @@ limitations under the License. */ // Package applyconfigurations generates types for constructing declarative apply configurations. -package applyconfigurations +package applyconfiguration diff --git a/pkg/applyconfigurations/gen.go b/pkg/applyconfiguration/gen.go similarity index 99% rename from pkg/applyconfigurations/gen.go rename to pkg/applyconfiguration/gen.go index 5be4562ce..55a79dad1 100644 --- a/pkg/applyconfigurations/gen.go +++ b/pkg/applyconfiguration/gen.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package applyconfigurations +package applyconfiguration import ( "fmt" diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/internal/internal.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/internal/internal.go similarity index 94% rename from pkg/applyconfigurations/testdata/cronjob/applyconfiguration/internal/internal.go rename to pkg/applyconfiguration/testdata/cronjob/applyconfiguration/internal/internal.go index bdb4d8566..a0c4c4ecc 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/internal/internal.go +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/internal/internal.go @@ -1,4 +1,4 @@ -// Code generated by applyconfigurations. DO NOT EDIT. +// Code generated by applyconfiguration. DO NOT EDIT. package internal diff --git a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/associativetype.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/associativetype.go similarity index 96% rename from pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/associativetype.go rename to pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/associativetype.go index 9247c255f..b3dd678b0 100644 --- a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/associativetype.go +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/associativetype.go @@ -1,4 +1,4 @@ -// Code generated by applyconfigurations. DO NOT EDIT. +// Code generated by applyconfiguration. DO NOT EDIT. package cronjob diff --git a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjob.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjob.go similarity index 99% rename from pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjob.go rename to pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjob.go index 441f9ea80..aa223f677 100644 --- a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjob.go +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjob.go @@ -1,4 +1,4 @@ -// Code generated by applyconfigurations. DO NOT EDIT. +// Code generated by applyconfiguration. DO NOT EDIT. package cronjob diff --git a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobspec.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go similarity index 99% rename from pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobspec.go rename to pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go index e62b332af..245f6b5e0 100644 --- a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobspec.go +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go @@ -1,11 +1,11 @@ -// Code generated by applyconfigurations. DO NOT EDIT. +// Code generated by applyconfiguration. DO NOT EDIT. package cronjob import ( v1beta1 "k8s.io/api/batch/v1beta1" v1 "k8s.io/api/core/v1" - testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob" + testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob" ) // CronJobSpecApplyConfiguration represents a declarative configuration of the CronJobSpec type for use diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go similarity index 97% rename from pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go rename to pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go index f696bc514..8023eeab5 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go @@ -1,4 +1,4 @@ -// Code generated by applyconfigurations. DO NOT EDIT. +// Code generated by applyconfiguration. DO NOT EDIT. package cronjob diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go similarity index 94% rename from pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go rename to pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go index 70950b1b7..76e4206bb 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go @@ -1,4 +1,4 @@ -// Code generated by applyconfigurations. DO NOT EDIT. +// Code generated by applyconfiguration. DO NOT EDIT. package cronjob diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/utils.go similarity index 80% rename from pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go rename to pkg/applyconfiguration/testdata/cronjob/applyconfiguration/utils.go index 9737baf2b..fe009cfb8 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/utils.go +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/utils.go @@ -1,5 +1,5 @@ //go:build !ignore_autogenerated -// Code generated by applyconfigurations. DO NOT EDIT. +// Code generated by applyconfiguration. DO NOT EDIT. package testapplyconfiguration @@ -7,9 +7,9 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" testing "k8s.io/client-go/testing" - cronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob" - internal "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/internal" - testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob" + cronjob "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob" + internal "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/internal" + testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob" ) // ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no diff --git a/pkg/applyconfigurations/testdata/cronjob/cronjob_types.go b/pkg/applyconfiguration/testdata/cronjob/cronjob_types.go similarity index 100% rename from pkg/applyconfigurations/testdata/cronjob/cronjob_types.go rename to pkg/applyconfiguration/testdata/cronjob/cronjob_types.go diff --git a/pkg/applyconfigurations/testdata/cronjob/go.mod b/pkg/applyconfiguration/testdata/cronjob/go.mod similarity index 96% rename from pkg/applyconfigurations/testdata/cronjob/go.mod rename to pkg/applyconfiguration/testdata/cronjob/go.mod index dc9881bea..dcf4d802b 100644 --- a/pkg/applyconfigurations/testdata/cronjob/go.mod +++ b/pkg/applyconfiguration/testdata/cronjob/go.mod @@ -1,4 +1,4 @@ -module sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob +module sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob go 1.23.0 diff --git a/pkg/applyconfigurations/testdata/cronjob/go.sum b/pkg/applyconfiguration/testdata/cronjob/go.sum similarity index 100% rename from pkg/applyconfigurations/testdata/cronjob/go.sum rename to pkg/applyconfiguration/testdata/cronjob/go.sum diff --git a/pkg/applyconfigurations/testdata/cronjob/groupversion_info.go b/pkg/applyconfiguration/testdata/cronjob/groupversion_info.go similarity index 100% rename from pkg/applyconfigurations/testdata/cronjob/groupversion_info.go rename to pkg/applyconfiguration/testdata/cronjob/groupversion_info.go diff --git a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/internal/internal.go b/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/internal/internal.go similarity index 94% rename from pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/internal/internal.go rename to pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/internal/internal.go index bdb4d8566..a0c4c4ecc 100644 --- a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/internal/internal.go +++ b/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/internal/internal.go @@ -1,4 +1,4 @@ -// Code generated by applyconfigurations. DO NOT EDIT. +// Code generated by applyconfiguration. DO NOT EDIT. package internal diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/associativetype.go b/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/associativetype.go similarity index 96% rename from pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/associativetype.go rename to pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/associativetype.go index 9247c255f..b3dd678b0 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/associativetype.go +++ b/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/associativetype.go @@ -1,4 +1,4 @@ -// Code generated by applyconfigurations. DO NOT EDIT. +// Code generated by applyconfiguration. DO NOT EDIT. package cronjob diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjob.go b/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjob.go similarity index 99% rename from pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjob.go rename to pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjob.go index 441f9ea80..aa223f677 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjob.go +++ b/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjob.go @@ -1,4 +1,4 @@ -// Code generated by applyconfigurations. DO NOT EDIT. +// Code generated by applyconfiguration. DO NOT EDIT. package cronjob diff --git a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go b/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobspec.go similarity index 99% rename from pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go rename to pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobspec.go index e62b332af..245f6b5e0 100644 --- a/pkg/applyconfigurations/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go +++ b/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobspec.go @@ -1,11 +1,11 @@ -// Code generated by applyconfigurations. DO NOT EDIT. +// Code generated by applyconfiguration. DO NOT EDIT. package cronjob import ( v1beta1 "k8s.io/api/batch/v1beta1" v1 "k8s.io/api/core/v1" - testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob" + testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob" ) // CronJobSpecApplyConfiguration represents a declarative configuration of the CronJobSpec type for use diff --git a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobstatus.go b/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobstatus.go similarity index 97% rename from pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobstatus.go rename to pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobstatus.go index f696bc514..8023eeab5 100644 --- a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobstatus.go +++ b/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobstatus.go @@ -1,4 +1,4 @@ -// Code generated by applyconfigurations. DO NOT EDIT. +// Code generated by applyconfiguration. DO NOT EDIT. package cronjob diff --git a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/examplestruct.go b/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/examplestruct.go similarity index 94% rename from pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/examplestruct.go rename to pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/examplestruct.go index 70950b1b7..76e4206bb 100644 --- a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob/examplestruct.go +++ b/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/examplestruct.go @@ -1,4 +1,4 @@ -// Code generated by applyconfigurations. DO NOT EDIT. +// Code generated by applyconfiguration. DO NOT EDIT. package cronjob diff --git a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/utils.go b/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/utils.go similarity index 80% rename from pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/utils.go rename to pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/utils.go index a56703e4b..8746c6915 100644 --- a/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/utils.go +++ b/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/utils.go @@ -1,4 +1,4 @@ -// Code generated by applyconfigurations. DO NOT EDIT. +// Code generated by applyconfiguration. DO NOT EDIT. package testapplyconfiguration @@ -6,9 +6,9 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" testing "k8s.io/client-go/testing" - cronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob" - internal "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/internal" - testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfigurations/testdata/cronjob/testapplyconfiguration/testdata/cronjob" + cronjob "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob" + internal "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/internal" + testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob" ) // ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no diff --git a/pkg/applyconfigurations/zz_generated.markerhelp.go b/pkg/applyconfiguration/zz_generated.markerhelp.go similarity index 97% rename from pkg/applyconfigurations/zz_generated.markerhelp.go rename to pkg/applyconfiguration/zz_generated.markerhelp.go index e21bbf34a..6e0a0af27 100644 --- a/pkg/applyconfigurations/zz_generated.markerhelp.go +++ b/pkg/applyconfiguration/zz_generated.markerhelp.go @@ -18,7 +18,7 @@ limitations under the License. // Code generated by helpgen. DO NOT EDIT. -package applyconfigurations +package applyconfiguration import ( "sigs.k8s.io/controller-tools/pkg/markers" From 326a20eb1d0db55f29d56fb1513db37706a73cdd Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Fri, 21 Mar 2025 14:00:05 +0000 Subject: [PATCH 16/22] Rework tests to use temporary directory for output files --- .../applyconfiguration_integration_test.go | 128 +++++++---- .../cronjob/applyconfiguration/utils.go | 7 +- .../testdata/cronjob/groupversion_info.go | 2 +- .../internal/internal.go | 46 ---- .../testdata/cronjob/associativetype.go | 41 ---- .../testdata/cronjob/cronjob.go | 209 ------------------ .../testdata/cronjob/cronjobspec.go | 204 ----------------- .../testdata/cronjob/cronjobstatus.go | 48 ---- .../testdata/cronjob/examplestruct.go | 23 -- .../cronjob/testapplyconfiguration/utils.go | 36 --- 10 files changed, 95 insertions(+), 649 deletions(-) delete mode 100644 pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/internal/internal.go delete mode 100644 pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/associativetype.go delete mode 100644 pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjob.go delete mode 100644 pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobspec.go delete mode 100644 pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobstatus.go delete mode 100644 pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/examplestruct.go delete mode 100644 pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/utils.go diff --git a/pkg/applyconfiguration/applyconfiguration_integration_test.go b/pkg/applyconfiguration/applyconfiguration_integration_test.go index fd25034e2..666a5b570 100644 --- a/pkg/applyconfiguration/applyconfiguration_integration_test.go +++ b/pkg/applyconfiguration/applyconfiguration_integration_test.go @@ -25,6 +25,7 @@ import ( "strings" . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/extensions/table" . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/util/sets" @@ -34,7 +35,10 @@ import ( "sigs.k8s.io/controller-tools/pkg/markers" ) -const ignoreAutogenerated = "//go:build !ignore_autogenerated\n" +const ( + cronjobDir = "./testdata/cronjob" + applyConfigurationDir = "applyconfiguration" +) type outputToMap map[string]*outputFile @@ -60,46 +64,70 @@ func (o *outputFile) Close() error { } var _ = Describe("ApplyConfiguration generation from API types", func() { - outputPath := "testapplyconfiguration" - masterPath := "applyconfiguration" - By("resetting the test directory") - // not using after each to allow for inspection of failed tests + var originalCWD string + BeforeEach(func() { - Expect(os.RemoveAll(filepath.Join(".", outputPath))).To(Succeed()) + var tmpDir string + + By("Setting up a temporary directory", func() { + var err error + tmpDir, err = os.MkdirTemp("", "applyconfiguration-integration-test") + Expect(err).NotTo(HaveOccurred(), "Should be able to create a temporary directory") + + // Copy the testdata directory, but removed the generated files. + Expect(os.CopyFS(tmpDir, os.DirFS(cronjobDir))).To(Succeed(), "Should be able to copy source files") + Expect(os.RemoveAll(filepath.Join(tmpDir, applyConfigurationDir))).To(Succeed(), "Should be able to remove generated file from temp directory") + }) + + By("Switching into testdata to appease go modules", func() { + cwd, err := os.Getwd() + Expect(err).NotTo(HaveOccurred()) + + originalCWD = cwd + + Expect(os.Chdir(tmpDir)).To(Succeed()) // go modules are directory-sensitive + }) + + By(fmt.Sprintf("Completed set up in %s", tmpDir)) }) - It("should be able to verify generated ApplyConfiguration types for the CronJob schema", func() { - By("switching into testdata to appease go modules") - cwd, err := os.Getwd() - Expect(err).NotTo(HaveOccurred()) - Expect(os.Chdir("./testdata/cronjob")).To(Succeed()) // go modules are directory-sensitive - defer func() { Expect(os.Chdir(cwd)).To(Succeed()) }() + AfterEach(func() { + // Reset the working directory + Expect(os.Chdir(originalCWD)).To(Succeed()) + }) + + DescribeTable("should be able to verify generated ApplyConfiguration types for the CronJob schema", func(outputPackage string) { + Expect(replaceOutputPkgMarker(".", outputPackage)).To(Succeed()) + + // The output is used to capture the generated CRD file. + // The output of the applyconfiguration cannot be generated to memory, gengo handles all of the writing to disk directly. output := make(outputToMap) - By("initializing the runtime") + By("Initializing the runtime") optionsRegistry := &markers.Registry{} Expect(optionsRegistry.Register(markers.Must(markers.MakeDefinition("crd", markers.DescribesPackage, crd.Generator{})))).To(Succeed()) - // Add the applyconfigurations generator but set it to verify only. - // This allows us to check if there's a diff between the checked in generated data and what it would generate now. - Expect(optionsRegistry.Register(markers.Must(markers.MakeDefinition("apply", markers.DescribesPackage, Generator{})))).To(Succeed()) + Expect(optionsRegistry.Register(markers.Must(markers.MakeDefinition("applyconfiguration", markers.DescribesPackage, Generator{})))).To(Succeed()) + rt, err := genall.FromOptions(optionsRegistry, []string{ "crd", // Run another generator first to make sure they don't interfere; see also: the comment on cronjob_types.go:UntypedBlob - "apply", + "applyconfiguration", }) Expect(err).NotTo(HaveOccurred()) + rt.OutputRules = genall.OutputRules{Default: output} - cronJobFS := os.DirFS(".") + originalFS := os.DirFS(filepath.Join(originalCWD, cronjobDir)) + tmpFS := os.DirFS(".") - By("running the generator and checking for errors") + By("Running the generator") hadErrs := rt.Run() - By("checking for errors") + By("Checking for generation errors") Expect(hadErrs).To(BeFalse(), "Generator should run without errors") - filesInMaster := make(map[string][]byte) - masterFileNames := sets.New[string]() - Expect(fs.WalkDir(cronJobFS, masterPath, func(path string, d fs.DirEntry, err error) error { + filesInOriginal := make(map[string][]byte) + originalFileNames := sets.New[string]() + Expect(fs.WalkDir(originalFS, applyConfigurationDir, func(path string, d fs.DirEntry, err error) error { if err != nil { return err } @@ -108,21 +136,21 @@ var _ = Describe("ApplyConfiguration generation from API types", func() { return nil } - data, err := os.ReadFile(path) + data, err := os.ReadFile(filepath.Join(originalCWD, cronjobDir, path)) if err != nil { return fmt.Errorf("error reading file %s: %w", path, err) } // Record the path without the path prefix for comparison later. - path = strings.TrimPrefix(path, masterPath+"/") - masterFileNames.Insert(path) - filesInMaster[path] = data + path = strings.TrimPrefix(path, applyConfigurationDir+"/") + originalFileNames.Insert(path) + filesInOriginal[path] = data return nil })).To(Succeed()) filesInOutput := make(map[string][]byte) outputFileNames := sets.New[string]() - Expect(fs.WalkDir(cronJobFS, outputPath, func(path string, d fs.DirEntry, err error) error { + Expect(fs.WalkDir(tmpFS, outputPackage, func(path string, d fs.DirEntry, err error) error { if err != nil { return err } @@ -137,21 +165,47 @@ var _ = Describe("ApplyConfiguration generation from API types", func() { } // Record the path without the path prefix for comparison later. - path = strings.TrimPrefix(path, outputPath+"/") + path = strings.TrimPrefix(path, outputPackage+"/") outputFileNames.Insert(path) filesInOutput[path] = data return nil })).To(Succeed()) - // Every file should be in both sets, check for files not in both sets. - Expect(masterFileNames.SymmetricDifference(outputFileNames).UnsortedList()).To(BeEmpty(), "Generated files should match the checked in files") + // // Every file should be in both sets, check for files not in both sets. + Expect(outputFileNames.UnsortedList()).To(ConsistOf(originalFileNames.UnsortedList()), "Generated files should match the checked in files") - for name, content := range filesInMaster { - if strings.HasPrefix(string(content), ignoreAutogenerated) { - content = []byte(strings.TrimPrefix(string(content), ignoreAutogenerated)) - } + for name, content := range filesInOriginal { + // Make sure the package string is correct for the newly generated content. + content = []byte(strings.Replace(string(content), "package applyconfiguration", fmt.Sprintf("package %s", outputPackage), 1)) + + // Make sure the import paths are correct for the newly generated content. + content = []byte(strings.ReplaceAll(string(content), "testdata/cronjob/applyconfiguration", fmt.Sprintf("testdata/cronjob/%s", outputPackage))) - Expect(string(filesInOutput[name])).To(Equal(string(content)), "Generated files should match the checked in files, diff found in %s", name) + Expect(string(filesInOutput[name])).To(BeComparableTo(string(content)), "Generated files should match the checked in files, diff found in %s", name) } - }) + }, + Entry("with the default applyconfiguration output package", "applyconfiguration"), + Entry("with the an alternative output package", "other"), + ) }) + +func replaceOutputPkgMarker(dir string, newOutputPackage string) error { + f, err := os.Open(filepath.Join(dir, "groupversion_info.go")) + if err != nil { + return fmt.Errorf("error opening groupversion_info.go: %w", err) + } + defer f.Close() + + data, err := io.ReadAll(f) + if err != nil { + return fmt.Errorf("error reading groupversion_info.go: %w", err) + } + + newData := strings.Replace(string(data), "// +kubebuilder:ac:output:package=\"applyconfiguration\"", fmt.Sprintf("// +kubebuilder:ac:output:package=\"%s\"", newOutputPackage), 1) + + if err := os.WriteFile(filepath.Join(dir, "groupversion_info.go"), []byte(newData), 0644); err != nil { + return fmt.Errorf("error writing groupversion_info.go: %w", err) + } + + return nil +} diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/utils.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/utils.go index fe009cfb8..b97b36bb2 100644 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/utils.go +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/utils.go @@ -1,15 +1,14 @@ -//go:build !ignore_autogenerated // Code generated by applyconfiguration. DO NOT EDIT. -package testapplyconfiguration +package applyconfiguration import ( runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" testing "k8s.io/client-go/testing" cronjob "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob" - internal "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/internal" - testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob" + internal "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/internal" + testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob" ) // ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no diff --git a/pkg/applyconfiguration/testdata/cronjob/groupversion_info.go b/pkg/applyconfiguration/testdata/cronjob/groupversion_info.go index c8bbdbb82..f3e8b29e3 100644 --- a/pkg/applyconfiguration/testdata/cronjob/groupversion_info.go +++ b/pkg/applyconfiguration/testdata/cronjob/groupversion_info.go @@ -17,7 +17,7 @@ limitations under the License. // +groupName=testdata.kubebuilder.io // +versionName=v1 // +kubebuilder:ac:generate=true -// +kubebuilder:ac:output:package="testapplyconfiguration" +// +kubebuilder:ac:output:package="applyconfiguration" package testdata import ( diff --git a/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/internal/internal.go b/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/internal/internal.go deleted file mode 100644 index a0c4c4ecc..000000000 --- a/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/internal/internal.go +++ /dev/null @@ -1,46 +0,0 @@ -// Code generated by applyconfiguration. DO NOT EDIT. - -package internal - -import ( - fmt "fmt" - sync "sync" - - typed "sigs.k8s.io/structured-merge-diff/v4/typed" -) - -func Parser() *typed.Parser { - parserOnce.Do(func() { - var err error - parser, err = typed.NewParser(schemaYAML) - if err != nil { - panic(fmt.Sprintf("Failed to parse schema: %v", err)) - } - }) - return parser -} - -var parserOnce sync.Once -var parser *typed.Parser -var schemaYAML = typed.YAMLObject(`types: -- name: __untyped_atomic_ - scalar: untyped - list: - elementType: - namedType: __untyped_atomic_ - elementRelationship: atomic - map: - elementType: - namedType: __untyped_atomic_ - elementRelationship: atomic -- name: __untyped_deduced_ - scalar: untyped - list: - elementType: - namedType: __untyped_atomic_ - elementRelationship: atomic - map: - elementType: - namedType: __untyped_deduced_ - elementRelationship: separable -`) diff --git a/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/associativetype.go b/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/associativetype.go deleted file mode 100644 index b3dd678b0..000000000 --- a/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/associativetype.go +++ /dev/null @@ -1,41 +0,0 @@ -// Code generated by applyconfiguration. DO NOT EDIT. - -package cronjob - -// AssociativeTypeApplyConfiguration represents a declarative configuration of the AssociativeType type for use -// with apply. -type AssociativeTypeApplyConfiguration struct { - Name *string `json:"name,omitempty"` - Secondary *int `json:"secondary,omitempty"` - Foo *string `json:"foo,omitempty"` -} - -// AssociativeTypeApplyConfiguration constructs a declarative configuration of the AssociativeType type for use with -// apply. -func AssociativeType() *AssociativeTypeApplyConfiguration { - return &AssociativeTypeApplyConfiguration{} -} - -// WithName sets the Name field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the Name field is set to the value of the last call. -func (b *AssociativeTypeApplyConfiguration) WithName(value string) *AssociativeTypeApplyConfiguration { - b.Name = &value - return b -} - -// WithSecondary sets the Secondary field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the Secondary field is set to the value of the last call. -func (b *AssociativeTypeApplyConfiguration) WithSecondary(value int) *AssociativeTypeApplyConfiguration { - b.Secondary = &value - return b -} - -// WithFoo sets the Foo field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the Foo field is set to the value of the last call. -func (b *AssociativeTypeApplyConfiguration) WithFoo(value string) *AssociativeTypeApplyConfiguration { - b.Foo = &value - return b -} diff --git a/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjob.go b/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjob.go deleted file mode 100644 index aa223f677..000000000 --- a/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjob.go +++ /dev/null @@ -1,209 +0,0 @@ -// Code generated by applyconfiguration. DO NOT EDIT. - -package cronjob - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - v1 "k8s.io/client-go/applyconfigurations/meta/v1" -) - -// CronJobApplyConfiguration represents a declarative configuration of the CronJob type for use -// with apply. -type CronJobApplyConfiguration struct { - v1.TypeMetaApplyConfiguration `json:",inline"` - *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` - Spec *CronJobSpecApplyConfiguration `json:"spec,omitempty"` - Status *CronJobStatusApplyConfiguration `json:"status,omitempty"` -} - -// CronJob constructs a declarative configuration of the CronJob type for use with -// apply. -func CronJob(name, namespace string) *CronJobApplyConfiguration { - b := &CronJobApplyConfiguration{} - b.WithName(name) - b.WithNamespace(namespace) - b.WithKind("CronJob") - b.WithAPIVersion("testdata/cronjob") - return b -} - -// WithKind sets the Kind field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the Kind field is set to the value of the last call. -func (b *CronJobApplyConfiguration) WithKind(value string) *CronJobApplyConfiguration { - b.TypeMetaApplyConfiguration.Kind = &value - return b -} - -// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the APIVersion field is set to the value of the last call. -func (b *CronJobApplyConfiguration) WithAPIVersion(value string) *CronJobApplyConfiguration { - b.TypeMetaApplyConfiguration.APIVersion = &value - return b -} - -// WithName sets the Name field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the Name field is set to the value of the last call. -func (b *CronJobApplyConfiguration) WithName(value string) *CronJobApplyConfiguration { - b.ensureObjectMetaApplyConfigurationExists() - b.ObjectMetaApplyConfiguration.Name = &value - return b -} - -// WithGenerateName sets the GenerateName field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the GenerateName field is set to the value of the last call. -func (b *CronJobApplyConfiguration) WithGenerateName(value string) *CronJobApplyConfiguration { - b.ensureObjectMetaApplyConfigurationExists() - b.ObjectMetaApplyConfiguration.GenerateName = &value - return b -} - -// WithNamespace sets the Namespace field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the Namespace field is set to the value of the last call. -func (b *CronJobApplyConfiguration) WithNamespace(value string) *CronJobApplyConfiguration { - b.ensureObjectMetaApplyConfigurationExists() - b.ObjectMetaApplyConfiguration.Namespace = &value - return b -} - -// WithUID sets the UID field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the UID field is set to the value of the last call. -func (b *CronJobApplyConfiguration) WithUID(value types.UID) *CronJobApplyConfiguration { - b.ensureObjectMetaApplyConfigurationExists() - b.ObjectMetaApplyConfiguration.UID = &value - return b -} - -// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the ResourceVersion field is set to the value of the last call. -func (b *CronJobApplyConfiguration) WithResourceVersion(value string) *CronJobApplyConfiguration { - b.ensureObjectMetaApplyConfigurationExists() - b.ObjectMetaApplyConfiguration.ResourceVersion = &value - return b -} - -// WithGeneration sets the Generation field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the Generation field is set to the value of the last call. -func (b *CronJobApplyConfiguration) WithGeneration(value int64) *CronJobApplyConfiguration { - b.ensureObjectMetaApplyConfigurationExists() - b.ObjectMetaApplyConfiguration.Generation = &value - return b -} - -// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the CreationTimestamp field is set to the value of the last call. -func (b *CronJobApplyConfiguration) WithCreationTimestamp(value metav1.Time) *CronJobApplyConfiguration { - b.ensureObjectMetaApplyConfigurationExists() - b.ObjectMetaApplyConfiguration.CreationTimestamp = &value - return b -} - -// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the DeletionTimestamp field is set to the value of the last call. -func (b *CronJobApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *CronJobApplyConfiguration { - b.ensureObjectMetaApplyConfigurationExists() - b.ObjectMetaApplyConfiguration.DeletionTimestamp = &value - return b -} - -// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. -func (b *CronJobApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *CronJobApplyConfiguration { - b.ensureObjectMetaApplyConfigurationExists() - b.ObjectMetaApplyConfiguration.DeletionGracePeriodSeconds = &value - return b -} - -// WithLabels puts the entries into the Labels field in the declarative configuration -// and returns the receiver, so that objects can be build by chaining "With" function invocations. -// If called multiple times, the entries provided by each call will be put on the Labels field, -// overwriting an existing map entries in Labels field with the same key. -func (b *CronJobApplyConfiguration) WithLabels(entries map[string]string) *CronJobApplyConfiguration { - b.ensureObjectMetaApplyConfigurationExists() - if b.ObjectMetaApplyConfiguration.Labels == nil && len(entries) > 0 { - b.ObjectMetaApplyConfiguration.Labels = make(map[string]string, len(entries)) - } - for k, v := range entries { - b.ObjectMetaApplyConfiguration.Labels[k] = v - } - return b -} - -// WithAnnotations puts the entries into the Annotations field in the declarative configuration -// and returns the receiver, so that objects can be build by chaining "With" function invocations. -// If called multiple times, the entries provided by each call will be put on the Annotations field, -// overwriting an existing map entries in Annotations field with the same key. -func (b *CronJobApplyConfiguration) WithAnnotations(entries map[string]string) *CronJobApplyConfiguration { - b.ensureObjectMetaApplyConfigurationExists() - if b.ObjectMetaApplyConfiguration.Annotations == nil && len(entries) > 0 { - b.ObjectMetaApplyConfiguration.Annotations = make(map[string]string, len(entries)) - } - for k, v := range entries { - b.ObjectMetaApplyConfiguration.Annotations[k] = v - } - return b -} - -// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration -// and returns the receiver, so that objects can be build by chaining "With" function invocations. -// If called multiple times, values provided by each call will be appended to the OwnerReferences field. -func (b *CronJobApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *CronJobApplyConfiguration { - b.ensureObjectMetaApplyConfigurationExists() - for i := range values { - if values[i] == nil { - panic("nil value passed to WithOwnerReferences") - } - b.ObjectMetaApplyConfiguration.OwnerReferences = append(b.ObjectMetaApplyConfiguration.OwnerReferences, *values[i]) - } - return b -} - -// WithFinalizers adds the given value to the Finalizers field in the declarative configuration -// and returns the receiver, so that objects can be build by chaining "With" function invocations. -// If called multiple times, values provided by each call will be appended to the Finalizers field. -func (b *CronJobApplyConfiguration) WithFinalizers(values ...string) *CronJobApplyConfiguration { - b.ensureObjectMetaApplyConfigurationExists() - for i := range values { - b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i]) - } - return b -} - -func (b *CronJobApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { - if b.ObjectMetaApplyConfiguration == nil { - b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} - } -} - -// WithSpec sets the Spec field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the Spec field is set to the value of the last call. -func (b *CronJobApplyConfiguration) WithSpec(value *CronJobSpecApplyConfiguration) *CronJobApplyConfiguration { - b.Spec = value - return b -} - -// WithStatus sets the Status field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the Status field is set to the value of the last call. -func (b *CronJobApplyConfiguration) WithStatus(value *CronJobStatusApplyConfiguration) *CronJobApplyConfiguration { - b.Status = value - return b -} - -// GetName retrieves the value of the Name field in the declarative configuration. -func (b *CronJobApplyConfiguration) GetName() *string { - b.ensureObjectMetaApplyConfigurationExists() - return b.ObjectMetaApplyConfiguration.Name -} diff --git a/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobspec.go b/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobspec.go deleted file mode 100644 index 245f6b5e0..000000000 --- a/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobspec.go +++ /dev/null @@ -1,204 +0,0 @@ -// Code generated by applyconfiguration. DO NOT EDIT. - -package cronjob - -import ( - v1beta1 "k8s.io/api/batch/v1beta1" - v1 "k8s.io/api/core/v1" - testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob" -) - -// CronJobSpecApplyConfiguration represents a declarative configuration of the CronJobSpec type for use -// with apply. -type CronJobSpecApplyConfiguration struct { - Schedule *string `json:"schedule,omitempty"` - StartingDeadlineSeconds *int64 `json:"startingDeadlineSeconds,omitempty"` - ConcurrencyPolicy *testdatacronjob.ConcurrencyPolicy `json:"concurrencyPolicy,omitempty"` - Suspend *bool `json:"suspend,omitempty"` - BinaryName []byte `json:"binaryName,omitempty"` - CanBeNull *string `json:"canBeNull,omitempty"` - JobTemplate *v1beta1.JobTemplateSpec `json:"jobTemplate,omitempty"` - SuccessfulJobsHistoryLimit *int32 `json:"successfulJobsHistoryLimit,omitempty"` - FailedJobsHistoryLimit *int32 `json:"failedJobsHistoryLimit,omitempty"` - StringSliceData map[string][]string `json:"stringSliceData,omitempty"` - PtrData map[string]*string `json:"ptrData,omitempty"` - Slice []string `json:"slice,omitempty"` - SlicePtr []*string `json:"slicePtr,omitempty"` - SliceStruct []*testdatacronjob.ExampleStruct `json:"sliceStruct,omitempty"` - BuiltInReference *v1.PodSpec `json:"builtInReference,omitempty"` - Int *int `json:"int,omitempty"` - AssociativeList []AssociativeTypeApplyConfiguration `json:"associativeList,omitempty"` -} - -// CronJobSpecApplyConfiguration constructs a declarative configuration of the CronJobSpec type for use with -// apply. -func CronJobSpec() *CronJobSpecApplyConfiguration { - return &CronJobSpecApplyConfiguration{} -} - -// WithSchedule sets the Schedule field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the Schedule field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithSchedule(value string) *CronJobSpecApplyConfiguration { - b.Schedule = &value - return b -} - -// WithStartingDeadlineSeconds sets the StartingDeadlineSeconds field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the StartingDeadlineSeconds field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithStartingDeadlineSeconds(value int64) *CronJobSpecApplyConfiguration { - b.StartingDeadlineSeconds = &value - return b -} - -// WithConcurrencyPolicy sets the ConcurrencyPolicy field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the ConcurrencyPolicy field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithConcurrencyPolicy(value testdatacronjob.ConcurrencyPolicy) *CronJobSpecApplyConfiguration { - b.ConcurrencyPolicy = &value - return b -} - -// WithSuspend sets the Suspend field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the Suspend field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithSuspend(value bool) *CronJobSpecApplyConfiguration { - b.Suspend = &value - return b -} - -// WithBinaryName adds the given value to the BinaryName field in the declarative configuration -// and returns the receiver, so that objects can be build by chaining "With" function invocations. -// If called multiple times, values provided by each call will be appended to the BinaryName field. -func (b *CronJobSpecApplyConfiguration) WithBinaryName(values ...byte) *CronJobSpecApplyConfiguration { - for i := range values { - b.BinaryName = append(b.BinaryName, values[i]) - } - return b -} - -// WithCanBeNull sets the CanBeNull field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the CanBeNull field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithCanBeNull(value string) *CronJobSpecApplyConfiguration { - b.CanBeNull = &value - return b -} - -// WithJobTemplate sets the JobTemplate field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the JobTemplate field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithJobTemplate(value v1beta1.JobTemplateSpec) *CronJobSpecApplyConfiguration { - b.JobTemplate = &value - return b -} - -// WithSuccessfulJobsHistoryLimit sets the SuccessfulJobsHistoryLimit field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the SuccessfulJobsHistoryLimit field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithSuccessfulJobsHistoryLimit(value int32) *CronJobSpecApplyConfiguration { - b.SuccessfulJobsHistoryLimit = &value - return b -} - -// WithFailedJobsHistoryLimit sets the FailedJobsHistoryLimit field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the FailedJobsHistoryLimit field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithFailedJobsHistoryLimit(value int32) *CronJobSpecApplyConfiguration { - b.FailedJobsHistoryLimit = &value - return b -} - -// WithStringSliceData puts the entries into the StringSliceData field in the declarative configuration -// and returns the receiver, so that objects can be build by chaining "With" function invocations. -// If called multiple times, the entries provided by each call will be put on the StringSliceData field, -// overwriting an existing map entries in StringSliceData field with the same key. -func (b *CronJobSpecApplyConfiguration) WithStringSliceData(entries map[string][]string) *CronJobSpecApplyConfiguration { - if b.StringSliceData == nil && len(entries) > 0 { - b.StringSliceData = make(map[string][]string, len(entries)) - } - for k, v := range entries { - b.StringSliceData[k] = v - } - return b -} - -// WithPtrData puts the entries into the PtrData field in the declarative configuration -// and returns the receiver, so that objects can be build by chaining "With" function invocations. -// If called multiple times, the entries provided by each call will be put on the PtrData field, -// overwriting an existing map entries in PtrData field with the same key. -func (b *CronJobSpecApplyConfiguration) WithPtrData(entries map[string]*string) *CronJobSpecApplyConfiguration { - if b.PtrData == nil && len(entries) > 0 { - b.PtrData = make(map[string]*string, len(entries)) - } - for k, v := range entries { - b.PtrData[k] = v - } - return b -} - -// WithSlice adds the given value to the Slice field in the declarative configuration -// and returns the receiver, so that objects can be build by chaining "With" function invocations. -// If called multiple times, values provided by each call will be appended to the Slice field. -func (b *CronJobSpecApplyConfiguration) WithSlice(values ...string) *CronJobSpecApplyConfiguration { - for i := range values { - b.Slice = append(b.Slice, values[i]) - } - return b -} - -// WithSlicePtr adds the given value to the SlicePtr field in the declarative configuration -// and returns the receiver, so that objects can be build by chaining "With" function invocations. -// If called multiple times, values provided by each call will be appended to the SlicePtr field. -func (b *CronJobSpecApplyConfiguration) WithSlicePtr(values ...*string) *CronJobSpecApplyConfiguration { - for i := range values { - if values[i] == nil { - panic("nil value passed to WithSlicePtr") - } - b.SlicePtr = append(b.SlicePtr, *values[i]) - } - return b -} - -// WithSliceStruct adds the given value to the SliceStruct field in the declarative configuration -// and returns the receiver, so that objects can be build by chaining "With" function invocations. -// If called multiple times, values provided by each call will be appended to the SliceStruct field. -func (b *CronJobSpecApplyConfiguration) WithSliceStruct(values ...**testdatacronjob.ExampleStruct) *CronJobSpecApplyConfiguration { - for i := range values { - if values[i] == nil { - panic("nil value passed to WithSliceStruct") - } - b.SliceStruct = append(b.SliceStruct, *values[i]) - } - return b -} - -// WithBuiltInReference sets the BuiltInReference field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the BuiltInReference field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithBuiltInReference(value v1.PodSpec) *CronJobSpecApplyConfiguration { - b.BuiltInReference = &value - return b -} - -// WithInt sets the Int field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the Int field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithInt(value int) *CronJobSpecApplyConfiguration { - b.Int = &value - return b -} - -// WithAssociativeList adds the given value to the AssociativeList field in the declarative configuration -// and returns the receiver, so that objects can be build by chaining "With" function invocations. -// If called multiple times, values provided by each call will be appended to the AssociativeList field. -func (b *CronJobSpecApplyConfiguration) WithAssociativeList(values ...*AssociativeTypeApplyConfiguration) *CronJobSpecApplyConfiguration { - for i := range values { - if values[i] == nil { - panic("nil value passed to WithAssociativeList") - } - b.AssociativeList = append(b.AssociativeList, *values[i]) - } - return b -} diff --git a/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobstatus.go b/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobstatus.go deleted file mode 100644 index 8023eeab5..000000000 --- a/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/cronjobstatus.go +++ /dev/null @@ -1,48 +0,0 @@ -// Code generated by applyconfiguration. DO NOT EDIT. - -package cronjob - -import ( - v1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// CronJobStatusApplyConfiguration represents a declarative configuration of the CronJobStatus type for use -// with apply. -type CronJobStatusApplyConfiguration struct { - Active []v1.ObjectReference `json:"active,omitempty"` - LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty"` - LastScheduleMicroTime *metav1.MicroTime `json:"lastScheduleMicroTime,omitempty"` -} - -// CronJobStatusApplyConfiguration constructs a declarative configuration of the CronJobStatus type for use with -// apply. -func CronJobStatus() *CronJobStatusApplyConfiguration { - return &CronJobStatusApplyConfiguration{} -} - -// WithActive adds the given value to the Active field in the declarative configuration -// and returns the receiver, so that objects can be build by chaining "With" function invocations. -// If called multiple times, values provided by each call will be appended to the Active field. -func (b *CronJobStatusApplyConfiguration) WithActive(values ...v1.ObjectReference) *CronJobStatusApplyConfiguration { - for i := range values { - b.Active = append(b.Active, values[i]) - } - return b -} - -// WithLastScheduleTime sets the LastScheduleTime field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the LastScheduleTime field is set to the value of the last call. -func (b *CronJobStatusApplyConfiguration) WithLastScheduleTime(value metav1.Time) *CronJobStatusApplyConfiguration { - b.LastScheduleTime = &value - return b -} - -// WithLastScheduleMicroTime sets the LastScheduleMicroTime field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the LastScheduleMicroTime field is set to the value of the last call. -func (b *CronJobStatusApplyConfiguration) WithLastScheduleMicroTime(value metav1.MicroTime) *CronJobStatusApplyConfiguration { - b.LastScheduleMicroTime = &value - return b -} diff --git a/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/examplestruct.go b/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/examplestruct.go deleted file mode 100644 index 76e4206bb..000000000 --- a/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob/examplestruct.go +++ /dev/null @@ -1,23 +0,0 @@ -// Code generated by applyconfiguration. DO NOT EDIT. - -package cronjob - -// ExampleStructApplyConfiguration represents a declarative configuration of the ExampleStruct type for use -// with apply. -type ExampleStructApplyConfiguration struct { - ExampleField *string `json:"string,omitempty"` -} - -// ExampleStructApplyConfiguration constructs a declarative configuration of the ExampleStruct type for use with -// apply. -func ExampleStruct() *ExampleStructApplyConfiguration { - return &ExampleStructApplyConfiguration{} -} - -// WithExampleField sets the ExampleField field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the ExampleField field is set to the value of the last call. -func (b *ExampleStructApplyConfiguration) WithExampleField(value string) *ExampleStructApplyConfiguration { - b.ExampleField = &value - return b -} diff --git a/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/utils.go b/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/utils.go deleted file mode 100644 index 8746c6915..000000000 --- a/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/utils.go +++ /dev/null @@ -1,36 +0,0 @@ -// Code generated by applyconfiguration. DO NOT EDIT. - -package testapplyconfiguration - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - testing "k8s.io/client-go/testing" - cronjob "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob" - internal "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/internal" - testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob/testapplyconfiguration/testdata/cronjob" -) - -// ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no -// apply configuration type exists for the given GroupVersionKind. -func ForKind(kind schema.GroupVersionKind) interface{} { - switch kind { - // Group=testdata, Version=cronjob - case cronjob.SchemeGroupVersion.WithKind("AssociativeType"): - return &testdatacronjob.AssociativeTypeApplyConfiguration{} - case cronjob.SchemeGroupVersion.WithKind("CronJob"): - return &testdatacronjob.CronJobApplyConfiguration{} - case cronjob.SchemeGroupVersion.WithKind("CronJobSpec"): - return &testdatacronjob.CronJobSpecApplyConfiguration{} - case cronjob.SchemeGroupVersion.WithKind("CronJobStatus"): - return &testdatacronjob.CronJobStatusApplyConfiguration{} - case cronjob.SchemeGroupVersion.WithKind("ExampleStruct"): - return &testdatacronjob.ExampleStructApplyConfiguration{} - - } - return nil -} - -func NewTypeConverter(scheme *runtime.Scheme) *testing.TypeConverter { - return &testing.TypeConverter{Scheme: scheme, TypeResolver: internal.Parser()} -} From 0aae7570e8c4588abc89cfdcd276f4b827a509cf Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Fri, 21 Mar 2025 14:10:30 +0000 Subject: [PATCH 17/22] Update cronjob_types with the latest version --- .../applyconfiguration_integration_test.go | 2 +- .../testdata/cronjob/containsnestedmap.go | 29 + .../testdata/cronjob/cronjobspec.go | 725 +++++++++++++++++- .../testdata/cronjob/cronjobstatus.go | 61 +- .../testdata/cronjob/duration.go | 27 + .../testdata/cronjob/embeddedstruct.go | 23 + .../testdata/cronjob/empiableobject.go | 32 + .../testdata/cronjob/examplestruct.go | 23 - .../testdata/cronjob/exportedstruct.go | 23 + .../testdata/cronjob/justnestedobject.go | 32 + .../testdata/cronjob/minmaxobject.go | 41 + .../testdata/cronjob/nestedobject.go | 32 + .../cronjob/nestedstructwithseveralfields.go | 32 + .../testdata/cronjob/preserved.go | 23 + .../testdata/cronjob/rootobject.go | 23 + .../testdata/cronjob/unexportedstruct.go | 23 + .../cronjob/applyconfiguration/utils.go | 26 +- .../testdata/cronjob/cronjob_types.go | 625 ++++++++++++++- 18 files changed, 1717 insertions(+), 85 deletions(-) create mode 100644 pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/containsnestedmap.go create mode 100644 pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/duration.go create mode 100644 pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/embeddedstruct.go create mode 100644 pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/empiableobject.go delete mode 100644 pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go create mode 100644 pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/exportedstruct.go create mode 100644 pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/justnestedobject.go create mode 100644 pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/minmaxobject.go create mode 100644 pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/nestedobject.go create mode 100644 pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/nestedstructwithseveralfields.go create mode 100644 pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/preserved.go create mode 100644 pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/rootobject.go create mode 100644 pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/unexportedstruct.go diff --git a/pkg/applyconfiguration/applyconfiguration_integration_test.go b/pkg/applyconfiguration/applyconfiguration_integration_test.go index 666a5b570..1e4d0682e 100644 --- a/pkg/applyconfiguration/applyconfiguration_integration_test.go +++ b/pkg/applyconfiguration/applyconfiguration_integration_test.go @@ -109,7 +109,7 @@ var _ = Describe("ApplyConfiguration generation from API types", func() { Expect(optionsRegistry.Register(markers.Must(markers.MakeDefinition("applyconfiguration", markers.DescribesPackage, Generator{})))).To(Succeed()) rt, err := genall.FromOptions(optionsRegistry, []string{ - "crd", // Run another generator first to make sure they don't interfere; see also: the comment on cronjob_types.go:UntypedBlob + "crd:allowDangerousTypes=true,ignoreUnexportedFields=true", // Run another generator first to make sure they don't interfere; see also: the comment on cronjob_types.go:UntypedBlob "applyconfiguration", }) Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/containsnestedmap.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/containsnestedmap.go new file mode 100644 index 000000000..22bf67cbc --- /dev/null +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/containsnestedmap.go @@ -0,0 +1,29 @@ +// Code generated by applyconfiguration. DO NOT EDIT. + +package cronjob + +// ContainsNestedMapApplyConfiguration represents a declarative configuration of the ContainsNestedMap type for use +// with apply. +type ContainsNestedMapApplyConfiguration struct { + InnerMap map[string]string `json:"innerMap,omitempty"` +} + +// ContainsNestedMapApplyConfiguration constructs a declarative configuration of the ContainsNestedMap type for use with +// apply. +func ContainsNestedMap() *ContainsNestedMapApplyConfiguration { + return &ContainsNestedMapApplyConfiguration{} +} + +// WithInnerMap puts the entries into the InnerMap field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the InnerMap field, +// overwriting an existing map entries in InnerMap field with the same key. +func (b *ContainsNestedMapApplyConfiguration) WithInnerMap(entries map[string]string) *ContainsNestedMapApplyConfiguration { + if b.InnerMap == nil && len(entries) > 0 { + b.InnerMap = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.InnerMap[k] = v + } + return b +} diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go index 245f6b5e0..6160862da 100644 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go @@ -5,29 +5,95 @@ package cronjob import ( v1beta1 "k8s.io/api/batch/v1beta1" v1 "k8s.io/api/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + intstr "k8s.io/apimachinery/pkg/util/intstr" testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob" ) // CronJobSpecApplyConfiguration represents a declarative configuration of the CronJobSpec type for use // with apply. type CronJobSpecApplyConfiguration struct { - Schedule *string `json:"schedule,omitempty"` - StartingDeadlineSeconds *int64 `json:"startingDeadlineSeconds,omitempty"` - ConcurrencyPolicy *testdatacronjob.ConcurrencyPolicy `json:"concurrencyPolicy,omitempty"` - Suspend *bool `json:"suspend,omitempty"` - BinaryName []byte `json:"binaryName,omitempty"` - CanBeNull *string `json:"canBeNull,omitempty"` - JobTemplate *v1beta1.JobTemplateSpec `json:"jobTemplate,omitempty"` - SuccessfulJobsHistoryLimit *int32 `json:"successfulJobsHistoryLimit,omitempty"` - FailedJobsHistoryLimit *int32 `json:"failedJobsHistoryLimit,omitempty"` - StringSliceData map[string][]string `json:"stringSliceData,omitempty"` - PtrData map[string]*string `json:"ptrData,omitempty"` - Slice []string `json:"slice,omitempty"` - SlicePtr []*string `json:"slicePtr,omitempty"` - SliceStruct []*testdatacronjob.ExampleStruct `json:"sliceStruct,omitempty"` - BuiltInReference *v1.PodSpec `json:"builtInReference,omitempty"` - Int *int `json:"int,omitempty"` - AssociativeList []AssociativeTypeApplyConfiguration `json:"associativeList,omitempty"` + Schedule *string `json:"schedule,omitempty"` + StartingDeadlineSeconds *int64 `json:"startingDeadlineSeconds,omitempty"` + ConcurrencyPolicy *testdatacronjob.ConcurrencyPolicy `json:"concurrencyPolicy,omitempty"` + Suspend *bool `json:"suspend,omitempty"` + NoReallySuspend *testdatacronjob.TotallyABool `json:"noReallySuspend,omitempty"` + BinaryName []byte `json:"binaryName,omitempty"` + CanBeNull *string `json:"canBeNull,omitempty"` + JobTemplate *v1beta1.JobTemplateSpec `json:"jobTemplate,omitempty"` + SuccessfulJobsHistoryLimit *int32 `json:"successfulJobsHistoryLimit,omitempty"` + FailedJobsHistoryLimit *int32 `json:"failedJobsHistoryLimit,omitempty"` + ByteSliceData map[string][]byte `json:"byteSliceData,omitempty"` + StringSliceData map[string][]string `json:"stringSliceData,omitempty"` + PtrData map[string]*string `json:"ptrData,omitempty"` + TwoOfAKindPart0 *string `json:"twoOfAKindPart0,omitempty"` + TwoOfAKindPart1 *testdatacronjob.LongerString `json:"twoOfAKindPart1,omitempty"` + DefaultedString *string `json:"defaultedString,omitempty"` + DefaultedSlice []string `json:"defaultedSlice,omitempty"` + DefaultedObject []RootObjectApplyConfiguration `json:"defaultedObject,omitempty"` + DefaultedEmptySlice []string `json:"defaultedEmptySlice,omitempty"` + DefaultedEmptyMap map[string]string `json:"defaultedEmptyMap,omitempty"` + DefaultedEmptyObject *EmpiableObjectApplyConfiguration `json:"defaultedEmptyObject,omitempty"` + DoubleDefaultedString *string `json:"doubleDefaultedString,omitempty"` + KubernetesDefaultedString *string `json:"kubernetesDefaultedString,omitempty"` + KubernetesDefaultedSlice []string `json:"kubernetesDefaultedSlice,omitempty"` + KubernetesDefaultedObject []RootObjectApplyConfiguration `json:"kubernetesDefaultedObject,omitempty"` + KubernetesDefaultedEmptySlice []string `json:"kubernetesDefaultedEmptySlice,omitempty"` + KubernetesDefaultedEmptyMap map[string]string `json:"kubernetesDefaultedEmptyMap,omitempty"` + KubernetesDefaultedEmptyObject *EmpiableObjectApplyConfiguration `json:"kubernetesDefaultedEmptyObject,omitempty"` + KubernetesDefaultedRef *string `json:"kubernetesDefaultedRef,omitempty"` + PatternObject *string `json:"patternObject,omitempty"` + EmbeddedResource *runtime.RawExtension `json:"embeddedResource,omitempty"` + UnprunedJSON *NestedObjectApplyConfiguration `json:"unprunedJSON,omitempty"` + UnprunedEmbeddedResource *runtime.RawExtension `json:"unprunedEmbeddedResource,omitempty"` + UnprunedFromType *PreservedApplyConfiguration `json:"unprunedFomType,omitempty"` + UnprunedFromTypeAndField *PreservedApplyConfiguration `json:"unprunedFomTypeAndField,omitempty"` + AssociativeList []AssociativeTypeApplyConfiguration `json:"associativeList,omitempty"` + NestedAssociativeList *testdatacronjob.NestedAssociativeList `json:"nestedassociativeList,omitempty"` + MapOfInfo map[string][]byte `json:"mapOfInfo,omitempty"` + NestedMapOfInfo *testdatacronjob.NestedMapOfInfo `json:"nestedMapOfInfo,omitempty"` + StructWithSeveralFields *NestedObjectApplyConfiguration `json:"structWithSeveralFields,omitempty"` + NestedStructWithSeveralFields *NestedStructWithSeveralFieldsApplyConfiguration `json:"nestedStructWithSeveralFields,omitempty"` + NestedStructWithSeveralFieldsDoubleMarked *NestedStructWithSeveralFieldsApplyConfiguration `json:"nestedStructWithSeveralFieldsDoubleMarked,omitempty"` + JustNestedObject *JustNestedObjectApplyConfiguration `json:"justNestedObject,omitempty"` + ExplicitlyOptionalKubebuilder *string `json:"explicitlyOptionalKubebuilder,omitempty"` + ExplicitlyOptionalKubernetes *string `json:"explicitlyOptionalKubernetes,omitempty"` + ExplicitlyRequiredKubebuilder *string `json:"explicitlyRequiredKubebuilder,omitempty"` + ExplicitlyRequiredKubernetes *string `json:"explicitlyRequiredKubernetes,omitempty"` + MinMaxProperties *MinMaxObjectApplyConfiguration `json:"minMaxProperties,omitempty"` + Schemaless []byte `json:"schemaless,omitempty"` + IntOrStringWithAPattern *intstr.IntOrString `json:"intOrStringWithAPattern,omitempty"` + NestedMap map[string]map[string]string `json:"nestedMap,omitempty"` + NestedNestedMap map[string]map[string]map[string]string `json:"nestedNestedMap,omitempty"` + ContainsNestedMapMap map[string]ContainsNestedMapApplyConfiguration `json:"nestedMapInStruct,omitempty"` + MapOfArraysOfFloats map[string][]bool `json:"mapOfArraysOfFloats,omitempty"` + FloatWithValidations *float64 `json:"floatWithValidations,omitempty"` + Float64WithValidations *float64 `json:"float64WithValidations,omitempty"` + IntWithValidations *int `json:"intWithValidations,omitempty"` + Int32WithValidations *int32 `json:"int32WithValidations,omitempty"` + unexportedStructApplyConfiguration `json:",inline"` + ExportedStructApplyConfiguration `json:",inline"` + StringWithEvenLength *string `json:"stringWithEvenLength,omitempty"` + StringWithEvenLengthAndMessageExpression *string `json:"stringWithEvenLengthAndMessageExpression,omitempty"` + StringWithEvenLengthAndGoodPrefix *testdatacronjob.StringEvenType `json:"stringWithEvenLengthAndGoodPrefix,omitempty"` + ForbiddenInt *int `json:"forbiddenInt,omitempty"` + Array *[3]int `json:"array,omitempty"` + ArrayUsingCompositeLiteral *[3]string `json:"arrayUsingCompositeLiteral,omitempty"` + Hosts []string `json:"hosts,omitempty"` + EnumSlice []int `json:"enumSlice,omitempty"` + HostsAlias *testdatacronjob.Hosts `json:"hostsAlias,omitempty"` + AliasFromPackage *v1.IPFamilyPolicy `json:"aliasFromPackage,omitempty"` + StringAlias *string `json:"stringAlias,omitempty"` + StringAliasPtr *string `json:"stringAliasPtr,omitempty"` + StringAliasAddedValidation *string `json:"stringAliasAddedValidation,omitempty"` + StringAliasAlreadyValidated *string `json:"stringAliasAlreadyValidated,omitempty"` + StringPair []string `json:"stringPair,omitempty"` + LongerStringArray []testdatacronjob.LongerString `json:"longerStringArray,omitempty"` + IntOrStringArrayWithAPattern []*intstr.IntOrString `json:"intOrStringArrayWithAPattern,omitempty"` + Protocol *v1.Protocol `json:"protocol,omitempty"` + SelectableFieldString *string `json:"selectableFieldString,omitempty"` + EmbeddedStructApplyConfiguration `json:",inline"` + OnlyAllowSettingOnUpdate *int32 `json:"onlyAllowSettingOnUpdate,omitempty"` } // CronJobSpecApplyConfiguration constructs a declarative configuration of the CronJobSpec type for use with @@ -68,6 +134,14 @@ func (b *CronJobSpecApplyConfiguration) WithSuspend(value bool) *CronJobSpecAppl return b } +// WithNoReallySuspend sets the NoReallySuspend field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the NoReallySuspend field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithNoReallySuspend(value testdatacronjob.TotallyABool) *CronJobSpecApplyConfiguration { + b.NoReallySuspend = &value + return b +} + // WithBinaryName adds the given value to the BinaryName field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. // If called multiple times, values provided by each call will be appended to the BinaryName field. @@ -110,6 +184,20 @@ func (b *CronJobSpecApplyConfiguration) WithFailedJobsHistoryLimit(value int32) return b } +// WithByteSliceData puts the entries into the ByteSliceData field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the ByteSliceData field, +// overwriting an existing map entries in ByteSliceData field with the same key. +func (b *CronJobSpecApplyConfiguration) WithByteSliceData(entries map[string][]byte) *CronJobSpecApplyConfiguration { + if b.ByteSliceData == nil && len(entries) > 0 { + b.ByteSliceData = make(map[string][]byte, len(entries)) + } + for k, v := range entries { + b.ByteSliceData[k] = v + } + return b +} + // WithStringSliceData puts the entries into the StringSliceData field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. // If called multiple times, the entries provided by each call will be put on the StringSliceData field, @@ -138,55 +226,209 @@ func (b *CronJobSpecApplyConfiguration) WithPtrData(entries map[string]*string) return b } -// WithSlice adds the given value to the Slice field in the declarative configuration +// WithTwoOfAKindPart0 sets the TwoOfAKindPart0 field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the TwoOfAKindPart0 field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithTwoOfAKindPart0(value string) *CronJobSpecApplyConfiguration { + b.TwoOfAKindPart0 = &value + return b +} + +// WithTwoOfAKindPart1 sets the TwoOfAKindPart1 field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the TwoOfAKindPart1 field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithTwoOfAKindPart1(value testdatacronjob.LongerString) *CronJobSpecApplyConfiguration { + b.TwoOfAKindPart1 = &value + return b +} + +// WithDefaultedString sets the DefaultedString field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DefaultedString field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithDefaultedString(value string) *CronJobSpecApplyConfiguration { + b.DefaultedString = &value + return b +} + +// WithDefaultedSlice adds the given value to the DefaultedSlice field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. -// If called multiple times, values provided by each call will be appended to the Slice field. -func (b *CronJobSpecApplyConfiguration) WithSlice(values ...string) *CronJobSpecApplyConfiguration { +// If called multiple times, values provided by each call will be appended to the DefaultedSlice field. +func (b *CronJobSpecApplyConfiguration) WithDefaultedSlice(values ...string) *CronJobSpecApplyConfiguration { for i := range values { - b.Slice = append(b.Slice, values[i]) + b.DefaultedSlice = append(b.DefaultedSlice, values[i]) } return b } -// WithSlicePtr adds the given value to the SlicePtr field in the declarative configuration +// WithDefaultedObject adds the given value to the DefaultedObject field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. -// If called multiple times, values provided by each call will be appended to the SlicePtr field. -func (b *CronJobSpecApplyConfiguration) WithSlicePtr(values ...*string) *CronJobSpecApplyConfiguration { +// If called multiple times, values provided by each call will be appended to the DefaultedObject field. +func (b *CronJobSpecApplyConfiguration) WithDefaultedObject(values ...*RootObjectApplyConfiguration) *CronJobSpecApplyConfiguration { for i := range values { if values[i] == nil { - panic("nil value passed to WithSlicePtr") + panic("nil value passed to WithDefaultedObject") } - b.SlicePtr = append(b.SlicePtr, *values[i]) + b.DefaultedObject = append(b.DefaultedObject, *values[i]) } return b } -// WithSliceStruct adds the given value to the SliceStruct field in the declarative configuration +// WithDefaultedEmptySlice adds the given value to the DefaultedEmptySlice field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. -// If called multiple times, values provided by each call will be appended to the SliceStruct field. -func (b *CronJobSpecApplyConfiguration) WithSliceStruct(values ...**testdatacronjob.ExampleStruct) *CronJobSpecApplyConfiguration { +// If called multiple times, values provided by each call will be appended to the DefaultedEmptySlice field. +func (b *CronJobSpecApplyConfiguration) WithDefaultedEmptySlice(values ...string) *CronJobSpecApplyConfiguration { + for i := range values { + b.DefaultedEmptySlice = append(b.DefaultedEmptySlice, values[i]) + } + return b +} + +// WithDefaultedEmptyMap puts the entries into the DefaultedEmptyMap field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the DefaultedEmptyMap field, +// overwriting an existing map entries in DefaultedEmptyMap field with the same key. +func (b *CronJobSpecApplyConfiguration) WithDefaultedEmptyMap(entries map[string]string) *CronJobSpecApplyConfiguration { + if b.DefaultedEmptyMap == nil && len(entries) > 0 { + b.DefaultedEmptyMap = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.DefaultedEmptyMap[k] = v + } + return b +} + +// WithDefaultedEmptyObject sets the DefaultedEmptyObject field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DefaultedEmptyObject field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithDefaultedEmptyObject(value *EmpiableObjectApplyConfiguration) *CronJobSpecApplyConfiguration { + b.DefaultedEmptyObject = value + return b +} + +// WithDoubleDefaultedString sets the DoubleDefaultedString field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DoubleDefaultedString field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithDoubleDefaultedString(value string) *CronJobSpecApplyConfiguration { + b.DoubleDefaultedString = &value + return b +} + +// WithKubernetesDefaultedString sets the KubernetesDefaultedString field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the KubernetesDefaultedString field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithKubernetesDefaultedString(value string) *CronJobSpecApplyConfiguration { + b.KubernetesDefaultedString = &value + return b +} + +// WithKubernetesDefaultedSlice adds the given value to the KubernetesDefaultedSlice field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the KubernetesDefaultedSlice field. +func (b *CronJobSpecApplyConfiguration) WithKubernetesDefaultedSlice(values ...string) *CronJobSpecApplyConfiguration { + for i := range values { + b.KubernetesDefaultedSlice = append(b.KubernetesDefaultedSlice, values[i]) + } + return b +} + +// WithKubernetesDefaultedObject adds the given value to the KubernetesDefaultedObject field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the KubernetesDefaultedObject field. +func (b *CronJobSpecApplyConfiguration) WithKubernetesDefaultedObject(values ...*RootObjectApplyConfiguration) *CronJobSpecApplyConfiguration { for i := range values { if values[i] == nil { - panic("nil value passed to WithSliceStruct") + panic("nil value passed to WithKubernetesDefaultedObject") } - b.SliceStruct = append(b.SliceStruct, *values[i]) + b.KubernetesDefaultedObject = append(b.KubernetesDefaultedObject, *values[i]) } return b } -// WithBuiltInReference sets the BuiltInReference field in the declarative configuration to the given value +// WithKubernetesDefaultedEmptySlice adds the given value to the KubernetesDefaultedEmptySlice field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the KubernetesDefaultedEmptySlice field. +func (b *CronJobSpecApplyConfiguration) WithKubernetesDefaultedEmptySlice(values ...string) *CronJobSpecApplyConfiguration { + for i := range values { + b.KubernetesDefaultedEmptySlice = append(b.KubernetesDefaultedEmptySlice, values[i]) + } + return b +} + +// WithKubernetesDefaultedEmptyMap puts the entries into the KubernetesDefaultedEmptyMap field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the KubernetesDefaultedEmptyMap field, +// overwriting an existing map entries in KubernetesDefaultedEmptyMap field with the same key. +func (b *CronJobSpecApplyConfiguration) WithKubernetesDefaultedEmptyMap(entries map[string]string) *CronJobSpecApplyConfiguration { + if b.KubernetesDefaultedEmptyMap == nil && len(entries) > 0 { + b.KubernetesDefaultedEmptyMap = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.KubernetesDefaultedEmptyMap[k] = v + } + return b +} + +// WithKubernetesDefaultedEmptyObject sets the KubernetesDefaultedEmptyObject field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the KubernetesDefaultedEmptyObject field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithKubernetesDefaultedEmptyObject(value *EmpiableObjectApplyConfiguration) *CronJobSpecApplyConfiguration { + b.KubernetesDefaultedEmptyObject = value + return b +} + +// WithKubernetesDefaultedRef sets the KubernetesDefaultedRef field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the KubernetesDefaultedRef field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithKubernetesDefaultedRef(value string) *CronJobSpecApplyConfiguration { + b.KubernetesDefaultedRef = &value + return b +} + +// WithPatternObject sets the PatternObject field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the BuiltInReference field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithBuiltInReference(value v1.PodSpec) *CronJobSpecApplyConfiguration { - b.BuiltInReference = &value +// If called multiple times, the PatternObject field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithPatternObject(value string) *CronJobSpecApplyConfiguration { + b.PatternObject = &value return b } -// WithInt sets the Int field in the declarative configuration to the given value +// WithEmbeddedResource sets the EmbeddedResource field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the Int field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithInt(value int) *CronJobSpecApplyConfiguration { - b.Int = &value +// If called multiple times, the EmbeddedResource field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithEmbeddedResource(value runtime.RawExtension) *CronJobSpecApplyConfiguration { + b.EmbeddedResource = &value + return b +} + +// WithUnprunedJSON sets the UnprunedJSON field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UnprunedJSON field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithUnprunedJSON(value *NestedObjectApplyConfiguration) *CronJobSpecApplyConfiguration { + b.UnprunedJSON = value + return b +} + +// WithUnprunedEmbeddedResource sets the UnprunedEmbeddedResource field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UnprunedEmbeddedResource field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithUnprunedEmbeddedResource(value runtime.RawExtension) *CronJobSpecApplyConfiguration { + b.UnprunedEmbeddedResource = &value + return b +} + +// WithUnprunedFromType sets the UnprunedFromType field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UnprunedFromType field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithUnprunedFromType(value *PreservedApplyConfiguration) *CronJobSpecApplyConfiguration { + b.UnprunedFromType = value + return b +} + +// WithUnprunedFromTypeAndField sets the UnprunedFromTypeAndField field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UnprunedFromTypeAndField field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithUnprunedFromTypeAndField(value *PreservedApplyConfiguration) *CronJobSpecApplyConfiguration { + b.UnprunedFromTypeAndField = value return b } @@ -202,3 +444,408 @@ func (b *CronJobSpecApplyConfiguration) WithAssociativeList(values ...*Associati } return b } + +// WithNestedAssociativeList sets the NestedAssociativeList field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the NestedAssociativeList field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithNestedAssociativeList(value testdatacronjob.NestedAssociativeList) *CronJobSpecApplyConfiguration { + b.NestedAssociativeList = &value + return b +} + +// WithMapOfInfo puts the entries into the MapOfInfo field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the MapOfInfo field, +// overwriting an existing map entries in MapOfInfo field with the same key. +func (b *CronJobSpecApplyConfiguration) WithMapOfInfo(entries map[string][]byte) *CronJobSpecApplyConfiguration { + if b.MapOfInfo == nil && len(entries) > 0 { + b.MapOfInfo = make(map[string][]byte, len(entries)) + } + for k, v := range entries { + b.MapOfInfo[k] = v + } + return b +} + +// WithNestedMapOfInfo sets the NestedMapOfInfo field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the NestedMapOfInfo field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithNestedMapOfInfo(value testdatacronjob.NestedMapOfInfo) *CronJobSpecApplyConfiguration { + b.NestedMapOfInfo = &value + return b +} + +// WithStructWithSeveralFields sets the StructWithSeveralFields field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the StructWithSeveralFields field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithStructWithSeveralFields(value *NestedObjectApplyConfiguration) *CronJobSpecApplyConfiguration { + b.StructWithSeveralFields = value + return b +} + +// WithNestedStructWithSeveralFields sets the NestedStructWithSeveralFields field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the NestedStructWithSeveralFields field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithNestedStructWithSeveralFields(value *NestedStructWithSeveralFieldsApplyConfiguration) *CronJobSpecApplyConfiguration { + b.NestedStructWithSeveralFields = value + return b +} + +// WithNestedStructWithSeveralFieldsDoubleMarked sets the NestedStructWithSeveralFieldsDoubleMarked field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the NestedStructWithSeveralFieldsDoubleMarked field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithNestedStructWithSeveralFieldsDoubleMarked(value *NestedStructWithSeveralFieldsApplyConfiguration) *CronJobSpecApplyConfiguration { + b.NestedStructWithSeveralFieldsDoubleMarked = value + return b +} + +// WithJustNestedObject sets the JustNestedObject field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the JustNestedObject field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithJustNestedObject(value *JustNestedObjectApplyConfiguration) *CronJobSpecApplyConfiguration { + b.JustNestedObject = value + return b +} + +// WithExplicitlyOptionalKubebuilder sets the ExplicitlyOptionalKubebuilder field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ExplicitlyOptionalKubebuilder field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithExplicitlyOptionalKubebuilder(value string) *CronJobSpecApplyConfiguration { + b.ExplicitlyOptionalKubebuilder = &value + return b +} + +// WithExplicitlyOptionalKubernetes sets the ExplicitlyOptionalKubernetes field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ExplicitlyOptionalKubernetes field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithExplicitlyOptionalKubernetes(value string) *CronJobSpecApplyConfiguration { + b.ExplicitlyOptionalKubernetes = &value + return b +} + +// WithExplicitlyRequiredKubebuilder sets the ExplicitlyRequiredKubebuilder field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ExplicitlyRequiredKubebuilder field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithExplicitlyRequiredKubebuilder(value string) *CronJobSpecApplyConfiguration { + b.ExplicitlyRequiredKubebuilder = &value + return b +} + +// WithExplicitlyRequiredKubernetes sets the ExplicitlyRequiredKubernetes field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ExplicitlyRequiredKubernetes field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithExplicitlyRequiredKubernetes(value string) *CronJobSpecApplyConfiguration { + b.ExplicitlyRequiredKubernetes = &value + return b +} + +// WithMinMaxProperties sets the MinMaxProperties field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the MinMaxProperties field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithMinMaxProperties(value *MinMaxObjectApplyConfiguration) *CronJobSpecApplyConfiguration { + b.MinMaxProperties = value + return b +} + +// WithSchemaless adds the given value to the Schemaless field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Schemaless field. +func (b *CronJobSpecApplyConfiguration) WithSchemaless(values ...byte) *CronJobSpecApplyConfiguration { + for i := range values { + b.Schemaless = append(b.Schemaless, values[i]) + } + return b +} + +// WithIntOrStringWithAPattern sets the IntOrStringWithAPattern field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the IntOrStringWithAPattern field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithIntOrStringWithAPattern(value intstr.IntOrString) *CronJobSpecApplyConfiguration { + b.IntOrStringWithAPattern = &value + return b +} + +// WithNestedMap puts the entries into the NestedMap field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the NestedMap field, +// overwriting an existing map entries in NestedMap field with the same key. +func (b *CronJobSpecApplyConfiguration) WithNestedMap(entries map[string]map[string]string) *CronJobSpecApplyConfiguration { + if b.NestedMap == nil && len(entries) > 0 { + b.NestedMap = make(map[string]map[string]string, len(entries)) + } + for k, v := range entries { + b.NestedMap[k] = v + } + return b +} + +// WithNestedNestedMap puts the entries into the NestedNestedMap field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the NestedNestedMap field, +// overwriting an existing map entries in NestedNestedMap field with the same key. +func (b *CronJobSpecApplyConfiguration) WithNestedNestedMap(entries map[string]map[string]map[string]string) *CronJobSpecApplyConfiguration { + if b.NestedNestedMap == nil && len(entries) > 0 { + b.NestedNestedMap = make(map[string]map[string]map[string]string, len(entries)) + } + for k, v := range entries { + b.NestedNestedMap[k] = v + } + return b +} + +// WithContainsNestedMapMap puts the entries into the ContainsNestedMapMap field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the ContainsNestedMapMap field, +// overwriting an existing map entries in ContainsNestedMapMap field with the same key. +func (b *CronJobSpecApplyConfiguration) WithContainsNestedMapMap(entries map[string]ContainsNestedMapApplyConfiguration) *CronJobSpecApplyConfiguration { + if b.ContainsNestedMapMap == nil && len(entries) > 0 { + b.ContainsNestedMapMap = make(map[string]ContainsNestedMapApplyConfiguration, len(entries)) + } + for k, v := range entries { + b.ContainsNestedMapMap[k] = v + } + return b +} + +// WithMapOfArraysOfFloats puts the entries into the MapOfArraysOfFloats field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the MapOfArraysOfFloats field, +// overwriting an existing map entries in MapOfArraysOfFloats field with the same key. +func (b *CronJobSpecApplyConfiguration) WithMapOfArraysOfFloats(entries map[string][]bool) *CronJobSpecApplyConfiguration { + if b.MapOfArraysOfFloats == nil && len(entries) > 0 { + b.MapOfArraysOfFloats = make(map[string][]bool, len(entries)) + } + for k, v := range entries { + b.MapOfArraysOfFloats[k] = v + } + return b +} + +// WithFloatWithValidations sets the FloatWithValidations field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the FloatWithValidations field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithFloatWithValidations(value float64) *CronJobSpecApplyConfiguration { + b.FloatWithValidations = &value + return b +} + +// WithFloat64WithValidations sets the Float64WithValidations field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Float64WithValidations field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithFloat64WithValidations(value float64) *CronJobSpecApplyConfiguration { + b.Float64WithValidations = &value + return b +} + +// WithIntWithValidations sets the IntWithValidations field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the IntWithValidations field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithIntWithValidations(value int) *CronJobSpecApplyConfiguration { + b.IntWithValidations = &value + return b +} + +// WithInt32WithValidations sets the Int32WithValidations field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Int32WithValidations field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithInt32WithValidations(value int32) *CronJobSpecApplyConfiguration { + b.Int32WithValidations = &value + return b +} + +// WithFoo sets the Foo field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Foo field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithFoo(value string) *CronJobSpecApplyConfiguration { + b.unexportedStructApplyConfiguration.Foo = &value + return b +} + +// WithBaz sets the Baz field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Baz field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithBaz(value string) *CronJobSpecApplyConfiguration { + b.ExportedStructApplyConfiguration.Baz = &value + return b +} + +// WithStringWithEvenLength sets the StringWithEvenLength field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the StringWithEvenLength field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithStringWithEvenLength(value string) *CronJobSpecApplyConfiguration { + b.StringWithEvenLength = &value + return b +} + +// WithStringWithEvenLengthAndMessageExpression sets the StringWithEvenLengthAndMessageExpression field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the StringWithEvenLengthAndMessageExpression field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithStringWithEvenLengthAndMessageExpression(value string) *CronJobSpecApplyConfiguration { + b.StringWithEvenLengthAndMessageExpression = &value + return b +} + +// WithStringWithEvenLengthAndGoodPrefix sets the StringWithEvenLengthAndGoodPrefix field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the StringWithEvenLengthAndGoodPrefix field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithStringWithEvenLengthAndGoodPrefix(value testdatacronjob.StringEvenType) *CronJobSpecApplyConfiguration { + b.StringWithEvenLengthAndGoodPrefix = &value + return b +} + +// WithForbiddenInt sets the ForbiddenInt field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ForbiddenInt field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithForbiddenInt(value int) *CronJobSpecApplyConfiguration { + b.ForbiddenInt = &value + return b +} + +// WithArray sets the Array field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Array field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithArray(value [3]int) *CronJobSpecApplyConfiguration { + b.Array = &value + return b +} + +// WithArrayUsingCompositeLiteral sets the ArrayUsingCompositeLiteral field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ArrayUsingCompositeLiteral field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithArrayUsingCompositeLiteral(value [3]string) *CronJobSpecApplyConfiguration { + b.ArrayUsingCompositeLiteral = &value + return b +} + +// WithHosts adds the given value to the Hosts field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Hosts field. +func (b *CronJobSpecApplyConfiguration) WithHosts(values ...string) *CronJobSpecApplyConfiguration { + for i := range values { + b.Hosts = append(b.Hosts, values[i]) + } + return b +} + +// WithEnumSlice adds the given value to the EnumSlice field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the EnumSlice field. +func (b *CronJobSpecApplyConfiguration) WithEnumSlice(values ...int) *CronJobSpecApplyConfiguration { + for i := range values { + b.EnumSlice = append(b.EnumSlice, values[i]) + } + return b +} + +// WithHostsAlias sets the HostsAlias field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the HostsAlias field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithHostsAlias(value testdatacronjob.Hosts) *CronJobSpecApplyConfiguration { + b.HostsAlias = &value + return b +} + +// WithAliasFromPackage sets the AliasFromPackage field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AliasFromPackage field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithAliasFromPackage(value v1.IPFamilyPolicy) *CronJobSpecApplyConfiguration { + b.AliasFromPackage = &value + return b +} + +// WithStringAlias sets the StringAlias field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the StringAlias field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithStringAlias(value string) *CronJobSpecApplyConfiguration { + b.StringAlias = &value + return b +} + +// WithStringAliasPtr sets the StringAliasPtr field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the StringAliasPtr field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithStringAliasPtr(value string) *CronJobSpecApplyConfiguration { + b.StringAliasPtr = &value + return b +} + +// WithStringAliasAddedValidation sets the StringAliasAddedValidation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the StringAliasAddedValidation field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithStringAliasAddedValidation(value string) *CronJobSpecApplyConfiguration { + b.StringAliasAddedValidation = &value + return b +} + +// WithStringAliasAlreadyValidated sets the StringAliasAlreadyValidated field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the StringAliasAlreadyValidated field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithStringAliasAlreadyValidated(value string) *CronJobSpecApplyConfiguration { + b.StringAliasAlreadyValidated = &value + return b +} + +// WithStringPair adds the given value to the StringPair field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the StringPair field. +func (b *CronJobSpecApplyConfiguration) WithStringPair(values ...string) *CronJobSpecApplyConfiguration { + for i := range values { + b.StringPair = append(b.StringPair, values[i]) + } + return b +} + +// WithLongerStringArray adds the given value to the LongerStringArray field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the LongerStringArray field. +func (b *CronJobSpecApplyConfiguration) WithLongerStringArray(values ...testdatacronjob.LongerString) *CronJobSpecApplyConfiguration { + for i := range values { + b.LongerStringArray = append(b.LongerStringArray, values[i]) + } + return b +} + +// WithIntOrStringArrayWithAPattern adds the given value to the IntOrStringArrayWithAPattern field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the IntOrStringArrayWithAPattern field. +func (b *CronJobSpecApplyConfiguration) WithIntOrStringArrayWithAPattern(values ...*intstr.IntOrString) *CronJobSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithIntOrStringArrayWithAPattern") + } + b.IntOrStringArrayWithAPattern = append(b.IntOrStringArrayWithAPattern, *values[i]) + } + return b +} + +// WithProtocol sets the Protocol field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Protocol field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithProtocol(value v1.Protocol) *CronJobSpecApplyConfiguration { + b.Protocol = &value + return b +} + +// WithSelectableFieldString sets the SelectableFieldString field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the SelectableFieldString field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithSelectableFieldString(value string) *CronJobSpecApplyConfiguration { + b.SelectableFieldString = &value + return b +} + +// WithFromEmbedded sets the FromEmbedded field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the FromEmbedded field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithFromEmbedded(value string) *CronJobSpecApplyConfiguration { + b.EmbeddedStructApplyConfiguration.FromEmbedded = &value + return b +} + +// WithOnlyAllowSettingOnUpdate sets the OnlyAllowSettingOnUpdate field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the OnlyAllowSettingOnUpdate field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithOnlyAllowSettingOnUpdate(value int32) *CronJobSpecApplyConfiguration { + b.OnlyAllowSettingOnUpdate = &value + return b +} diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go index 8023eeab5..9483ba401 100644 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go @@ -5,14 +5,21 @@ package cronjob import ( v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob" ) // CronJobStatusApplyConfiguration represents a declarative configuration of the CronJobStatus type for use // with apply. type CronJobStatusApplyConfiguration struct { - Active []v1.ObjectReference `json:"active,omitempty"` - LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty"` - LastScheduleMicroTime *metav1.MicroTime `json:"lastScheduleMicroTime,omitempty"` + Active []v1.ObjectReference `json:"active,omitempty"` + LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty"` + LastScheduleTime2 *testdatacronjob.Time2 `json:"lastScheduleTime2,omitempty"` + LastScheduleMicroTime *metav1.MicroTime `json:"lastScheduleMicroTime,omitempty"` + LastActiveLogURL *testdatacronjob.URL `json:"lastActiveLogURL,omitempty"` + LastActiveLogURL2 *testdatacronjob.URL2 `json:"lastActiveLogURL2,omitempty"` + LastActiveLogURL3 *testdatacronjob.URL3 `json:"lastActiveLogURL3,omitempty"` + LastActiveLogURL4 *testdatacronjob.URL4 `json:"lastActiveLogURL4,omitempty"` + Runtime *DurationApplyConfiguration `json:"duration,omitempty"` } // CronJobStatusApplyConfiguration constructs a declarative configuration of the CronJobStatus type for use with @@ -39,6 +46,14 @@ func (b *CronJobStatusApplyConfiguration) WithLastScheduleTime(value metav1.Time return b } +// WithLastScheduleTime2 sets the LastScheduleTime2 field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LastScheduleTime2 field is set to the value of the last call. +func (b *CronJobStatusApplyConfiguration) WithLastScheduleTime2(value testdatacronjob.Time2) *CronJobStatusApplyConfiguration { + b.LastScheduleTime2 = &value + return b +} + // WithLastScheduleMicroTime sets the LastScheduleMicroTime field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the LastScheduleMicroTime field is set to the value of the last call. @@ -46,3 +61,43 @@ func (b *CronJobStatusApplyConfiguration) WithLastScheduleMicroTime(value metav1 b.LastScheduleMicroTime = &value return b } + +// WithLastActiveLogURL sets the LastActiveLogURL field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LastActiveLogURL field is set to the value of the last call. +func (b *CronJobStatusApplyConfiguration) WithLastActiveLogURL(value testdatacronjob.URL) *CronJobStatusApplyConfiguration { + b.LastActiveLogURL = &value + return b +} + +// WithLastActiveLogURL2 sets the LastActiveLogURL2 field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LastActiveLogURL2 field is set to the value of the last call. +func (b *CronJobStatusApplyConfiguration) WithLastActiveLogURL2(value testdatacronjob.URL2) *CronJobStatusApplyConfiguration { + b.LastActiveLogURL2 = &value + return b +} + +// WithLastActiveLogURL3 sets the LastActiveLogURL3 field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LastActiveLogURL3 field is set to the value of the last call. +func (b *CronJobStatusApplyConfiguration) WithLastActiveLogURL3(value testdatacronjob.URL3) *CronJobStatusApplyConfiguration { + b.LastActiveLogURL3 = &value + return b +} + +// WithLastActiveLogURL4 sets the LastActiveLogURL4 field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LastActiveLogURL4 field is set to the value of the last call. +func (b *CronJobStatusApplyConfiguration) WithLastActiveLogURL4(value testdatacronjob.URL4) *CronJobStatusApplyConfiguration { + b.LastActiveLogURL4 = &value + return b +} + +// WithRuntime sets the Runtime field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Runtime field is set to the value of the last call. +func (b *CronJobStatusApplyConfiguration) WithRuntime(value *DurationApplyConfiguration) *CronJobStatusApplyConfiguration { + b.Runtime = value + return b +} diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/duration.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/duration.go new file mode 100644 index 000000000..4a529a0fe --- /dev/null +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/duration.go @@ -0,0 +1,27 @@ +// Code generated by applyconfiguration. DO NOT EDIT. + +package cronjob + +import ( + time "time" +) + +// DurationApplyConfiguration represents a declarative configuration of the Duration type for use +// with apply. +type DurationApplyConfiguration struct { + Value *time.Duration `json:"value,omitempty"` +} + +// DurationApplyConfiguration constructs a declarative configuration of the Duration type for use with +// apply. +func Duration() *DurationApplyConfiguration { + return &DurationApplyConfiguration{} +} + +// WithValue sets the Value field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Value field is set to the value of the last call. +func (b *DurationApplyConfiguration) WithValue(value time.Duration) *DurationApplyConfiguration { + b.Value = &value + return b +} diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/embeddedstruct.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/embeddedstruct.go new file mode 100644 index 000000000..8c4d6a3dc --- /dev/null +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/embeddedstruct.go @@ -0,0 +1,23 @@ +// Code generated by applyconfiguration. DO NOT EDIT. + +package cronjob + +// EmbeddedStructApplyConfiguration represents a declarative configuration of the EmbeddedStruct type for use +// with apply. +type EmbeddedStructApplyConfiguration struct { + FromEmbedded *string `json:"fromEmbedded,omitempty"` +} + +// EmbeddedStructApplyConfiguration constructs a declarative configuration of the EmbeddedStruct type for use with +// apply. +func EmbeddedStruct() *EmbeddedStructApplyConfiguration { + return &EmbeddedStructApplyConfiguration{} +} + +// WithFromEmbedded sets the FromEmbedded field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the FromEmbedded field is set to the value of the last call. +func (b *EmbeddedStructApplyConfiguration) WithFromEmbedded(value string) *EmbeddedStructApplyConfiguration { + b.FromEmbedded = &value + return b +} diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/empiableobject.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/empiableobject.go new file mode 100644 index 000000000..92ee64426 --- /dev/null +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/empiableobject.go @@ -0,0 +1,32 @@ +// Code generated by applyconfiguration. DO NOT EDIT. + +package cronjob + +// EmpiableObjectApplyConfiguration represents a declarative configuration of the EmpiableObject type for use +// with apply. +type EmpiableObjectApplyConfiguration struct { + Foo *string `json:"foo,omitempty"` + Bar *string `json:"bar,omitempty"` +} + +// EmpiableObjectApplyConfiguration constructs a declarative configuration of the EmpiableObject type for use with +// apply. +func EmpiableObject() *EmpiableObjectApplyConfiguration { + return &EmpiableObjectApplyConfiguration{} +} + +// WithFoo sets the Foo field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Foo field is set to the value of the last call. +func (b *EmpiableObjectApplyConfiguration) WithFoo(value string) *EmpiableObjectApplyConfiguration { + b.Foo = &value + return b +} + +// WithBar sets the Bar field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Bar field is set to the value of the last call. +func (b *EmpiableObjectApplyConfiguration) WithBar(value string) *EmpiableObjectApplyConfiguration { + b.Bar = &value + return b +} diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go deleted file mode 100644 index 76e4206bb..000000000 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/examplestruct.go +++ /dev/null @@ -1,23 +0,0 @@ -// Code generated by applyconfiguration. DO NOT EDIT. - -package cronjob - -// ExampleStructApplyConfiguration represents a declarative configuration of the ExampleStruct type for use -// with apply. -type ExampleStructApplyConfiguration struct { - ExampleField *string `json:"string,omitempty"` -} - -// ExampleStructApplyConfiguration constructs a declarative configuration of the ExampleStruct type for use with -// apply. -func ExampleStruct() *ExampleStructApplyConfiguration { - return &ExampleStructApplyConfiguration{} -} - -// WithExampleField sets the ExampleField field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the ExampleField field is set to the value of the last call. -func (b *ExampleStructApplyConfiguration) WithExampleField(value string) *ExampleStructApplyConfiguration { - b.ExampleField = &value - return b -} diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/exportedstruct.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/exportedstruct.go new file mode 100644 index 000000000..d0b9b8688 --- /dev/null +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/exportedstruct.go @@ -0,0 +1,23 @@ +// Code generated by applyconfiguration. DO NOT EDIT. + +package cronjob + +// ExportedStructApplyConfiguration represents a declarative configuration of the ExportedStruct type for use +// with apply. +type ExportedStructApplyConfiguration struct { + Baz *string `json:"baz,omitempty"` +} + +// ExportedStructApplyConfiguration constructs a declarative configuration of the ExportedStruct type for use with +// apply. +func ExportedStruct() *ExportedStructApplyConfiguration { + return &ExportedStructApplyConfiguration{} +} + +// WithBaz sets the Baz field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Baz field is set to the value of the last call. +func (b *ExportedStructApplyConfiguration) WithBaz(value string) *ExportedStructApplyConfiguration { + b.Baz = &value + return b +} diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/justnestedobject.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/justnestedobject.go new file mode 100644 index 000000000..81b8f881f --- /dev/null +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/justnestedobject.go @@ -0,0 +1,32 @@ +// Code generated by applyconfiguration. DO NOT EDIT. + +package cronjob + +// JustNestedObjectApplyConfiguration represents a declarative configuration of the JustNestedObject type for use +// with apply. +type JustNestedObjectApplyConfiguration struct { + Foo *string `json:"foo,omitempty"` + Bar *bool `json:"bar,omitempty"` +} + +// JustNestedObjectApplyConfiguration constructs a declarative configuration of the JustNestedObject type for use with +// apply. +func JustNestedObject() *JustNestedObjectApplyConfiguration { + return &JustNestedObjectApplyConfiguration{} +} + +// WithFoo sets the Foo field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Foo field is set to the value of the last call. +func (b *JustNestedObjectApplyConfiguration) WithFoo(value string) *JustNestedObjectApplyConfiguration { + b.Foo = &value + return b +} + +// WithBar sets the Bar field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Bar field is set to the value of the last call. +func (b *JustNestedObjectApplyConfiguration) WithBar(value bool) *JustNestedObjectApplyConfiguration { + b.Bar = &value + return b +} diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/minmaxobject.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/minmaxobject.go new file mode 100644 index 000000000..8e1a5f4fc --- /dev/null +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/minmaxobject.go @@ -0,0 +1,41 @@ +// Code generated by applyconfiguration. DO NOT EDIT. + +package cronjob + +// MinMaxObjectApplyConfiguration represents a declarative configuration of the MinMaxObject type for use +// with apply. +type MinMaxObjectApplyConfiguration struct { + Foo *string `json:"foo,omitempty"` + Bar *string `json:"bar,omitempty"` + Baz *string `json:"baz,omitempty"` +} + +// MinMaxObjectApplyConfiguration constructs a declarative configuration of the MinMaxObject type for use with +// apply. +func MinMaxObject() *MinMaxObjectApplyConfiguration { + return &MinMaxObjectApplyConfiguration{} +} + +// WithFoo sets the Foo field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Foo field is set to the value of the last call. +func (b *MinMaxObjectApplyConfiguration) WithFoo(value string) *MinMaxObjectApplyConfiguration { + b.Foo = &value + return b +} + +// WithBar sets the Bar field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Bar field is set to the value of the last call. +func (b *MinMaxObjectApplyConfiguration) WithBar(value string) *MinMaxObjectApplyConfiguration { + b.Bar = &value + return b +} + +// WithBaz sets the Baz field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Baz field is set to the value of the last call. +func (b *MinMaxObjectApplyConfiguration) WithBaz(value string) *MinMaxObjectApplyConfiguration { + b.Baz = &value + return b +} diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/nestedobject.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/nestedobject.go new file mode 100644 index 000000000..167d029b9 --- /dev/null +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/nestedobject.go @@ -0,0 +1,32 @@ +// Code generated by applyconfiguration. DO NOT EDIT. + +package cronjob + +// NestedObjectApplyConfiguration represents a declarative configuration of the NestedObject type for use +// with apply. +type NestedObjectApplyConfiguration struct { + Foo *string `json:"foo,omitempty"` + Bar *bool `json:"bar,omitempty"` +} + +// NestedObjectApplyConfiguration constructs a declarative configuration of the NestedObject type for use with +// apply. +func NestedObject() *NestedObjectApplyConfiguration { + return &NestedObjectApplyConfiguration{} +} + +// WithFoo sets the Foo field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Foo field is set to the value of the last call. +func (b *NestedObjectApplyConfiguration) WithFoo(value string) *NestedObjectApplyConfiguration { + b.Foo = &value + return b +} + +// WithBar sets the Bar field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Bar field is set to the value of the last call. +func (b *NestedObjectApplyConfiguration) WithBar(value bool) *NestedObjectApplyConfiguration { + b.Bar = &value + return b +} diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/nestedstructwithseveralfields.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/nestedstructwithseveralfields.go new file mode 100644 index 000000000..02c65cae9 --- /dev/null +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/nestedstructwithseveralfields.go @@ -0,0 +1,32 @@ +// Code generated by applyconfiguration. DO NOT EDIT. + +package cronjob + +// NestedStructWithSeveralFieldsApplyConfiguration represents a declarative configuration of the NestedStructWithSeveralFields type for use +// with apply. +type NestedStructWithSeveralFieldsApplyConfiguration struct { + Foo *string `json:"foo,omitempty"` + Bar *bool `json:"bar,omitempty"` +} + +// NestedStructWithSeveralFieldsApplyConfiguration constructs a declarative configuration of the NestedStructWithSeveralFields type for use with +// apply. +func NestedStructWithSeveralFields() *NestedStructWithSeveralFieldsApplyConfiguration { + return &NestedStructWithSeveralFieldsApplyConfiguration{} +} + +// WithFoo sets the Foo field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Foo field is set to the value of the last call. +func (b *NestedStructWithSeveralFieldsApplyConfiguration) WithFoo(value string) *NestedStructWithSeveralFieldsApplyConfiguration { + b.Foo = &value + return b +} + +// WithBar sets the Bar field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Bar field is set to the value of the last call. +func (b *NestedStructWithSeveralFieldsApplyConfiguration) WithBar(value bool) *NestedStructWithSeveralFieldsApplyConfiguration { + b.Bar = &value + return b +} diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/preserved.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/preserved.go new file mode 100644 index 000000000..4e0ea6635 --- /dev/null +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/preserved.go @@ -0,0 +1,23 @@ +// Code generated by applyconfiguration. DO NOT EDIT. + +package cronjob + +// PreservedApplyConfiguration represents a declarative configuration of the Preserved type for use +// with apply. +type PreservedApplyConfiguration struct { + ConcreteField *string `json:"concreteField,omitempty"` +} + +// PreservedApplyConfiguration constructs a declarative configuration of the Preserved type for use with +// apply. +func Preserved() *PreservedApplyConfiguration { + return &PreservedApplyConfiguration{} +} + +// WithConcreteField sets the ConcreteField field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ConcreteField field is set to the value of the last call. +func (b *PreservedApplyConfiguration) WithConcreteField(value string) *PreservedApplyConfiguration { + b.ConcreteField = &value + return b +} diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/rootobject.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/rootobject.go new file mode 100644 index 000000000..fcc4b850d --- /dev/null +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/rootobject.go @@ -0,0 +1,23 @@ +// Code generated by applyconfiguration. DO NOT EDIT. + +package cronjob + +// RootObjectApplyConfiguration represents a declarative configuration of the RootObject type for use +// with apply. +type RootObjectApplyConfiguration struct { + Nested *NestedObjectApplyConfiguration `json:"nested,omitempty"` +} + +// RootObjectApplyConfiguration constructs a declarative configuration of the RootObject type for use with +// apply. +func RootObject() *RootObjectApplyConfiguration { + return &RootObjectApplyConfiguration{} +} + +// WithNested sets the Nested field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Nested field is set to the value of the last call. +func (b *RootObjectApplyConfiguration) WithNested(value *NestedObjectApplyConfiguration) *RootObjectApplyConfiguration { + b.Nested = value + return b +} diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/unexportedstruct.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/unexportedstruct.go new file mode 100644 index 000000000..d7a5a097a --- /dev/null +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/unexportedstruct.go @@ -0,0 +1,23 @@ +// Code generated by applyconfiguration. DO NOT EDIT. + +package cronjob + +// UnexportedStructApplyConfiguration represents a declarative configuration of the UnexportedStruct type for use +// with apply. +type UnexportedStructApplyConfiguration struct { + Foo *string `json:"foo,omitempty"` +} + +// UnexportedStructApplyConfiguration constructs a declarative configuration of the UnexportedStruct type for use with +// apply. +func UnexportedStruct() *UnexportedStructApplyConfiguration { + return &UnexportedStructApplyConfiguration{} +} + +// WithFoo sets the Foo field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Foo field is set to the value of the last call. +func (b *UnexportedStructApplyConfiguration) WithFoo(value string) *UnexportedStructApplyConfiguration { + b.Foo = &value + return b +} diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/utils.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/utils.go index b97b36bb2..2f4a9b7a7 100644 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/utils.go +++ b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/utils.go @@ -18,14 +18,36 @@ func ForKind(kind schema.GroupVersionKind) interface{} { // Group=testdata, Version=cronjob case cronjob.SchemeGroupVersion.WithKind("AssociativeType"): return &testdatacronjob.AssociativeTypeApplyConfiguration{} + case cronjob.SchemeGroupVersion.WithKind("ContainsNestedMap"): + return &testdatacronjob.ContainsNestedMapApplyConfiguration{} case cronjob.SchemeGroupVersion.WithKind("CronJob"): return &testdatacronjob.CronJobApplyConfiguration{} case cronjob.SchemeGroupVersion.WithKind("CronJobSpec"): return &testdatacronjob.CronJobSpecApplyConfiguration{} case cronjob.SchemeGroupVersion.WithKind("CronJobStatus"): return &testdatacronjob.CronJobStatusApplyConfiguration{} - case cronjob.SchemeGroupVersion.WithKind("ExampleStruct"): - return &testdatacronjob.ExampleStructApplyConfiguration{} + case cronjob.SchemeGroupVersion.WithKind("Duration"): + return &testdatacronjob.DurationApplyConfiguration{} + case cronjob.SchemeGroupVersion.WithKind("EmbeddedStruct"): + return &testdatacronjob.EmbeddedStructApplyConfiguration{} + case cronjob.SchemeGroupVersion.WithKind("EmpiableObject"): + return &testdatacronjob.EmpiableObjectApplyConfiguration{} + case cronjob.SchemeGroupVersion.WithKind("ExportedStruct"): + return &testdatacronjob.ExportedStructApplyConfiguration{} + case cronjob.SchemeGroupVersion.WithKind("JustNestedObject"): + return &testdatacronjob.JustNestedObjectApplyConfiguration{} + case cronjob.SchemeGroupVersion.WithKind("MinMaxObject"): + return &testdatacronjob.MinMaxObjectApplyConfiguration{} + case cronjob.SchemeGroupVersion.WithKind("NestedObject"): + return &testdatacronjob.NestedObjectApplyConfiguration{} + case cronjob.SchemeGroupVersion.WithKind("NestedStructWithSeveralFields"): + return &testdatacronjob.NestedStructWithSeveralFieldsApplyConfiguration{} + case cronjob.SchemeGroupVersion.WithKind("Preserved"): + return &testdatacronjob.PreservedApplyConfiguration{} + case cronjob.SchemeGroupVersion.WithKind("RootObject"): + return &testdatacronjob.RootObjectApplyConfiguration{} + case cronjob.SchemeGroupVersion.WithKind("UnexportedStruct"): + return &testdatacronjob.unexportedStructApplyConfiguration{} } return nil diff --git a/pkg/applyconfiguration/testdata/cronjob/cronjob_types.go b/pkg/applyconfiguration/testdata/cronjob/cronjob_types.go index 6b2438e37..5d62d1f44 100644 --- a/pkg/applyconfiguration/testdata/cronjob/cronjob_types.go +++ b/pkg/applyconfiguration/testdata/cronjob/cronjob_types.go @@ -13,20 +13,37 @@ See the License for the specific language governing permissions and limitations under the License. */ -//go:generate ../../../.run-controller-gen.sh paths=. output:dir=. +// TODO(directxman12): test this across both versions (right now we're just +// trusting k/k conversion, which is probably fine though) +//go:generate ../../../.run-controller-gen.sh crd:ignoreUnexportedFields=true,allowDangerousTypes=true paths=./;./deprecated;./unserved;./job/... output:dir=. + +// +groupName=testdata.kubebuilder.io +// +versionName=v1 package testdata import ( + "encoding" + "encoding/json" + "fmt" + "net/url" + "strconv" + "time" + batchv1beta1 "k8s.io/api/batch/v1beta1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/intstr" ) // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. +const DefaultRefValue = "defaultRefValue" + // CronJobSpec defines the desired state of CronJob +// +kubebuilder:validation:XValidation:rule="has(oldSelf.forbiddenInt) || !has(self.forbiddenInt)",message="forbiddenInt is not allowed",fieldPath=".forbiddenInt",reason="FieldValueForbidden" type CronJobSpec struct { // The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron. Schedule string `json:"schedule"` @@ -52,6 +69,11 @@ type CronJobSpec struct { // This tests that non-serialized fields aren't included in the schema. InternalData string `json:"-"` + // This flag is like suspend, but for when you really mean it. + // It helps test the +kubebuilder:validation:Type marker. + // +optional + NoReallySuspend *TotallyABool `json:"noReallySuspend,omitempty"` + // This tests byte slice schema generation. BinaryName []byte `json:"binaryName"` @@ -72,36 +94,392 @@ type CronJobSpec struct { // +optional FailedJobsHistoryLimit *int32 `json:"failedJobsHistoryLimit,omitempty"` + // This tests byte slices are allowed as map values. + ByteSliceData map[string][]byte `json:"byteSliceData,omitempty"` + // This tests string slices are allowed as map values. StringSliceData map[string][]string `json:"stringSliceData,omitempty"` // This tests pointers are allowed as map values. PtrData map[string]*string `json:"ptrData,omitempty"` - // This tests that slice has the proper ac generation - // +kubebuilder:default={a,b} - Slice []string `json:"slice"` + // This tests that markers that are allowed on both fields and types are applied to fields + // +kubebuilder:validation:MinLength=4 + TwoOfAKindPart0 string `json:"twoOfAKindPart0"` - // This tests that slice with pointers has the proper ac generation - // +kubebuilder:default={a,b} - SlicePtr []*string `json:"slicePtr"` + // This tests that markers that are allowed on both fields and types are applied to types + TwoOfAKindPart1 LongerString `json:"twoOfAKindPart1"` - // This tests that slice with structs has the proper ac generation + // This tests that primitive defaulting can be performed. + // +kubebuilder:default=forty-two + // +kubebuilder:example=forty-two + DefaultedString string `json:"defaultedString"` + + // This tests that slice defaulting can be performed. // +kubebuilder:default={a,b} - SliceStruct []*ExampleStruct `json:"sliceStruct"` + // +kubebuilder:example={a,b} + DefaultedSlice []string `json:"defaultedSlice"` + + // This tests that slice and object defaulting can be performed. + // +kubebuilder:default={{nested: {foo: "baz", bar: true}},{nested: {foo: "qux", bar: false}}} + // +kubebuilder:example={{nested: {foo: "baz", bar: true}},{nested: {foo: "qux", bar: false}}} + DefaultedObject []RootObject `json:"defaultedObject"` + + // This tests that empty slice defaulting can be performed. + // +kubebuilder:default={} + DefaultedEmptySlice []string `json:"defaultedEmptySlice"` + + // This tests that an empty object defaulting can be performed on a map. + // +kubebuilder:default={} + DefaultedEmptyMap map[string]string `json:"defaultedEmptyMap"` + + // This tests that an empty object defaulting can be performed on an object. + // +kubebuilder:default={} + DefaultedEmptyObject EmpiableObject `json:"defaultedEmptyObject"` + + // This tests that kubebuilder defaulting takes precedence. + // +kubebuilder:default="kubebuilder-default" + // +default="kubernetes-default" + DoubleDefaultedString string `json:"doubleDefaultedString"` + + // This tests that primitive defaulting can be performed. + // +default="forty-two" + KubernetesDefaultedString string `json:"kubernetesDefaultedString"` - // This tests that references to built in types have the proper ac generation - // Built in types are generated under "k8s.io/client-go/applyconfigurations" - BuiltInReference *corev1.PodSpec `json:"builtInReference"` + // This tests that slice defaulting can be performed. + // +default=["a","b"] + KubernetesDefaultedSlice []string `json:"kubernetesDefaultedSlice"` - // This tests that non-pointer ints have the proper ac generation - Int int `json:"int"` + // This tests that slice and object defaulting can be performed. + // +default=[{"nested": {"foo": "baz", "bar": true}},{"nested": {"foo": "qux", "bar": false}}] + KubernetesDefaultedObject []RootObject `json:"kubernetesDefaultedObject"` + + // This tests that empty slice defaulting can be performed. + // +default=[] + KubernetesDefaultedEmptySlice []string `json:"kubernetesDefaultedEmptySlice"` + + // This tests that an empty object defaulting can be performed on a map. + // +default={} + KubernetesDefaultedEmptyMap map[string]string `json:"kubernetesDefaultedEmptyMap"` + + // This tests that an empty object defaulting can be performed on an object. + // +default={} + KubernetesDefaultedEmptyObject EmpiableObject `json:"kubernetesDefaultedEmptyObject"` + + // This tests that use of +default=ref(...) doesn't break generation + // +default=ref(DefaultRefValue) + KubernetesDefaultedRef string `json:"kubernetesDefaultedRef,omitempty"` + + // This tests that pattern validator is properly applied. + // +kubebuilder:validation:Pattern=`^$|^((https):\/\/?)[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|\/?))$` + PatternObject string `json:"patternObject"` + + // +kubebuilder:validation:EmbeddedResource + // +kubebuilder:validation:nullable + EmbeddedResource runtime.RawExtension `json:"embeddedResource"` + + // +kubebuilder:validation:nullable + // +kubebuilder:pruning:PreserveUnknownFields + UnprunedJSON NestedObject `json:"unprunedJSON"` + + // +kubebuilder:pruning:PreserveUnknownFields + // +kubebuilder:validation:EmbeddedResource + // +kubebuilder:validation:nullable + UnprunedEmbeddedResource runtime.RawExtension `json:"unprunedEmbeddedResource"` + + // This tests that a type-level pruning marker works. + UnprunedFromType Preserved `json:"unprunedFomType"` + + // This tests that a type-level pruning marker combined with a field-level pruning marker works. + // +kubebuilder:pruning:PreserveUnknownFields + UnprunedFromTypeAndField Preserved `json:"unprunedFomTypeAndField"` // This tests that associative lists work. // +listType=map // +listMapKey=name // +listMapKey=secondary AssociativeList []AssociativeType `json:"associativeList"` + + // This tests that associative lists work via a nested type. + NestedAssociativeList NestedAssociativeList `json:"nestedassociativeList"` + + // A map that allows different actors to manage different fields + // +mapType=granular + MapOfInfo map[string][]byte `json:"mapOfInfo"` + + // A map that allows different actors to manage different fields via a nested type. + NestedMapOfInfo NestedMapOfInfo `json:"nestedMapOfInfo"` + + // A struct that can only be entirely replaced + // +structType=atomic + StructWithSeveralFields NestedObject `json:"structWithSeveralFields"` + + // A struct that can only be entirely replaced via a nested type. + NestedStructWithSeveralFields NestedStructWithSeveralFields `json:"nestedStructWithSeveralFields"` + + // A struct that can only be entirely replaced via a nested type and + // field markers. + // +structType=atomic + NestedStructWithSeveralFieldsDoubleMarked NestedStructWithSeveralFields `json:"nestedStructWithSeveralFieldsDoubleMarked"` + + // This tests that type references are properly flattened + // +kubebuilder:validation:optional + JustNestedObject *JustNestedObject `json:"justNestedObject,omitempty"` + + // This tests explicitly optional kubebuilder fields + // +kubebuilder:validation:Optional + ExplicitlyOptionalKubebuilder string `json:"explicitlyOptionalKubebuilder"` + + // This tests explicitly optional kubernetes fields + // +optional + ExplicitlyOptionalKubernetes string `json:"explicitlyOptionalKubernetes"` + + // This tests explicitly required kubebuilder fields + // +kubebuilder:validation:Required + ExplicitlyRequiredKubebuilder string `json:"explicitlyRequiredKubebuilder,omitempty"` + + // This tests explicitly required kubernetes fields + // +required + ExplicitlyRequiredKubernetes string `json:"explicitlyRequiredKubernetes,omitempty"` + + // This tests that min/max properties work + MinMaxProperties MinMaxObject `json:"minMaxProperties,omitempty"` + + // This tests that the schemaless marker works + // +kubebuilder:validation:Schemaless + Schemaless []byte `json:"schemaless,omitempty"` + + // This tests that an IntOrString can also have string validation. + // This can be useful if you want to limit the string to a percentage or integer. + // The XIntOrString marker is a requirement for having a pattern on this type. + // +kubebuilder:validation:XIntOrString + // +kubebuilder:validation:MaxLength=11 + // +kubebuilder:validation:MinLength=2 + // +kubebuilder:validation:Pattern="^((100|[0-9]{1,2})%|[0-9]+)$" + IntOrStringWithAPattern *intstr.IntOrString `json:"intOrStringWithAPattern,omitempty"` + + // Checks that nested maps work + NestedMap map[string]map[string]string `json:"nestedMap,omitempty"` + + // Checks that multiply-nested maps work + NestedNestedMap map[string]map[string]map[string]string `json:"nestedNestedMap,omitempty"` + + // Checks that maps containing types that contain maps work + ContainsNestedMapMap map[string]ContainsNestedMap `json:"nestedMapInStruct,omitempty"` + + // Maps of arrays of things-that-aren’t-strings are permitted + MapOfArraysOfFloats map[string][]bool `json:"mapOfArraysOfFloats,omitempty"` + + // +kubebuilder:validation:Minimum=-0.5 + // +kubebuilder:validation:Maximum=1.5 + // +kubebuilder:validation:MultipleOf=0.5 + FloatWithValidations float64 `json:"floatWithValidations"` + + // +kubebuilder:validation:Minimum=-0.5 + // +kubebuilder:validation:Maximum=1.5 + // +kubebuilder:validation:MultipleOf=0.5 + Float64WithValidations float64 `json:"float64WithValidations"` + + // +kubebuilder:validation:Minimum=-2 + // +kubebuilder:validation:Maximum=2 + // +kubebuilder:validation:MultipleOf=2 + IntWithValidations int `json:"intWithValidations"` + + // +kubebuilder:validation:Minimum=-2 + // +kubebuilder:validation:Maximum=2 + // +kubebuilder:validation:MultipleOf=2 + Int32WithValidations int32 `json:"int32WithValidations"` + + // This tests that unexported fields are skipped in the schema generation + unexportedField string + + // This tests that both unexported and exported inline fields are not skipped in the schema generation + unexportedStruct `json:",inline"` + ExportedStruct `json:",inline"` + + // Test of the expression-based validation rule marker, with optional message. + // +kubebuilder:validation:XValidation:rule="self.size() % 2 == 0",message="must have even length" + // +kubebuilder:validation:XValidation:rule="true" + StringWithEvenLength string `json:"stringWithEvenLength,omitempty"` + + // Test of the expression-based validation with messageExpression marker. + // +kubebuilder:validation:XValidation:rule="self.size() % 2 == 0",messageExpression="'Length has to be even but is ' + len(self.stringWithEvenLengthAndMessageExpression) + ' instead'" + StringWithEvenLengthAndMessageExpression string `json:"stringWithEvenLengthAndMessageExpression,omitempty"` + + // Test of the expression-based validation on both field and type. + // +kubebuilder:validation:XValidation:rule="self.startsWith('good-')",message="must have good prefix" + StringWithEvenLengthAndGoodPrefix StringEvenType `json:"stringWithEvenLengthAndGoodPrefix,omitempty"` + + // Test that we can add a forbidden field using XValidation Reason and FieldPath. + // The validation is applied to the spec struct itself and not the field. + ForbiddenInt int `json:"forbiddenInt,omitempty"` + + // Checks that fixed-length arrays work + Array [3]int `json:"array,omitempty"` + + // Checks that arrays work when the type contains a composite literal + ArrayUsingCompositeLiteral [len(struct{ X [3]int }{}.X)]string `json:"arrayUsingCompositeLiteral,omitempty"` + + // This tests string slice item validation. + // +kubebuilder:validation:MinItems=1 + // +kubebuilder:validation:items:MinLength=1 + // +kubebuilder:validation:items:MaxLength=255 + // +kubebuilder:validation:items:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?([.][a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ + // +listType=set + Hosts []string `json:"hosts,omitempty"` + + // This tests slice item validation with enum + // +kubebuilder:validation:items:Enum=0;1;3 + EnumSlice []int `json:"enumSlice,omitempty"` + + HostsAlias Hosts `json:"hostsAlias,omitempty"` + + // This tests that alias imported from a package is handled correctly. The + // corev1.IPFamilyPolicyType is just reused since it's available from + // imported package. We can create our own in a separate package if needed. + AliasFromPackage corev1.IPFamilyPolicyType `json:"aliasFromPackage,omitempty"` + + // This tests that string alias is handled correctly. + StringAlias StringAlias `json:"stringAlias,omitempty"` + StringAliasPtr *StringAlias `json:"stringAliasPtr,omitempty"` + + // This tests that validation on a string alias type is handled correctly. + // +kubebuilder:validation:MinLength=1 + // +kubebuilder:validation:MaxLength=255 + StringAliasAddedValidation StringAlias `json:"stringAliasAddedValidation,omitempty"` + + // This tests that validation on a the string alias type itself is handled correctly. + StringAliasAlreadyValidated StringAliasWithValidation `json:"stringAliasAlreadyValidated,omitempty"` + + // This tests string slice validation. + // +kubebuilder:validation:MinItems=2 + // +kubebuilder:validation:MaxItems=2 + StringPair []string `json:"stringPair"` + + // This tests string alias slice item validation. + // +kubebuilder:validation:MinItems=3 + LongerStringArray []LongerString `json:"longerStringArray,omitempty"` + + // This tests that a slice of IntOrString can also have string validation. + // This can be useful if you want to limit the string to a percentage or integer. + // The XIntOrString marker is a requirement for having a pattern on this type. + // +kubebuilder:validation:items:XIntOrString + // +kubebuilder:validation:items:MaxLength=10 + // +kubebuilder:validation:items:MinLength=1 + // +kubebuilder:validation:items:Pattern="^((100|[0-9]{1,2})%|[0-9]+)$" + IntOrStringArrayWithAPattern []*intstr.IntOrString `json:"intOrStringArrayWithAPattern,omitempty"` + + // This tests that we can embed protocol correctly (without ending up with allOf). + // Context: https://github.com/kubernetes-sigs/controller-tools/issues/1027 + // Defaults to "TCP". + // +optional + // +default="TCP" + Protocol corev1.Protocol `json:"protocol,omitempty" protobuf:"bytes,4,opt,name=protocol,casttype=Protocol"` + + // This tests that selectable field. + SelectableFieldString string `json:"selectableFieldString,omitempty"` + + // This tests that embedded struct, which is an alias type, is handled correctly. + InlineAlias `json:",inline"` + + // Test that we can add a field that can only be set to a non-default value on updates using XValidation OptionalOldSelf. + // +kubebuilder:validation:XValidation:rule="oldSelf.hasValue() || self == 0",message="must be set to 0 on creation. can be set to any value on an update.",optionalOldSelf=true + OnlyAllowSettingOnUpdate int32 `json:"onlyAllowSettingOnUpdate,omitempty"` +} + +type InlineAlias = EmbeddedStruct + +// EmbeddedStruct is for testing that embedded struct is handled correctly when it is used through an alias type. +type EmbeddedStruct struct { + // FromEmbedded is a field from the embedded struct that was used through an alias type. + FromEmbedded string `json:"fromEmbedded,omitempty"` +} + +type StringAlias = string + +// +kubebuilder:validation:MinLength=1 +// +kubebuilder:validation:MaxLength=255 +type StringAliasWithValidation = string + +type ContainsNestedMap struct { + InnerMap map[string]string `json:"innerMap,omitempty"` +} + +// +kubebuilder:validation:Type=object +// +kubebuilder:pruning:PreserveUnknownFields +type Preserved struct { + ConcreteField string `json:"concreteField"` + Rest map[string]interface{} `json:"-"` +} + +func (p *Preserved) UnmarshalJSON(data []byte) error { + if err := json.Unmarshal(data, &p.Rest); err != nil { + return err + } + conc, found := p.Rest["concreteField"] + if !found { + return nil + } + concStr, isStr := conc.(string) + if !isStr { + return fmt.Errorf("concreteField was not string") + } + delete(p.Rest, "concreteField") + p.ConcreteField = concStr + return nil +} + +func (p *Preserved) MarshalJSON() ([]byte, error) { + full := make(map[string]interface{}, len(p.Rest)+1) + for k, v := range p.Rest { + full[k] = v + } + full["concreteField"] = p.ConcreteField + return json.Marshal(full) +} + +type NestedObject struct { + Foo string `json:"foo"` + Bar bool `json:"bar"` +} + +// +structType=atomic +type NestedStructWithSeveralFields NestedObject + +type JustNestedObject NestedObject + +// +kubebuilder:validation:MinProperties=1 +// +kubebuilder:validation:MaxProperties=2 +type MinMaxObject struct { + Foo string `json:"foo,omitempty"` + Bar string `json:"bar,omitempty"` + Baz string `json:"baz,omitempty"` +} + +type EmpiableObject struct { + // +kubebuilder:default=forty-two + Foo string `json:"foo,omitempty"` + Bar string `json:"bar,omitempty"` +} + +type unexportedStruct struct { + // This tests that exported fields are not skipped in the schema generation + Foo string `json:"foo"` + + // This tests that unexported fields are skipped in the schema generation + bar string +} + +type ExportedStruct struct { + // This tests that exported fields are not skipped in the schema generation + Baz string `json:"baz"` + + // This tests that unexported fields are skipped in the schema generation + qux string +} + +type RootObject struct { + Nested NestedObject `json:"nested"` } type AssociativeType struct { @@ -110,6 +488,191 @@ type AssociativeType struct { Foo string `json:"foo"` } +// +listType=map +// +listMapKey=name +// +listMapKey=secondary +type NestedAssociativeList []AssociativeType + +// +mapType=granular +type NestedMapOfInfo map[string][]byte + +// +kubebuilder:validation:MinLength=4 +// This tests that markers that are allowed on both fields and types are applied to types +type LongerString string + +// use an explicit type marker to verify that apply-first markers generate properly + +// +kubebuilder:validation:Type=string +// TotallyABool is a bool that serializes as a string. +type TotallyABool bool + +// This tests string slice item validation. +// +kubebuilder:validation:MinItems=1 +// +kubebuilder:validation:items:MinLength=1 +// +kubebuilder:validation:items:MaxLength=255 +// +kubebuilder:validation:items:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?([.][a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ +// +listType=set +type Hosts []string + +func (t TotallyABool) MarshalJSON() ([]byte, error) { + if t { + return []byte(`"true"`), nil + } else { + return []byte(`"false"`), nil + } +} + +func (t *TotallyABool) UnmarshalJSON(in []byte) error { + switch string(in) { + case `"true"`: + *t = true + return nil + case `"false"`: + *t = false + default: + return fmt.Errorf("bad TotallyABool value %q", string(in)) + } + return nil +} + +// +kubebuilder:validation:Type=string +// URL wraps url.URL. +// It has custom json marshal methods that enable it to be used in K8s CRDs +// such that the CRD resource will have the URL but operator code can can work with url.URL struct +type URL struct { + url.URL +} + +func (u *URL) MarshalJSON() ([]byte, error) { + return []byte(fmt.Sprintf("%q", u.String())), nil +} + +func (u *URL) UnmarshalJSON(b []byte) error { + var ref string + if err := json.Unmarshal(b, &ref); err != nil { + return err + } + if ref == "" { + *u = URL{} + return nil + } + + r, err := url.Parse(ref) + if err != nil { + return err + } else if r != nil { + *u = URL{*r} + } else { + *u = URL{} + } + return nil +} + +func (u *URL) String() string { + if u == nil { + return "" + } + return u.URL.String() +} + +// +kubebuilder:validation:Type=string +// URL2 is an alias of url.URL. +// It has custom json marshal methods that enable it to be used in K8s CRDs +// such that the CRD resource will have the URL but operator code can can work with url.URL struct +type URL2 url.URL + +func (u *URL2) MarshalJSON() ([]byte, error) { + return []byte(fmt.Sprintf("%q", u.String())), nil +} + +func (u *URL2) UnmarshalJSON(b []byte) error { + var ref string + if err := json.Unmarshal(b, &ref); err != nil { + return err + } + if ref == "" { + *u = URL2{} + return nil + } + + r, err := url.Parse(ref) + if err != nil { + return err + } else if r != nil { + *u = *(*URL2)(r) + } else { + *u = URL2{} + } + return nil +} + +func (u *URL2) String() string { + if u == nil { + return "" + } + return (*url.URL)(u).String() +} + +// URL3 wraps [net/url.URL]. It implements [encoding.TextMarshaler] so that it +// can be used in K8s CRDs such that the CRD resource will have the URL but +// operator code can can work with the URL struct. +type URL3 struct{ url.URL } + +var _ encoding.TextMarshaler = (*URL3)(nil) + +// MarshalText implements [encoding.TextMarshaler]. +func (u *URL3) MarshalText() (text []byte, err error) { + return u.MarshalBinary() +} + +// URL4 is newtype around [net/url.URL]. It implements [encoding.TextMarshaler] +// so that it can be used in K8s CRDs such that the CRD resource will have the +// URL but operator code can can work with the URL struct. +type URL4 url.URL + +var _ encoding.TextMarshaler = (*URL4)(nil) + +// MarshalText implements [encoding.TextMarshaler]. +func (u *URL4) MarshalText() (text []byte, err error) { + return (*url.URL)(u).MarshalBinary() +} + +// +kubebuilder:validation:Type=integer +// +kubebuilder:validation:Format=int64 +// Time2 is a newtype around [metav1.Time]. +// It implements both [encoding.TextMarshaler] and [json.Marshaler]. +// The latter is authoritative for the CRD generation. +type Time2 time.Time + +var _ interface { + encoding.TextMarshaler + json.Marshaler +} = (*Time2)(nil) + +// MarshalText implements [encoding.TextMarshaler]. +func (t *Time2) MarshalText() (text []byte, err error) { + return []byte((*time.Time)(t).String()), nil +} + +// MarshalJSON implements [json.Marshaler]. +func (t *Time2) MarshalJSON() ([]byte, error) { + return strconv.AppendInt(nil, (*time.Time)(t).UnixMilli(), 10), nil +} + +// Duration has a custom Marshaler but no markers. +// We want the CRD generation to infer type information +// from the go types and ignore the presense of the Marshaler. +type Duration struct { + Value time.Duration `json:"value"` +} + +func (d Duration) MarshalJSON() ([]byte, error) { + type durationWithoutUnmarshaler Duration + return json.Marshal(durationWithoutUnmarshaler(d)) +} + +var _ json.Marshaler = Duration{} + // ConcurrencyPolicy describes how the job will be handled. // Only one of the following concurrent policies may be specified. // If none of the following policies is specified, the default one @@ -129,6 +692,10 @@ const ( ReplaceConcurrent ConcurrencyPolicy = "Replace" ) +// StringEvenType is a type that includes an expression-based validation. +// +kubebuilder:validation:XValidation:rule="self.size() % 2 == 0",message="must have even length" +type StringEvenType string + // CronJobStatus defines the observed state of CronJob type CronJobStatus struct { // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster @@ -142,18 +709,40 @@ type CronJobStatus struct { // +optional LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty"` + // Information when was the last time the job was successfully scheduled. + // +optional + LastScheduleTime2 Time2 `json:"lastScheduleTime2,omitempty"` + // Information about the last time the job was successfully scheduled, // with microsecond precision. // +optional LastScheduleMicroTime *metav1.MicroTime `json:"lastScheduleMicroTime,omitempty"` -} -type ExampleStruct struct { - ExampleField string `json:"string"` + // LastActiveLogURL specifies the logging url for the last started job + // +optional + LastActiveLogURL *URL `json:"lastActiveLogURL,omitempty"` + + // LastActiveLogURL2 specifies the logging url for the last started job + // +optional + LastActiveLogURL2 *URL2 `json:"lastActiveLogURL2,omitempty"` + + // LastActiveLogURL3 specifies the logging url for the last started job + // +optional + LastActiveLogURL3 *URL3 `json:"lastActiveLogURL3,omitempty"` + + // LastActiveLogURL4 specifies the logging url for the last started job + // +optional + LastActiveLogURL4 *URL4 `json:"lastActiveLogURL4,omitempty"` + + Runtime *Duration `json:"duration,omitempty"` } +// +kubebuilder:object:root=true // +kubebuilder:subresource:status // +kubebuilder:resource:singular=mycronjob +// +kubebuilder:storageversion +// +kubebuilder:metadata:annotations="api-approved.kubernetes.io=https://github.com/kubernetes-sigs/controller-tools";"cert-manager.io/inject-ca-from-secret=cert-manager/cert-manager-webhook-ca" +// +kubebuilder:selectablefield:JSONPath=`.spec.selectableFieldString` // CronJob is the Schema for the cronjobs API type CronJob struct { @@ -166,6 +755,8 @@ type CronJob struct { Status CronJobStatus `json:"status,omitempty"` } +// +kubebuilder:object:root=true + // CronJobList contains a list of CronJob type CronJobList struct { metav1.TypeMeta `json:",inline"` From c8ef095cdf4793967bbe0e31e5792d2f11311b10 Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Fri, 21 Mar 2025 14:13:30 +0000 Subject: [PATCH 18/22] Update groupversion inline with latest kubebuilder --- .../testdata/cronjob/groupversion_info.go | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/pkg/applyconfiguration/testdata/cronjob/groupversion_info.go b/pkg/applyconfiguration/testdata/cronjob/groupversion_info.go index f3e8b29e3..ea7ce82a5 100644 --- a/pkg/applyconfiguration/testdata/cronjob/groupversion_info.go +++ b/pkg/applyconfiguration/testdata/cronjob/groupversion_info.go @@ -29,24 +29,12 @@ import ( var ( GroupName = "testdata.kubebuilder.io" GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"} - schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) - // Install is a function which adds this version to a scheme - Install = schemeBuilder.AddToScheme + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) - // SchemeGroupVersion generated code relies on this name - // Deprecated - SchemeGroupVersion = GroupVersion // AddToScheme exists solely to keep the old generators creating valid code - // DEPRECATED - AddToScheme = schemeBuilder.AddToScheme + AddToScheme = SchemeBuilder.AddToScheme ) -// Resource generated code relies on this being here, but it logically belongs to the group -// DEPRECATED -func Resource(resource string) schema.GroupResource { - return schema.GroupResource{Group: GroupName, Resource: resource} -} - // Adds the list of known types to api.Scheme. func addKnownTypes(scheme *runtime.Scheme) error { metav1.AddToGroupVersion(scheme, GroupVersion) From fe610e21fceaa1efde90e21aee8b90c49e192dc1 Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Fri, 21 Mar 2025 14:14:47 +0000 Subject: [PATCH 19/22] Update go.mod to match latest of top level --- .../testdata/cronjob/go.mod | 33 ++++---- .../testdata/cronjob/go.sum | 76 +++++++++---------- 2 files changed, 55 insertions(+), 54 deletions(-) diff --git a/pkg/applyconfiguration/testdata/cronjob/go.mod b/pkg/applyconfiguration/testdata/cronjob/go.mod index dcf4d802b..5e5314ee9 100644 --- a/pkg/applyconfiguration/testdata/cronjob/go.mod +++ b/pkg/applyconfiguration/testdata/cronjob/go.mod @@ -1,12 +1,14 @@ module sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob -go 1.23.0 +go 1.24.0 + +toolchain go1.24.1 require ( - k8s.io/api v0.32.0 - k8s.io/apimachinery v0.32.0 - k8s.io/client-go v0.32.0 - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 + k8s.io/api v0.33.0-beta.0 + k8s.io/apimachinery v0.33.0-beta.0 + k8s.io/client-go v0.33.0-beta.0 + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 ) require ( @@ -18,9 +20,7 @@ require ( github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/swag v0.23.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.4 // indirect - github.com/google/gnostic-models v0.6.8 // indirect - github.com/google/gofuzz v1.2.0 // indirect + github.com/google/gnostic-models v0.6.9 // indirect github.com/google/uuid v1.6.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -30,19 +30,20 @@ require ( github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/x448/float16 v0.8.4 // indirect - golang.org/x/net v0.30.0 // indirect - golang.org/x/oauth2 v0.23.0 // indirect - golang.org/x/sys v0.26.0 // indirect - golang.org/x/term v0.25.0 // indirect - golang.org/x/text v0.19.0 // indirect - golang.org/x/time v0.7.0 // indirect - google.golang.org/protobuf v1.35.1 // indirect + golang.org/x/net v0.33.0 // indirect + golang.org/x/oauth2 v0.27.0 // indirect + golang.org/x/sys v0.30.0 // indirect + golang.org/x/term v0.29.0 // indirect + golang.org/x/text v0.22.0 // indirect + golang.org/x/time v0.9.0 // indirect + google.golang.org/protobuf v1.36.5 // indirect gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/klog/v2 v2.130.1 // indirect - k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 // indirect k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/pkg/applyconfiguration/testdata/cronjob/go.sum b/pkg/applyconfiguration/testdata/cronjob/go.sum index 7b7596d1d..730d19731 100644 --- a/pkg/applyconfiguration/testdata/cronjob/go.sum +++ b/pkg/applyconfiguration/testdata/cronjob/go.sum @@ -21,16 +21,12 @@ github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1v github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= -github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= +github.com/google/gnostic-models v0.6.9 h1:MU/8wDLif2qCXZmzncUQ/BOfxWfthHi63KqpoNbWqVw= +github.com/google/gnostic-models v0.6.9/go.mod h1:CiWsm0s6BSQd1hRn8/QmxqB6BesYcbSZxsz9b0KuDBw= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -63,22 +59,23 @@ github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4= github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= -github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= -github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= +github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -92,26 +89,26 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= -golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= -golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= -golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/oauth2 v0.27.0 h1:da9Vo7/tDv5RH/7nZDz1eMGS/q1Vv1N/7FCrBhI9I3M= +golang.org/x/oauth2 v0.27.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= -golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU= +golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= -golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= -golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= -golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= +golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY= +golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= @@ -122,8 +119,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= -google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= +google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= @@ -134,21 +131,24 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.32.0 h1:OL9JpbvAU5ny9ga2fb24X8H6xQlVp+aJMFlgtQjR9CE= -k8s.io/api v0.32.0/go.mod h1:4LEwHZEf6Q/cG96F3dqR965sYOfmPM7rq81BLgsE0p0= -k8s.io/apimachinery v0.32.0 h1:cFSE7N3rmEEtv4ei5X6DaJPHHX0C+upp+v5lVPiEwpg= -k8s.io/apimachinery v0.32.0/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE= -k8s.io/client-go v0.32.0 h1:DimtMcnN/JIKZcrSrstiwvvZvLjG0aSxy8PxN8IChp8= -k8s.io/client-go v0.32.0/go.mod h1:boDWvdM1Drk4NJj/VddSLnx59X3OPgwrOo0vGbtq9+8= +k8s.io/api v0.33.0-beta.0 h1:/sAUrfXsjKPST2mZjpWhjRdzSR6SD5KlJpiOgCQQhAQ= +k8s.io/api v0.33.0-beta.0/go.mod h1:TYyCgedkG4OVS4+4D2n25BdbMcexMSLx6Y7OkAzkxLQ= +k8s.io/apimachinery v0.33.0-beta.0 h1:vLDBChfQwyimk6AbuT7OZOIqxSg/44JlXuxqBk85j68= +k8s.io/apimachinery v0.33.0-beta.0/go.mod h1:S2OIkExGqJOXYSYcAJwQ9zWcc6BkBUdTJUu4M7z0cvo= +k8s.io/client-go v0.33.0-beta.0 h1:xRGKK5hU39pb6CFDCDOOlG+LEenB93/RK9hoP4eyAsU= +k8s.io/client-go v0.33.0-beta.0/go.mod h1:RF6hSu+FncpgHQs1zA1UfGbMq8gxay89r37bCQe+Mj4= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y= -k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f/go.mod h1:R/HEjbvWI0qdfb8viZUeVZm0X6IZnxAydC7YU42CMw4= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= From 46f9f4fd6d2698536003919d3ecd19f7688454f8 Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Fri, 21 Mar 2025 15:03:16 +0000 Subject: [PATCH 20/22] Move test apis into an API v1 folder to be more accurate --- .../applyconfiguration_integration_test.go | 16 ++-- .../api/v1}/associativetype.go | 2 +- .../api/v1}/containsnestedmap.go | 2 +- .../v1/applyconfiguration/api/v1}/cronjob.go | 24 +++--- .../applyconfiguration/api/v1}/cronjobspec.go | 74 +++++++++---------- .../api/v1}/cronjobstatus.go | 30 ++++---- .../v1/applyconfiguration/api/v1}/duration.go | 2 +- .../api/v1}/embeddedstruct.go | 2 +- .../api/v1}/empiableobject.go | 2 +- .../api/v1}/exportedstruct.go | 2 +- .../api/v1}/justnestedobject.go | 2 +- .../api/v1}/minmaxobject.go | 2 +- .../api/v1}/nestedobject.go | 2 +- .../api/v1}/nestedstructwithseveralfields.go | 2 +- .../applyconfiguration/api/v1}/preserved.go | 2 +- .../applyconfiguration/api/v1}/rootobject.go | 2 +- .../api/v1}/unexportedstruct.go | 2 +- .../applyconfiguration/internal/internal.go | 0 .../api/v1/applyconfiguration/utils.go | 58 +++++++++++++++ .../cronjob/{ => api/v1}/cronjob_types.go | 2 +- .../cronjob/{ => api/v1}/groupversion_info.go | 2 +- .../cronjob/applyconfiguration/utils.go | 58 --------------- 22 files changed, 146 insertions(+), 144 deletions(-) rename pkg/applyconfiguration/testdata/cronjob/{applyconfiguration/testdata/cronjob => api/v1/applyconfiguration/api/v1}/associativetype.go (99%) rename pkg/applyconfiguration/testdata/cronjob/{applyconfiguration/testdata/cronjob => api/v1/applyconfiguration/api/v1}/containsnestedmap.go (98%) rename pkg/applyconfiguration/testdata/cronjob/{applyconfiguration/testdata/cronjob => api/v1/applyconfiguration/api/v1}/cronjob.go (93%) rename pkg/applyconfiguration/testdata/cronjob/{applyconfiguration/testdata/cronjob => api/v1/applyconfiguration/api/v1}/cronjobspec.go (94%) rename pkg/applyconfiguration/testdata/cronjob/{applyconfiguration/testdata/cronjob => api/v1/applyconfiguration/api/v1}/cronjobstatus.go (83%) rename pkg/applyconfiguration/testdata/cronjob/{applyconfiguration/testdata/cronjob => api/v1/applyconfiguration/api/v1}/duration.go (98%) rename pkg/applyconfiguration/testdata/cronjob/{applyconfiguration/testdata/cronjob => api/v1/applyconfiguration/api/v1}/embeddedstruct.go (98%) rename pkg/applyconfiguration/testdata/cronjob/{applyconfiguration/testdata/cronjob => api/v1/applyconfiguration/api/v1}/empiableobject.go (98%) rename pkg/applyconfiguration/testdata/cronjob/{applyconfiguration/testdata/cronjob => api/v1/applyconfiguration/api/v1}/exportedstruct.go (98%) rename pkg/applyconfiguration/testdata/cronjob/{applyconfiguration/testdata/cronjob => api/v1/applyconfiguration/api/v1}/justnestedobject.go (98%) rename pkg/applyconfiguration/testdata/cronjob/{applyconfiguration/testdata/cronjob => api/v1/applyconfiguration/api/v1}/minmaxobject.go (99%) rename pkg/applyconfiguration/testdata/cronjob/{applyconfiguration/testdata/cronjob => api/v1/applyconfiguration/api/v1}/nestedobject.go (98%) rename pkg/applyconfiguration/testdata/cronjob/{applyconfiguration/testdata/cronjob => api/v1/applyconfiguration/api/v1}/nestedstructwithseveralfields.go (98%) rename pkg/applyconfiguration/testdata/cronjob/{applyconfiguration/testdata/cronjob => api/v1/applyconfiguration/api/v1}/preserved.go (98%) rename pkg/applyconfiguration/testdata/cronjob/{applyconfiguration/testdata/cronjob => api/v1/applyconfiguration/api/v1}/rootobject.go (98%) rename pkg/applyconfiguration/testdata/cronjob/{applyconfiguration/testdata/cronjob => api/v1/applyconfiguration/api/v1}/unexportedstruct.go (98%) rename pkg/applyconfiguration/testdata/cronjob/{ => api/v1}/applyconfiguration/internal/internal.go (100%) create mode 100644 pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/utils.go rename pkg/applyconfiguration/testdata/cronjob/{ => api/v1}/cronjob_types.go (99%) rename pkg/applyconfiguration/testdata/cronjob/{ => api/v1}/groupversion_info.go (98%) delete mode 100644 pkg/applyconfiguration/testdata/cronjob/applyconfiguration/utils.go diff --git a/pkg/applyconfiguration/applyconfiguration_integration_test.go b/pkg/applyconfiguration/applyconfiguration_integration_test.go index 1e4d0682e..b3382f971 100644 --- a/pkg/applyconfiguration/applyconfiguration_integration_test.go +++ b/pkg/applyconfiguration/applyconfiguration_integration_test.go @@ -76,7 +76,7 @@ var _ = Describe("ApplyConfiguration generation from API types", func() { // Copy the testdata directory, but removed the generated files. Expect(os.CopyFS(tmpDir, os.DirFS(cronjobDir))).To(Succeed(), "Should be able to copy source files") - Expect(os.RemoveAll(filepath.Join(tmpDir, applyConfigurationDir))).To(Succeed(), "Should be able to remove generated file from temp directory") + Expect(os.RemoveAll(filepath.Join(tmpDir, "api/v1", applyConfigurationDir))).To(Succeed(), "Should be able to remove generated file from temp directory") }) By("Switching into testdata to appease go modules", func() { @@ -97,7 +97,7 @@ var _ = Describe("ApplyConfiguration generation from API types", func() { }) DescribeTable("should be able to verify generated ApplyConfiguration types for the CronJob schema", func(outputPackage string) { - Expect(replaceOutputPkgMarker(".", outputPackage)).To(Succeed()) + Expect(replaceOutputPkgMarker("./api/v1", outputPackage)).To(Succeed()) // The output is used to capture the generated CRD file. // The output of the applyconfiguration cannot be generated to memory, gengo handles all of the writing to disk directly. @@ -105,19 +105,21 @@ var _ = Describe("ApplyConfiguration generation from API types", func() { By("Initializing the runtime") optionsRegistry := &markers.Registry{} + Expect(genall.RegisterOptionsMarkers(optionsRegistry)).To(Succeed()) Expect(optionsRegistry.Register(markers.Must(markers.MakeDefinition("crd", markers.DescribesPackage, crd.Generator{})))).To(Succeed()) Expect(optionsRegistry.Register(markers.Must(markers.MakeDefinition("applyconfiguration", markers.DescribesPackage, Generator{})))).To(Succeed()) rt, err := genall.FromOptions(optionsRegistry, []string{ "crd:allowDangerousTypes=true,ignoreUnexportedFields=true", // Run another generator first to make sure they don't interfere; see also: the comment on cronjob_types.go:UntypedBlob "applyconfiguration", + "paths=./api/v1", }) Expect(err).NotTo(HaveOccurred()) rt.OutputRules = genall.OutputRules{Default: output} originalFS := os.DirFS(filepath.Join(originalCWD, cronjobDir)) - tmpFS := os.DirFS(".") + tmpFS := os.DirFS("./api/v1") By("Running the generator") hadErrs := rt.Run() @@ -127,7 +129,7 @@ var _ = Describe("ApplyConfiguration generation from API types", func() { filesInOriginal := make(map[string][]byte) originalFileNames := sets.New[string]() - Expect(fs.WalkDir(originalFS, applyConfigurationDir, func(path string, d fs.DirEntry, err error) error { + Expect(fs.WalkDir(originalFS, filepath.Join("api/v1", applyConfigurationDir), func(path string, d fs.DirEntry, err error) error { if err != nil { return err } @@ -142,7 +144,7 @@ var _ = Describe("ApplyConfiguration generation from API types", func() { } // Record the path without the path prefix for comparison later. - path = strings.TrimPrefix(path, applyConfigurationDir+"/") + path = strings.TrimPrefix(path, filepath.Join("api/v1", applyConfigurationDir)+"/") originalFileNames.Insert(path) filesInOriginal[path] = data return nil @@ -159,7 +161,7 @@ var _ = Describe("ApplyConfiguration generation from API types", func() { return nil } - data, err := os.ReadFile(path) + data, err := os.ReadFile(filepath.Join("./api/v1", path)) if err != nil { return fmt.Errorf("error reading file %s: %w", path, err) } @@ -179,7 +181,7 @@ var _ = Describe("ApplyConfiguration generation from API types", func() { content = []byte(strings.Replace(string(content), "package applyconfiguration", fmt.Sprintf("package %s", outputPackage), 1)) // Make sure the import paths are correct for the newly generated content. - content = []byte(strings.ReplaceAll(string(content), "testdata/cronjob/applyconfiguration", fmt.Sprintf("testdata/cronjob/%s", outputPackage))) + content = []byte(strings.ReplaceAll(string(content), "testdata/cronjob/api/v1/applyconfiguration", fmt.Sprintf("testdata/cronjob/api/v1/%s", outputPackage))) Expect(string(filesInOutput[name])).To(BeComparableTo(string(content)), "Generated files should match the checked in files, diff found in %s", name) } diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/associativetype.go b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/associativetype.go similarity index 99% rename from pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/associativetype.go rename to pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/associativetype.go index b3dd678b0..b87f5b537 100644 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/associativetype.go +++ b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/associativetype.go @@ -1,6 +1,6 @@ // Code generated by applyconfiguration. DO NOT EDIT. -package cronjob +package v1 // AssociativeTypeApplyConfiguration represents a declarative configuration of the AssociativeType type for use // with apply. diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/containsnestedmap.go b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/containsnestedmap.go similarity index 98% rename from pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/containsnestedmap.go rename to pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/containsnestedmap.go index 22bf67cbc..8ce4471cd 100644 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/containsnestedmap.go +++ b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/containsnestedmap.go @@ -1,6 +1,6 @@ // Code generated by applyconfiguration. DO NOT EDIT. -package cronjob +package v1 // ContainsNestedMapApplyConfiguration represents a declarative configuration of the ContainsNestedMap type for use // with apply. diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjob.go b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/cronjob.go similarity index 93% rename from pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjob.go rename to pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/cronjob.go index aa223f677..0b66b4b6a 100644 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjob.go +++ b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/cronjob.go @@ -1,20 +1,20 @@ // Code generated by applyconfiguration. DO NOT EDIT. -package cronjob +package v1 import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apismetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" - v1 "k8s.io/client-go/applyconfigurations/meta/v1" + metav1 "k8s.io/client-go/applyconfigurations/meta/v1" ) // CronJobApplyConfiguration represents a declarative configuration of the CronJob type for use // with apply. type CronJobApplyConfiguration struct { - v1.TypeMetaApplyConfiguration `json:",inline"` - *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` - Spec *CronJobSpecApplyConfiguration `json:"spec,omitempty"` - Status *CronJobStatusApplyConfiguration `json:"status,omitempty"` + metav1.TypeMetaApplyConfiguration `json:",inline"` + *metav1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *CronJobSpecApplyConfiguration `json:"spec,omitempty"` + Status *CronJobStatusApplyConfiguration `json:"status,omitempty"` } // CronJob constructs a declarative configuration of the CronJob type for use with @@ -24,7 +24,7 @@ func CronJob(name, namespace string) *CronJobApplyConfiguration { b.WithName(name) b.WithNamespace(namespace) b.WithKind("CronJob") - b.WithAPIVersion("testdata/cronjob") + b.WithAPIVersion("api/v1") return b } @@ -101,7 +101,7 @@ func (b *CronJobApplyConfiguration) WithGeneration(value int64) *CronJobApplyCon // WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the CreationTimestamp field is set to the value of the last call. -func (b *CronJobApplyConfiguration) WithCreationTimestamp(value metav1.Time) *CronJobApplyConfiguration { +func (b *CronJobApplyConfiguration) WithCreationTimestamp(value apismetav1.Time) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.ObjectMetaApplyConfiguration.CreationTimestamp = &value return b @@ -110,7 +110,7 @@ func (b *CronJobApplyConfiguration) WithCreationTimestamp(value metav1.Time) *Cr // WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the DeletionTimestamp field is set to the value of the last call. -func (b *CronJobApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *CronJobApplyConfiguration { +func (b *CronJobApplyConfiguration) WithDeletionTimestamp(value apismetav1.Time) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.ObjectMetaApplyConfiguration.DeletionTimestamp = &value return b @@ -158,7 +158,7 @@ func (b *CronJobApplyConfiguration) WithAnnotations(entries map[string]string) * // WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. // If called multiple times, values provided by each call will be appended to the OwnerReferences field. -func (b *CronJobApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *CronJobApplyConfiguration { +func (b *CronJobApplyConfiguration) WithOwnerReferences(values ...*metav1.OwnerReferenceApplyConfiguration) *CronJobApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() for i := range values { if values[i] == nil { @@ -182,7 +182,7 @@ func (b *CronJobApplyConfiguration) WithFinalizers(values ...string) *CronJobApp func (b *CronJobApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { if b.ObjectMetaApplyConfiguration == nil { - b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + b.ObjectMetaApplyConfiguration = &metav1.ObjectMetaApplyConfiguration{} } } diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/cronjobspec.go similarity index 94% rename from pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go rename to pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/cronjobspec.go index 6160862da..2357d9d78 100644 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobspec.go +++ b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/cronjobspec.go @@ -1,13 +1,13 @@ // Code generated by applyconfiguration. DO NOT EDIT. -package cronjob +package v1 import ( v1beta1 "k8s.io/api/batch/v1beta1" - v1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" intstr "k8s.io/apimachinery/pkg/util/intstr" - testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob" + apiv1 "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob/api/v1" ) // CronJobSpecApplyConfiguration represents a declarative configuration of the CronJobSpec type for use @@ -15,9 +15,9 @@ import ( type CronJobSpecApplyConfiguration struct { Schedule *string `json:"schedule,omitempty"` StartingDeadlineSeconds *int64 `json:"startingDeadlineSeconds,omitempty"` - ConcurrencyPolicy *testdatacronjob.ConcurrencyPolicy `json:"concurrencyPolicy,omitempty"` + ConcurrencyPolicy *apiv1.ConcurrencyPolicy `json:"concurrencyPolicy,omitempty"` Suspend *bool `json:"suspend,omitempty"` - NoReallySuspend *testdatacronjob.TotallyABool `json:"noReallySuspend,omitempty"` + NoReallySuspend *apiv1.TotallyABool `json:"noReallySuspend,omitempty"` BinaryName []byte `json:"binaryName,omitempty"` CanBeNull *string `json:"canBeNull,omitempty"` JobTemplate *v1beta1.JobTemplateSpec `json:"jobTemplate,omitempty"` @@ -27,7 +27,7 @@ type CronJobSpecApplyConfiguration struct { StringSliceData map[string][]string `json:"stringSliceData,omitempty"` PtrData map[string]*string `json:"ptrData,omitempty"` TwoOfAKindPart0 *string `json:"twoOfAKindPart0,omitempty"` - TwoOfAKindPart1 *testdatacronjob.LongerString `json:"twoOfAKindPart1,omitempty"` + TwoOfAKindPart1 *apiv1.LongerString `json:"twoOfAKindPart1,omitempty"` DefaultedString *string `json:"defaultedString,omitempty"` DefaultedSlice []string `json:"defaultedSlice,omitempty"` DefaultedObject []RootObjectApplyConfiguration `json:"defaultedObject,omitempty"` @@ -49,9 +49,9 @@ type CronJobSpecApplyConfiguration struct { UnprunedFromType *PreservedApplyConfiguration `json:"unprunedFomType,omitempty"` UnprunedFromTypeAndField *PreservedApplyConfiguration `json:"unprunedFomTypeAndField,omitempty"` AssociativeList []AssociativeTypeApplyConfiguration `json:"associativeList,omitempty"` - NestedAssociativeList *testdatacronjob.NestedAssociativeList `json:"nestedassociativeList,omitempty"` + NestedAssociativeList *apiv1.NestedAssociativeList `json:"nestedassociativeList,omitempty"` MapOfInfo map[string][]byte `json:"mapOfInfo,omitempty"` - NestedMapOfInfo *testdatacronjob.NestedMapOfInfo `json:"nestedMapOfInfo,omitempty"` + NestedMapOfInfo *apiv1.NestedMapOfInfo `json:"nestedMapOfInfo,omitempty"` StructWithSeveralFields *NestedObjectApplyConfiguration `json:"structWithSeveralFields,omitempty"` NestedStructWithSeveralFields *NestedStructWithSeveralFieldsApplyConfiguration `json:"nestedStructWithSeveralFields,omitempty"` NestedStructWithSeveralFieldsDoubleMarked *NestedStructWithSeveralFieldsApplyConfiguration `json:"nestedStructWithSeveralFieldsDoubleMarked,omitempty"` @@ -73,25 +73,25 @@ type CronJobSpecApplyConfiguration struct { Int32WithValidations *int32 `json:"int32WithValidations,omitempty"` unexportedStructApplyConfiguration `json:",inline"` ExportedStructApplyConfiguration `json:",inline"` - StringWithEvenLength *string `json:"stringWithEvenLength,omitempty"` - StringWithEvenLengthAndMessageExpression *string `json:"stringWithEvenLengthAndMessageExpression,omitempty"` - StringWithEvenLengthAndGoodPrefix *testdatacronjob.StringEvenType `json:"stringWithEvenLengthAndGoodPrefix,omitempty"` - ForbiddenInt *int `json:"forbiddenInt,omitempty"` - Array *[3]int `json:"array,omitempty"` - ArrayUsingCompositeLiteral *[3]string `json:"arrayUsingCompositeLiteral,omitempty"` - Hosts []string `json:"hosts,omitempty"` - EnumSlice []int `json:"enumSlice,omitempty"` - HostsAlias *testdatacronjob.Hosts `json:"hostsAlias,omitempty"` - AliasFromPackage *v1.IPFamilyPolicy `json:"aliasFromPackage,omitempty"` - StringAlias *string `json:"stringAlias,omitempty"` - StringAliasPtr *string `json:"stringAliasPtr,omitempty"` - StringAliasAddedValidation *string `json:"stringAliasAddedValidation,omitempty"` - StringAliasAlreadyValidated *string `json:"stringAliasAlreadyValidated,omitempty"` - StringPair []string `json:"stringPair,omitempty"` - LongerStringArray []testdatacronjob.LongerString `json:"longerStringArray,omitempty"` - IntOrStringArrayWithAPattern []*intstr.IntOrString `json:"intOrStringArrayWithAPattern,omitempty"` - Protocol *v1.Protocol `json:"protocol,omitempty"` - SelectableFieldString *string `json:"selectableFieldString,omitempty"` + StringWithEvenLength *string `json:"stringWithEvenLength,omitempty"` + StringWithEvenLengthAndMessageExpression *string `json:"stringWithEvenLengthAndMessageExpression,omitempty"` + StringWithEvenLengthAndGoodPrefix *apiv1.StringEvenType `json:"stringWithEvenLengthAndGoodPrefix,omitempty"` + ForbiddenInt *int `json:"forbiddenInt,omitempty"` + Array *[3]int `json:"array,omitempty"` + ArrayUsingCompositeLiteral *[3]string `json:"arrayUsingCompositeLiteral,omitempty"` + Hosts []string `json:"hosts,omitempty"` + EnumSlice []int `json:"enumSlice,omitempty"` + HostsAlias *apiv1.Hosts `json:"hostsAlias,omitempty"` + AliasFromPackage *corev1.IPFamilyPolicy `json:"aliasFromPackage,omitempty"` + StringAlias *string `json:"stringAlias,omitempty"` + StringAliasPtr *string `json:"stringAliasPtr,omitempty"` + StringAliasAddedValidation *string `json:"stringAliasAddedValidation,omitempty"` + StringAliasAlreadyValidated *string `json:"stringAliasAlreadyValidated,omitempty"` + StringPair []string `json:"stringPair,omitempty"` + LongerStringArray []apiv1.LongerString `json:"longerStringArray,omitempty"` + IntOrStringArrayWithAPattern []*intstr.IntOrString `json:"intOrStringArrayWithAPattern,omitempty"` + Protocol *corev1.Protocol `json:"protocol,omitempty"` + SelectableFieldString *string `json:"selectableFieldString,omitempty"` EmbeddedStructApplyConfiguration `json:",inline"` OnlyAllowSettingOnUpdate *int32 `json:"onlyAllowSettingOnUpdate,omitempty"` } @@ -121,7 +121,7 @@ func (b *CronJobSpecApplyConfiguration) WithStartingDeadlineSeconds(value int64) // WithConcurrencyPolicy sets the ConcurrencyPolicy field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the ConcurrencyPolicy field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithConcurrencyPolicy(value testdatacronjob.ConcurrencyPolicy) *CronJobSpecApplyConfiguration { +func (b *CronJobSpecApplyConfiguration) WithConcurrencyPolicy(value apiv1.ConcurrencyPolicy) *CronJobSpecApplyConfiguration { b.ConcurrencyPolicy = &value return b } @@ -137,7 +137,7 @@ func (b *CronJobSpecApplyConfiguration) WithSuspend(value bool) *CronJobSpecAppl // WithNoReallySuspend sets the NoReallySuspend field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the NoReallySuspend field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithNoReallySuspend(value testdatacronjob.TotallyABool) *CronJobSpecApplyConfiguration { +func (b *CronJobSpecApplyConfiguration) WithNoReallySuspend(value apiv1.TotallyABool) *CronJobSpecApplyConfiguration { b.NoReallySuspend = &value return b } @@ -237,7 +237,7 @@ func (b *CronJobSpecApplyConfiguration) WithTwoOfAKindPart0(value string) *CronJ // WithTwoOfAKindPart1 sets the TwoOfAKindPart1 field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the TwoOfAKindPart1 field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithTwoOfAKindPart1(value testdatacronjob.LongerString) *CronJobSpecApplyConfiguration { +func (b *CronJobSpecApplyConfiguration) WithTwoOfAKindPart1(value apiv1.LongerString) *CronJobSpecApplyConfiguration { b.TwoOfAKindPart1 = &value return b } @@ -448,7 +448,7 @@ func (b *CronJobSpecApplyConfiguration) WithAssociativeList(values ...*Associati // WithNestedAssociativeList sets the NestedAssociativeList field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the NestedAssociativeList field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithNestedAssociativeList(value testdatacronjob.NestedAssociativeList) *CronJobSpecApplyConfiguration { +func (b *CronJobSpecApplyConfiguration) WithNestedAssociativeList(value apiv1.NestedAssociativeList) *CronJobSpecApplyConfiguration { b.NestedAssociativeList = &value return b } @@ -470,7 +470,7 @@ func (b *CronJobSpecApplyConfiguration) WithMapOfInfo(entries map[string][]byte) // WithNestedMapOfInfo sets the NestedMapOfInfo field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the NestedMapOfInfo field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithNestedMapOfInfo(value testdatacronjob.NestedMapOfInfo) *CronJobSpecApplyConfiguration { +func (b *CronJobSpecApplyConfiguration) WithNestedMapOfInfo(value apiv1.NestedMapOfInfo) *CronJobSpecApplyConfiguration { b.NestedMapOfInfo = &value return b } @@ -688,7 +688,7 @@ func (b *CronJobSpecApplyConfiguration) WithStringWithEvenLengthAndMessageExpres // WithStringWithEvenLengthAndGoodPrefix sets the StringWithEvenLengthAndGoodPrefix field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the StringWithEvenLengthAndGoodPrefix field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithStringWithEvenLengthAndGoodPrefix(value testdatacronjob.StringEvenType) *CronJobSpecApplyConfiguration { +func (b *CronJobSpecApplyConfiguration) WithStringWithEvenLengthAndGoodPrefix(value apiv1.StringEvenType) *CronJobSpecApplyConfiguration { b.StringWithEvenLengthAndGoodPrefix = &value return b } @@ -740,7 +740,7 @@ func (b *CronJobSpecApplyConfiguration) WithEnumSlice(values ...int) *CronJobSpe // WithHostsAlias sets the HostsAlias field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the HostsAlias field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithHostsAlias(value testdatacronjob.Hosts) *CronJobSpecApplyConfiguration { +func (b *CronJobSpecApplyConfiguration) WithHostsAlias(value apiv1.Hosts) *CronJobSpecApplyConfiguration { b.HostsAlias = &value return b } @@ -748,7 +748,7 @@ func (b *CronJobSpecApplyConfiguration) WithHostsAlias(value testdatacronjob.Hos // WithAliasFromPackage sets the AliasFromPackage field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the AliasFromPackage field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithAliasFromPackage(value v1.IPFamilyPolicy) *CronJobSpecApplyConfiguration { +func (b *CronJobSpecApplyConfiguration) WithAliasFromPackage(value corev1.IPFamilyPolicy) *CronJobSpecApplyConfiguration { b.AliasFromPackage = &value return b } @@ -798,7 +798,7 @@ func (b *CronJobSpecApplyConfiguration) WithStringPair(values ...string) *CronJo // WithLongerStringArray adds the given value to the LongerStringArray field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. // If called multiple times, values provided by each call will be appended to the LongerStringArray field. -func (b *CronJobSpecApplyConfiguration) WithLongerStringArray(values ...testdatacronjob.LongerString) *CronJobSpecApplyConfiguration { +func (b *CronJobSpecApplyConfiguration) WithLongerStringArray(values ...apiv1.LongerString) *CronJobSpecApplyConfiguration { for i := range values { b.LongerStringArray = append(b.LongerStringArray, values[i]) } @@ -821,7 +821,7 @@ func (b *CronJobSpecApplyConfiguration) WithIntOrStringArrayWithAPattern(values // WithProtocol sets the Protocol field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the Protocol field is set to the value of the last call. -func (b *CronJobSpecApplyConfiguration) WithProtocol(value v1.Protocol) *CronJobSpecApplyConfiguration { +func (b *CronJobSpecApplyConfiguration) WithProtocol(value corev1.Protocol) *CronJobSpecApplyConfiguration { b.Protocol = &value return b } diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/cronjobstatus.go similarity index 83% rename from pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go rename to pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/cronjobstatus.go index 9483ba401..22886a73a 100644 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/cronjobstatus.go +++ b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/cronjobstatus.go @@ -1,24 +1,24 @@ // Code generated by applyconfiguration. DO NOT EDIT. -package cronjob +package v1 import ( - v1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob" + apiv1 "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob/api/v1" ) // CronJobStatusApplyConfiguration represents a declarative configuration of the CronJobStatus type for use // with apply. type CronJobStatusApplyConfiguration struct { - Active []v1.ObjectReference `json:"active,omitempty"` + Active []corev1.ObjectReference `json:"active,omitempty"` LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty"` - LastScheduleTime2 *testdatacronjob.Time2 `json:"lastScheduleTime2,omitempty"` + LastScheduleTime2 *apiv1.Time2 `json:"lastScheduleTime2,omitempty"` LastScheduleMicroTime *metav1.MicroTime `json:"lastScheduleMicroTime,omitempty"` - LastActiveLogURL *testdatacronjob.URL `json:"lastActiveLogURL,omitempty"` - LastActiveLogURL2 *testdatacronjob.URL2 `json:"lastActiveLogURL2,omitempty"` - LastActiveLogURL3 *testdatacronjob.URL3 `json:"lastActiveLogURL3,omitempty"` - LastActiveLogURL4 *testdatacronjob.URL4 `json:"lastActiveLogURL4,omitempty"` + LastActiveLogURL *apiv1.URL `json:"lastActiveLogURL,omitempty"` + LastActiveLogURL2 *apiv1.URL2 `json:"lastActiveLogURL2,omitempty"` + LastActiveLogURL3 *apiv1.URL3 `json:"lastActiveLogURL3,omitempty"` + LastActiveLogURL4 *apiv1.URL4 `json:"lastActiveLogURL4,omitempty"` Runtime *DurationApplyConfiguration `json:"duration,omitempty"` } @@ -31,7 +31,7 @@ func CronJobStatus() *CronJobStatusApplyConfiguration { // WithActive adds the given value to the Active field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. // If called multiple times, values provided by each call will be appended to the Active field. -func (b *CronJobStatusApplyConfiguration) WithActive(values ...v1.ObjectReference) *CronJobStatusApplyConfiguration { +func (b *CronJobStatusApplyConfiguration) WithActive(values ...corev1.ObjectReference) *CronJobStatusApplyConfiguration { for i := range values { b.Active = append(b.Active, values[i]) } @@ -49,7 +49,7 @@ func (b *CronJobStatusApplyConfiguration) WithLastScheduleTime(value metav1.Time // WithLastScheduleTime2 sets the LastScheduleTime2 field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the LastScheduleTime2 field is set to the value of the last call. -func (b *CronJobStatusApplyConfiguration) WithLastScheduleTime2(value testdatacronjob.Time2) *CronJobStatusApplyConfiguration { +func (b *CronJobStatusApplyConfiguration) WithLastScheduleTime2(value apiv1.Time2) *CronJobStatusApplyConfiguration { b.LastScheduleTime2 = &value return b } @@ -65,7 +65,7 @@ func (b *CronJobStatusApplyConfiguration) WithLastScheduleMicroTime(value metav1 // WithLastActiveLogURL sets the LastActiveLogURL field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the LastActiveLogURL field is set to the value of the last call. -func (b *CronJobStatusApplyConfiguration) WithLastActiveLogURL(value testdatacronjob.URL) *CronJobStatusApplyConfiguration { +func (b *CronJobStatusApplyConfiguration) WithLastActiveLogURL(value apiv1.URL) *CronJobStatusApplyConfiguration { b.LastActiveLogURL = &value return b } @@ -73,7 +73,7 @@ func (b *CronJobStatusApplyConfiguration) WithLastActiveLogURL(value testdatacro // WithLastActiveLogURL2 sets the LastActiveLogURL2 field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the LastActiveLogURL2 field is set to the value of the last call. -func (b *CronJobStatusApplyConfiguration) WithLastActiveLogURL2(value testdatacronjob.URL2) *CronJobStatusApplyConfiguration { +func (b *CronJobStatusApplyConfiguration) WithLastActiveLogURL2(value apiv1.URL2) *CronJobStatusApplyConfiguration { b.LastActiveLogURL2 = &value return b } @@ -81,7 +81,7 @@ func (b *CronJobStatusApplyConfiguration) WithLastActiveLogURL2(value testdatacr // WithLastActiveLogURL3 sets the LastActiveLogURL3 field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the LastActiveLogURL3 field is set to the value of the last call. -func (b *CronJobStatusApplyConfiguration) WithLastActiveLogURL3(value testdatacronjob.URL3) *CronJobStatusApplyConfiguration { +func (b *CronJobStatusApplyConfiguration) WithLastActiveLogURL3(value apiv1.URL3) *CronJobStatusApplyConfiguration { b.LastActiveLogURL3 = &value return b } @@ -89,7 +89,7 @@ func (b *CronJobStatusApplyConfiguration) WithLastActiveLogURL3(value testdatacr // WithLastActiveLogURL4 sets the LastActiveLogURL4 field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the LastActiveLogURL4 field is set to the value of the last call. -func (b *CronJobStatusApplyConfiguration) WithLastActiveLogURL4(value testdatacronjob.URL4) *CronJobStatusApplyConfiguration { +func (b *CronJobStatusApplyConfiguration) WithLastActiveLogURL4(value apiv1.URL4) *CronJobStatusApplyConfiguration { b.LastActiveLogURL4 = &value return b } diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/duration.go b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/duration.go similarity index 98% rename from pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/duration.go rename to pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/duration.go index 4a529a0fe..3fc540f17 100644 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/duration.go +++ b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/duration.go @@ -1,6 +1,6 @@ // Code generated by applyconfiguration. DO NOT EDIT. -package cronjob +package v1 import ( time "time" diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/embeddedstruct.go b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/embeddedstruct.go similarity index 98% rename from pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/embeddedstruct.go rename to pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/embeddedstruct.go index 8c4d6a3dc..8dfbb200f 100644 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/embeddedstruct.go +++ b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/embeddedstruct.go @@ -1,6 +1,6 @@ // Code generated by applyconfiguration. DO NOT EDIT. -package cronjob +package v1 // EmbeddedStructApplyConfiguration represents a declarative configuration of the EmbeddedStruct type for use // with apply. diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/empiableobject.go b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/empiableobject.go similarity index 98% rename from pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/empiableobject.go rename to pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/empiableobject.go index 92ee64426..201c5493c 100644 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/empiableobject.go +++ b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/empiableobject.go @@ -1,6 +1,6 @@ // Code generated by applyconfiguration. DO NOT EDIT. -package cronjob +package v1 // EmpiableObjectApplyConfiguration represents a declarative configuration of the EmpiableObject type for use // with apply. diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/exportedstruct.go b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/exportedstruct.go similarity index 98% rename from pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/exportedstruct.go rename to pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/exportedstruct.go index d0b9b8688..73cdedeb1 100644 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/exportedstruct.go +++ b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/exportedstruct.go @@ -1,6 +1,6 @@ // Code generated by applyconfiguration. DO NOT EDIT. -package cronjob +package v1 // ExportedStructApplyConfiguration represents a declarative configuration of the ExportedStruct type for use // with apply. diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/justnestedobject.go b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/justnestedobject.go similarity index 98% rename from pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/justnestedobject.go rename to pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/justnestedobject.go index 81b8f881f..9ac372f6f 100644 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/justnestedobject.go +++ b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/justnestedobject.go @@ -1,6 +1,6 @@ // Code generated by applyconfiguration. DO NOT EDIT. -package cronjob +package v1 // JustNestedObjectApplyConfiguration represents a declarative configuration of the JustNestedObject type for use // with apply. diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/minmaxobject.go b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/minmaxobject.go similarity index 99% rename from pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/minmaxobject.go rename to pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/minmaxobject.go index 8e1a5f4fc..d42590a14 100644 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/minmaxobject.go +++ b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/minmaxobject.go @@ -1,6 +1,6 @@ // Code generated by applyconfiguration. DO NOT EDIT. -package cronjob +package v1 // MinMaxObjectApplyConfiguration represents a declarative configuration of the MinMaxObject type for use // with apply. diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/nestedobject.go b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/nestedobject.go similarity index 98% rename from pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/nestedobject.go rename to pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/nestedobject.go index 167d029b9..c71d89350 100644 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/nestedobject.go +++ b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/nestedobject.go @@ -1,6 +1,6 @@ // Code generated by applyconfiguration. DO NOT EDIT. -package cronjob +package v1 // NestedObjectApplyConfiguration represents a declarative configuration of the NestedObject type for use // with apply. diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/nestedstructwithseveralfields.go b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/nestedstructwithseveralfields.go similarity index 98% rename from pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/nestedstructwithseveralfields.go rename to pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/nestedstructwithseveralfields.go index 02c65cae9..90433a899 100644 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/nestedstructwithseveralfields.go +++ b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/nestedstructwithseveralfields.go @@ -1,6 +1,6 @@ // Code generated by applyconfiguration. DO NOT EDIT. -package cronjob +package v1 // NestedStructWithSeveralFieldsApplyConfiguration represents a declarative configuration of the NestedStructWithSeveralFields type for use // with apply. diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/preserved.go b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/preserved.go similarity index 98% rename from pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/preserved.go rename to pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/preserved.go index 4e0ea6635..1decb4dd3 100644 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/preserved.go +++ b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/preserved.go @@ -1,6 +1,6 @@ // Code generated by applyconfiguration. DO NOT EDIT. -package cronjob +package v1 // PreservedApplyConfiguration represents a declarative configuration of the Preserved type for use // with apply. diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/rootobject.go b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/rootobject.go similarity index 98% rename from pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/rootobject.go rename to pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/rootobject.go index fcc4b850d..746a475b6 100644 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/rootobject.go +++ b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/rootobject.go @@ -1,6 +1,6 @@ // Code generated by applyconfiguration. DO NOT EDIT. -package cronjob +package v1 // RootObjectApplyConfiguration represents a declarative configuration of the RootObject type for use // with apply. diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/unexportedstruct.go b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/unexportedstruct.go similarity index 98% rename from pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/unexportedstruct.go rename to pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/unexportedstruct.go index d7a5a097a..966d65cab 100644 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob/unexportedstruct.go +++ b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1/unexportedstruct.go @@ -1,6 +1,6 @@ // Code generated by applyconfiguration. DO NOT EDIT. -package cronjob +package v1 // UnexportedStructApplyConfiguration represents a declarative configuration of the UnexportedStruct type for use // with apply. diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/internal/internal.go b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/internal/internal.go similarity index 100% rename from pkg/applyconfiguration/testdata/cronjob/applyconfiguration/internal/internal.go rename to pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/internal/internal.go diff --git a/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/utils.go b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/utils.go new file mode 100644 index 000000000..314abe174 --- /dev/null +++ b/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/utils.go @@ -0,0 +1,58 @@ +// Code generated by applyconfiguration. DO NOT EDIT. + +package applyconfiguration + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + testing "k8s.io/client-go/testing" + v1 "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob/api/v1" + apiv1 "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/api/v1" + internal "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration/internal" +) + +// ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no +// apply configuration type exists for the given GroupVersionKind. +func ForKind(kind schema.GroupVersionKind) interface{} { + switch kind { + // Group=api, Version=v1 + case v1.SchemeGroupVersion.WithKind("AssociativeType"): + return &apiv1.AssociativeTypeApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("ContainsNestedMap"): + return &apiv1.ContainsNestedMapApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("CronJob"): + return &apiv1.CronJobApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("CronJobSpec"): + return &apiv1.CronJobSpecApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("CronJobStatus"): + return &apiv1.CronJobStatusApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("Duration"): + return &apiv1.DurationApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("EmbeddedStruct"): + return &apiv1.EmbeddedStructApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("EmpiableObject"): + return &apiv1.EmpiableObjectApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("ExportedStruct"): + return &apiv1.ExportedStructApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("JustNestedObject"): + return &apiv1.JustNestedObjectApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("MinMaxObject"): + return &apiv1.MinMaxObjectApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("NestedObject"): + return &apiv1.NestedObjectApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("NestedStructWithSeveralFields"): + return &apiv1.NestedStructWithSeveralFieldsApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("Preserved"): + return &apiv1.PreservedApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("RootObject"): + return &apiv1.RootObjectApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("UnexportedStruct"): + return &apiv1.unexportedStructApplyConfiguration{} + + } + return nil +} + +func NewTypeConverter(scheme *runtime.Scheme) *testing.TypeConverter { + return &testing.TypeConverter{Scheme: scheme, TypeResolver: internal.Parser()} +} diff --git a/pkg/applyconfiguration/testdata/cronjob/cronjob_types.go b/pkg/applyconfiguration/testdata/cronjob/api/v1/cronjob_types.go similarity index 99% rename from pkg/applyconfiguration/testdata/cronjob/cronjob_types.go rename to pkg/applyconfiguration/testdata/cronjob/api/v1/cronjob_types.go index 5d62d1f44..c1010c4b3 100644 --- a/pkg/applyconfiguration/testdata/cronjob/cronjob_types.go +++ b/pkg/applyconfiguration/testdata/cronjob/api/v1/cronjob_types.go @@ -20,7 +20,7 @@ limitations under the License. // +groupName=testdata.kubebuilder.io // +versionName=v1 -package testdata +package v1 import ( "encoding" diff --git a/pkg/applyconfiguration/testdata/cronjob/groupversion_info.go b/pkg/applyconfiguration/testdata/cronjob/api/v1/groupversion_info.go similarity index 98% rename from pkg/applyconfiguration/testdata/cronjob/groupversion_info.go rename to pkg/applyconfiguration/testdata/cronjob/api/v1/groupversion_info.go index ea7ce82a5..569e35bba 100644 --- a/pkg/applyconfiguration/testdata/cronjob/groupversion_info.go +++ b/pkg/applyconfiguration/testdata/cronjob/api/v1/groupversion_info.go @@ -18,7 +18,7 @@ limitations under the License. // +versionName=v1 // +kubebuilder:ac:generate=true // +kubebuilder:ac:output:package="applyconfiguration" -package testdata +package v1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/utils.go b/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/utils.go deleted file mode 100644 index 2f4a9b7a7..000000000 --- a/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/utils.go +++ /dev/null @@ -1,58 +0,0 @@ -// Code generated by applyconfiguration. DO NOT EDIT. - -package applyconfiguration - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - testing "k8s.io/client-go/testing" - cronjob "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob" - internal "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/internal" - testdatacronjob "sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob/applyconfiguration/testdata/cronjob" -) - -// ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no -// apply configuration type exists for the given GroupVersionKind. -func ForKind(kind schema.GroupVersionKind) interface{} { - switch kind { - // Group=testdata, Version=cronjob - case cronjob.SchemeGroupVersion.WithKind("AssociativeType"): - return &testdatacronjob.AssociativeTypeApplyConfiguration{} - case cronjob.SchemeGroupVersion.WithKind("ContainsNestedMap"): - return &testdatacronjob.ContainsNestedMapApplyConfiguration{} - case cronjob.SchemeGroupVersion.WithKind("CronJob"): - return &testdatacronjob.CronJobApplyConfiguration{} - case cronjob.SchemeGroupVersion.WithKind("CronJobSpec"): - return &testdatacronjob.CronJobSpecApplyConfiguration{} - case cronjob.SchemeGroupVersion.WithKind("CronJobStatus"): - return &testdatacronjob.CronJobStatusApplyConfiguration{} - case cronjob.SchemeGroupVersion.WithKind("Duration"): - return &testdatacronjob.DurationApplyConfiguration{} - case cronjob.SchemeGroupVersion.WithKind("EmbeddedStruct"): - return &testdatacronjob.EmbeddedStructApplyConfiguration{} - case cronjob.SchemeGroupVersion.WithKind("EmpiableObject"): - return &testdatacronjob.EmpiableObjectApplyConfiguration{} - case cronjob.SchemeGroupVersion.WithKind("ExportedStruct"): - return &testdatacronjob.ExportedStructApplyConfiguration{} - case cronjob.SchemeGroupVersion.WithKind("JustNestedObject"): - return &testdatacronjob.JustNestedObjectApplyConfiguration{} - case cronjob.SchemeGroupVersion.WithKind("MinMaxObject"): - return &testdatacronjob.MinMaxObjectApplyConfiguration{} - case cronjob.SchemeGroupVersion.WithKind("NestedObject"): - return &testdatacronjob.NestedObjectApplyConfiguration{} - case cronjob.SchemeGroupVersion.WithKind("NestedStructWithSeveralFields"): - return &testdatacronjob.NestedStructWithSeveralFieldsApplyConfiguration{} - case cronjob.SchemeGroupVersion.WithKind("Preserved"): - return &testdatacronjob.PreservedApplyConfiguration{} - case cronjob.SchemeGroupVersion.WithKind("RootObject"): - return &testdatacronjob.RootObjectApplyConfiguration{} - case cronjob.SchemeGroupVersion.WithKind("UnexportedStruct"): - return &testdatacronjob.unexportedStructApplyConfiguration{} - - } - return nil -} - -func NewTypeConverter(scheme *runtime.Scheme) *testing.TypeConverter { - return &testing.TypeConverter{Scheme: scheme, TypeResolver: internal.Parser()} -} From 0023b019018574aeff3c0a1b7fdd5eb735cba5bb Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Fri, 21 Mar 2025 15:08:34 +0000 Subject: [PATCH 21/22] Add test for generating client outside of API directory --- .../applyconfiguration_integration_test.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/applyconfiguration/applyconfiguration_integration_test.go b/pkg/applyconfiguration/applyconfiguration_integration_test.go index b3382f971..33d8f8101 100644 --- a/pkg/applyconfiguration/applyconfiguration_integration_test.go +++ b/pkg/applyconfiguration/applyconfiguration_integration_test.go @@ -119,7 +119,7 @@ var _ = Describe("ApplyConfiguration generation from API types", func() { rt.OutputRules = genall.OutputRules{Default: output} originalFS := os.DirFS(filepath.Join(originalCWD, cronjobDir)) - tmpFS := os.DirFS("./api/v1") + tmpFS := os.DirFS(".") By("Running the generator") hadErrs := rt.Run() @@ -152,7 +152,7 @@ var _ = Describe("ApplyConfiguration generation from API types", func() { filesInOutput := make(map[string][]byte) outputFileNames := sets.New[string]() - Expect(fs.WalkDir(tmpFS, outputPackage, func(path string, d fs.DirEntry, err error) error { + Expect(fs.WalkDir(tmpFS, filepath.Join("api/v1", outputPackage), func(path string, d fs.DirEntry, err error) error { if err != nil { return err } @@ -161,13 +161,13 @@ var _ = Describe("ApplyConfiguration generation from API types", func() { return nil } - data, err := os.ReadFile(filepath.Join("./api/v1", path)) + data, err := os.ReadFile(path) if err != nil { return fmt.Errorf("error reading file %s: %w", path, err) } // Record the path without the path prefix for comparison later. - path = strings.TrimPrefix(path, outputPackage+"/") + path = strings.TrimPrefix(path, filepath.Join("api/v1", outputPackage)+"/") outputFileNames.Insert(path) filesInOutput[path] = data return nil @@ -177,17 +177,21 @@ var _ = Describe("ApplyConfiguration generation from API types", func() { Expect(outputFileNames.UnsortedList()).To(ConsistOf(originalFileNames.UnsortedList()), "Generated files should match the checked in files") for name, content := range filesInOriginal { + // If the output package uses a relative path we need to remove the "../" from the package name. + outputPackageName := strings.ReplaceAll(outputPackage, "../", "") + // Make sure the package string is correct for the newly generated content. - content = []byte(strings.Replace(string(content), "package applyconfiguration", fmt.Sprintf("package %s", outputPackage), 1)) + content = []byte(strings.Replace(string(content), "package applyconfiguration", fmt.Sprintf("package %s", outputPackageName), 1)) // Make sure the import paths are correct for the newly generated content. - content = []byte(strings.ReplaceAll(string(content), "testdata/cronjob/api/v1/applyconfiguration", fmt.Sprintf("testdata/cronjob/api/v1/%s", outputPackage))) + content = []byte(strings.ReplaceAll(string(content), "testdata/cronjob/api/v1/applyconfiguration", filepath.Join("testdata/cronjob/api/v1", outputPackage))) Expect(string(filesInOutput[name])).To(BeComparableTo(string(content)), "Generated files should match the checked in files, diff found in %s", name) } }, Entry("with the default applyconfiguration output package", "applyconfiguration"), Entry("with the an alternative output package", "other"), + Entry("with a package outside of the current directory", "../../clients"), ) }) From 804b842ae655816dd663a8ed7749f802936b7453 Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Fri, 21 Mar 2025 15:18:45 +0000 Subject: [PATCH 22/22] Address feedback on gen.go --- pkg/applyconfiguration/gen.go | 40 ++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/pkg/applyconfiguration/gen.go b/pkg/applyconfiguration/gen.go index 55a79dad1..73c727ab4 100644 --- a/pkg/applyconfiguration/gen.go +++ b/pkg/applyconfiguration/gen.go @@ -30,6 +30,7 @@ import ( "k8s.io/gengo/v2/generator" "k8s.io/gengo/v2/parser" + kerrors "k8s.io/apimachinery/pkg/util/errors" crdmarkers "sigs.k8s.io/controller-tools/pkg/crd/markers" "sigs.k8s.io/controller-tools/pkg/genall" "sigs.k8s.io/controller-tools/pkg/loader" @@ -45,7 +46,7 @@ var ( enableTypeMarker = markers.Must(markers.MakeDefinition("kubebuilder:ac:generate", markers.DescribesType, false)) ) -const importPathSuffix = "applyconfiguration" +const defaultOutputPackage = "applyconfiguration" // +controllertools:marker:generateHelp @@ -72,11 +73,11 @@ func (Generator) RegisterMarkers(into *markers.Registry) error { into.AddHelp(isCRDMarker, markers.SimpleHelp("apply", "enables apply configuration generation for this type")) into.AddHelp( - enableTypeMarker, markers.SimpleHelp("apply", "overrides enabling or disabling applyconfigurations generation for the type")) + enableTypeMarker, markers.SimpleHelp("apply", "overrides enabling or disabling applyconfiguration generation for the type, can be used to generate applyconfiguration for a single type when the package generation is disabled, or to disable generation for a single type when the package generation is enabled")) into.AddHelp( - enablePkgMarker, markers.SimpleHelp("apply", "overrides enabling or disabling applyconfigurations generation for the package")) + enablePkgMarker, markers.SimpleHelp("apply", "overrides enabling or disabling applyconfiguration generation for the package")) into.AddHelp( - outputPkgMarker, markers.SimpleHelp("apply", "overrides the default output package for the applyconfigurations generation")) + outputPkgMarker, markers.SimpleHelp("apply", "overrides the default output package for the applyconfiguration generation, supports relative paths to the API directory. The default value is \"applyconfiguration\"")) return nil } @@ -92,7 +93,6 @@ func enabledOnPackage(col *markers.Collector, pkg *loader.Package) (bool, error) return false, nil } -// enableOnType marks whether applyconfiguration generation is enabled for the type. func enabledOnType(info *markers.TypeInfo) bool { if typeMarker := info.Markers.Get(enableTypeMarker.Name); typeMarker != nil { return typeMarker.(bool) @@ -100,19 +100,21 @@ func enabledOnType(info *markers.TypeInfo) bool { return isCRD(info) } -func outputPkg(col *markers.Collector, pkg *loader.Package) (string, error) { +func outputPkg(col *markers.Collector, pkg *loader.Package) string { pkgMarkers, err := markers.PackageMarkers(col, pkg) if err != nil { - return "", err + // Use the default when there's an error. + return defaultOutputPackage } + pkgMarker := pkgMarkers.Get(outputPkgMarker.Name) if pkgMarker != nil { - return pkgMarker.(string), nil + return pkgMarker.(string) } - return "", nil + + return defaultOutputPackage } -// isCRD marks whether the type is a CRD based on the +kubebuilder:resource marker. func isCRD(info *markers.TypeInfo) bool { objectEnabled := info.Markers.Get(isCRDMarker.Name) return objectEnabled != nil @@ -126,7 +128,9 @@ func (d Generator) Generate(ctx *genall.GenerationContext) error { if err != nil { return fmt.Errorf("failed to create temporary file: %w", err) } - tmpFile.Close() + if err := tmpFile.Close(); err != nil { + return fmt.Errorf("failed to close temporary file: %w", err) + } defer os.Remove(tmpFile.Name()) @@ -139,11 +143,17 @@ func (d Generator) Generate(ctx *genall.GenerationContext) error { HeaderFilePath: headerFilePath, } + errs := []error{} for _, pkg := range ctx.Roots { if err := objGenCtx.generateForPackage(pkg); err != nil { - return err + errs = append(errs, err) } } + + if len(errs) > 0 { + return kerrors.NewAggregate(errs) + } + return nil } @@ -158,7 +168,6 @@ type ObjectGenCtx struct { // generateForPackage generates apply configuration implementations for // types in the given package, writing the formatted result to given writer. -// May return nil if source could not be generated. func (ctx *ObjectGenCtx) generateForPackage(root *loader.Package) error { enabled, _ := enabledOnPackage(ctx.Collector, root) if !enabled { @@ -171,10 +180,7 @@ func (ctx *ObjectGenCtx) generateForPackage(root *loader.Package) error { arguments := args.New() arguments.GoHeaderFile = ctx.HeaderFilePath - outpkg, _ := outputPkg(ctx.Collector, root) - if outpkg == "" { - outpkg = importPathSuffix - } + outpkg := outputPkg(ctx.Collector, root) arguments.OutputDir = filepath.Join(root.Dir, outpkg) arguments.OutputPkg = filepath.Join(root.Package.PkgPath, outpkg)