Skip to content

Commit

Permalink
Update example generators to preserve their behavior.
Browse files Browse the repository at this point in the history
  • Loading branch information
jennybuckley committed Jan 19, 2018
1 parent 73da645 commit debc696
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 14 deletions.
4 changes: 0 additions & 4 deletions examples/deepcopy-gen/generators/deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
inputs := sets.NewString(context.Inputs...)
packages := generator.Packages{}
header := append([]byte(fmt.Sprintf("// +build !%s\n\n", arguments.GeneratedBuildTag)), boilerplate...)
header = append(header, []byte(`
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
`)...)

boundingDirs := []string{}
if customArgs, ok := arguments.CustomArgs.(*CustomArgs); ok {
Expand Down
1 change: 1 addition & 0 deletions examples/deepcopy-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func main() {

// Override defaults.
arguments.OutputFileBaseName = "deepcopy_generated"
arguments.GeneratedByCommentTemplate = "\n// This file was autogenerated by deepcopy-gen. Do not edit it manually!"

// Custom args.
customArgs := &generators.CustomArgs{}
Expand Down
5 changes: 0 additions & 5 deletions examples/defaulter-gen/generators/defaulter.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,6 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat

packages := generator.Packages{}
header := append([]byte(fmt.Sprintf("// +build !%s\n\n", arguments.GeneratedBuildTag)), boilerplate...)
header = append(header, []byte(
`
// This file was autogenerated by defaulter-gen. Do not edit it manually!
`)...)

// Accumulate pre-existing default functions.
// TODO: This is too ad-hoc. We need a better way.
Expand Down
1 change: 1 addition & 0 deletions examples/defaulter-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func main() {

// Override defaults.
arguments.OutputFileBaseName = "defaulter_generated"
arguments.GeneratedByCommentTemplate = "\n// This file was autogenerated by defaulter-gen. Do not edit it manually!"

// Custom args.
customArgs := &generators.CustomArgs{
Expand Down
6 changes: 1 addition & 5 deletions examples/set-gen/generators/sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ func Packages(_ *generator.Context, arguments *args.GeneratorArgs) generator.Pac
return generator.Packages{&generator.DefaultPackage{
PackageName: "sets",
PackagePath: arguments.OutputPackagePath,
HeaderText: append(boilerplate, []byte(
`
// This file was autogenerated by set-gen. Do not edit it manually!
`)...),
HeaderText: boilerplate,
PackageDocumentation: []byte(
`// Package sets has auto-generated set types.
`),
Expand Down
4 changes: 4 additions & 0 deletions examples/set-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ import (

func main() {
arguments := args.Default()

// Override defaults.
arguments.GeneratedByCommentTemplate = "\n// This file was autogenerated by set-gen. Do not edit it manually!"

if err := arguments.Execute(
generators.NameSystems(),
generators.DefaultNameSystem(),
Expand Down

0 comments on commit debc696

Please sign in to comment.