Skip to content

Commit 895c34c

Browse files
author
Eric Stroczynski
authored
openapi: set build tag in generated openapi code (#1757)
* cmd/operator-sdk/internal/genutil/openapi.go: set ignore_autogenerated build tag in generated openapi code
1 parent d0926aa commit 895c34c

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

cmd/operator-sdk/internal/genutil/openapi.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828

2929
"github.com/pkg/errors"
3030
log "github.com/sirupsen/logrus"
31-
gengoargs "k8s.io/gengo/args"
3231
generatorargs "k8s.io/kube-openapi/cmd/openapi-gen/args"
3332
"k8s.io/kube-openapi/pkg/generators"
3433
)
@@ -103,16 +102,17 @@ func openAPIGen(hf string, fqApis []string) error {
103102
api = filepath.FromSlash(api)
104103
// Use relative API path so the generator writes to the correct path.
105104
apiPath := "." + string(filepath.Separator) + api[strings.Index(api, scaffold.ApisDir):]
106-
args := &gengoargs.GeneratorArgs{
107-
InputDirs: []string{apiPath},
108-
OutputFileBaseName: "zz_generated.openapi",
109-
OutputPackagePath: filepath.Join(wd, apiPath),
110-
GoHeaderFilePath: hf,
111-
CustomArgs: &generatorargs.CustomArgs{
112-
// Print API rule violations to stdout
113-
ReportFilename: "-",
114-
},
115-
}
105+
args, cargs := generatorargs.NewDefaults()
106+
// Ignore default output base and set our own output path.
107+
args.OutputBase = ""
108+
// openapi-gen already generates a "do not edit" comment.
109+
args.GeneratedByCommentTemplate = ""
110+
args.InputDirs = []string{apiPath}
111+
args.OutputFileBaseName = "zz_generated.openapi"
112+
args.OutputPackagePath = filepath.Join(wd, apiPath)
113+
args.GoHeaderFilePath = hf
114+
// Print API rule violations to stdout
115+
cargs.ReportFilename = "-"
116116
if err := generatorargs.Validate(args); err != nil {
117117
return errors.Wrap(err, "openapi-gen argument validation error")
118118
}

0 commit comments

Comments
 (0)