Skip to content

Commit e7233a1

Browse files
committed
Address issues raised by linter (comment/error format and pre-allocation)
Signed-off-by: Marvin Beckers <[email protected]>
1 parent aede36a commit e7233a1

File tree

14 files changed

+48
-48
lines changed

14 files changed

+48
-48
lines changed

examples/pkg/apis/example/register.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ import (
2424

2525
const GroupName = "example.dev"
2626

27-
// SchemeGroupVersion is group version used to register these objects
27+
// SchemeGroupVersion is group version used to register these objects.
2828
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}
2929

30-
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
30+
// Kind takes an unqualified kind and returns back a Group qualified GroupKind.
3131
func Kind(kind string) schema.GroupKind {
3232
return SchemeGroupVersion.WithKind(kind).GroupKind()
3333
}
3434

35-
// Resource takes an unqualified resource and returns a Group qualified GroupResource
35+
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
3636
func Resource(resource string) schema.GroupResource {
3737
return SchemeGroupVersion.WithResource(resource).GroupResource()
3838
}

examples/pkg/apis/example/v1/register.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ import (
2424
"acme.corp/pkg/apis/example"
2525
)
2626

27-
// SchemeGroupVersion is group version used to register these objects
27+
// SchemeGroupVersion is group version used to register these objects.
2828
var SchemeGroupVersion = schema.GroupVersion{Group: example.GroupName, Version: "v1"}
2929

30-
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
30+
// Kind takes an unqualified kind and returns back a Group qualified GroupKind.
3131
func Kind(kind string) schema.GroupKind {
3232
return SchemeGroupVersion.WithKind(kind).GroupKind()
3333
}
3434

35-
// Resource takes an unqualified resource and returns a Group qualified GroupResource
35+
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
3636
func Resource(resource string) schema.GroupResource {
3737
return SchemeGroupVersion.WithResource(resource).GroupResource()
3838
}

examples/pkg/apis/example/v1alpha1/register.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ import (
2424
"acme.corp/pkg/apis/example"
2525
)
2626

27-
// SchemeGroupVersion is group version used to register these objects
27+
// SchemeGroupVersion is group version used to register these objects.
2828
var SchemeGroupVersion = schema.GroupVersion{Group: example.GroupName, Version: "v1alpha1"}
2929

30-
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
30+
// Kind takes an unqualified kind and returns back a Group qualified GroupKind.
3131
func Kind(kind string) schema.GroupKind {
3232
return SchemeGroupVersion.WithKind(kind).GroupKind()
3333
}
3434

35-
// Resource takes an unqualified resource and returns a Group qualified GroupResource
35+
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
3636
func Resource(resource string) schema.GroupResource {
3737
return SchemeGroupVersion.WithResource(resource).GroupResource()
3838
}

examples/pkg/apis/example/v1beta1/register.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ import (
2424
"acme.corp/pkg/apis/example"
2525
)
2626

27-
// SchemeGroupVersion is group version used to register these objects
27+
// SchemeGroupVersion is group version used to register these objects.
2828
var SchemeGroupVersion = schema.GroupVersion{Group: example.GroupName, Version: "v1beta1"}
2929

30-
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
30+
// Kind takes an unqualified kind and returns back a Group qualified GroupKind.
3131
func Kind(kind string) schema.GroupKind {
3232
return SchemeGroupVersion.WithKind(kind).GroupKind()
3333
}
3434

35-
// Resource takes an unqualified resource and returns a Group qualified GroupResource
35+
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
3636
func Resource(resource string) schema.GroupResource {
3737
return SchemeGroupVersion.WithResource(resource).GroupResource()
3838
}

examples/pkg/apis/example/v2/register.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ import (
2424
"acme.corp/pkg/apis/example"
2525
)
2626

27-
// SchemeGroupVersion is group version used to register these objects
27+
// SchemeGroupVersion is group version used to register these objects.
2828
var SchemeGroupVersion = schema.GroupVersion{Group: example.GroupName, Version: "v2"}
2929

30-
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
30+
// Kind takes an unqualified kind and returns back a Group qualified GroupKind.
3131
func Kind(kind string) schema.GroupKind {
3232
return SchemeGroupVersion.WithKind(kind).GroupKind()
3333
}
3434

35-
// Resource takes an unqualified resource and returns a Group qualified GroupResource
35+
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
3636
func Resource(resource string) schema.GroupResource {
3737
return SchemeGroupVersion.WithResource(resource).GroupResource()
3838
}

examples/pkg/apis/example3/v1/register.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ import (
2424
example "acme.corp/pkg/apis/example3"
2525
)
2626

27-
// SchemeGroupVersion is group version used to register these objects
27+
// SchemeGroupVersion is group version used to register these objects.
2828
var SchemeGroupVersion = schema.GroupVersion{Group: example.GroupName, Version: "v1"}
2929

30-
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
30+
// Kind takes an unqualified kind and returns back a Group qualified GroupKind.
3131
func Kind(kind string) schema.GroupKind {
3232
return SchemeGroupVersion.WithKind(kind).GroupKind()
3333
}
3434

35-
// Resource takes an unqualified resource and returns a Group qualified GroupResource
35+
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
3636
func Resource(resource string) schema.GroupResource {
3737
return SchemeGroupVersion.WithResource(resource).GroupResource()
3838
}

examples/pkg/apis/existinginterfaces/v1/register.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ import (
2424
"acme.corp/pkg/apis/existinginterfaces"
2525
)
2626

27-
// SchemeGroupVersion is group version used to register these objects
27+
// SchemeGroupVersion is group version used to register these objects.
2828
var SchemeGroupVersion = schema.GroupVersion{Group: existinginterfaces.GroupName, Version: "v1"}
2929

30-
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
30+
// Kind takes an unqualified kind and returns back a Group qualified GroupKind.
3131
func Kind(kind string) schema.GroupKind {
3232
return SchemeGroupVersion.WithKind(kind).GroupKind()
3333
}
3434

35-
// Resource takes an unqualified resource and returns a Group qualified GroupResource
35+
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
3636
func Resource(resource string) schema.GroupResource {
3737
return SchemeGroupVersion.WithResource(resource).GroupResource()
3838
}

examples/pkg/apis/secondexample/v1/register.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ import (
2424
example "acme.corp/pkg/apis/secondexample"
2525
)
2626

27-
// SchemeGroupVersion is group version used to register these objects
27+
// SchemeGroupVersion is group version used to register these objects.
2828
var SchemeGroupVersion = schema.GroupVersion{Group: example.GroupName, Version: "v1"}
2929

30-
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
30+
// Kind takes an unqualified kind and returns back a Group qualified GroupKind.
3131
func Kind(kind string) schema.GroupKind {
3232
return SchemeGroupVersion.WithKind(kind).GroupKind()
3333
}
3434

35-
// Resource takes an unqualified resource and returns a Group qualified GroupResource
35+
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
3636
func Resource(resource string) schema.GroupResource {
3737
return SchemeGroupVersion.WithResource(resource).GroupResource()
3838
}

main.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,21 @@ var (
5555
// them names for use on the command line.
5656
// Each output rule turns into two command line options:
5757
// - output:<generator>:<form> (per-generator output)
58-
// - output:<form> (default output)
58+
// - output:<form> (default output).
5959
allOutputRules = map[string]genall.OutputRule{
6060
"dir": genall.OutputToDirectory(""),
6161
"none": genall.OutputToNothing,
6262
"stdout": genall.OutputToStdout,
6363
"artifacts": genall.OutputArtifacts{},
6464
}
6565

66-
// optionsRegistry contains all the marker definitions used to process command line options
66+
// optionsRegistry contains all the marker definitions used to process command line options.
6767
optionsRegistry = &markers.Registry{}
6868
)
6969

7070
func init() {
7171
for genName, gen := range allGenerators {
72-
// make the generator options marker itself
72+
// make the generator options marker itself.
7373
defn := markers.Must(markers.MakeDefinition(genName, markers.DescribesPackage, gen))
7474
if err := optionsRegistry.Register(defn); err != nil {
7575
panic(err)
@@ -80,7 +80,7 @@ func init() {
8080
}
8181
}
8282

83-
// make per-generation output rule markers
83+
// make per-generation output rule markers.
8484
for ruleName, rule := range allOutputRules {
8585
ruleMarker := markers.Must(markers.MakeDefinition(fmt.Sprintf("output:%s:%s", genName, ruleName), markers.DescribesPackage, rule))
8686
if err := optionsRegistry.Register(ruleMarker); err != nil {
@@ -94,7 +94,7 @@ func init() {
9494
}
9595
}
9696

97-
// make "default output" output rule markers
97+
// make "default output" output rule markers.
9898
for ruleName, rule := range allOutputRules {
9999
ruleMarker := markers.Must(markers.MakeDefinition("output:"+ruleName, markers.DescribesPackage, rule))
100100
if err := optionsRegistry.Register(ruleMarker); err != nil {
@@ -107,7 +107,7 @@ func init() {
107107
}
108108
}
109109

110-
// add in the common options markers
110+
// add in the common options markers.
111111
if err := genall.RegisterOptionsMarkers(optionsRegistry); err != nil {
112112
panic(err)
113113
}
@@ -143,23 +143,23 @@ func main() {
143143
code-generator lister -ww
144144
`,
145145
RunE: func(c *cobra.Command, rawOpts []string) error {
146-
// print version if asked for it
146+
// print version if asked for it.
147147
if showVersion {
148148
version.Print()
149149
return nil
150150
}
151151

152-
// print the help if we asked for it (since we've got a different help flag :-/), then bail
152+
// print the help if we asked for it (since we've got a different help flag :-/), then bail.
153153
if helpLevel > 0 {
154154
return c.Usage()
155155
}
156156

157-
// print the marker docs if we asked for them, then bail
157+
// print the marker docs if we asked for them, then bail.
158158
if whichLevel > 0 {
159159
return printMarkerDocs(c, rawOpts, whichLevel)
160160
}
161161

162-
// otherwise, set up the runtime for actually running the generators
162+
// otherwise, set up the runtime for actually running the generators.
163163
rt, err := genall.FromOptions(optionsRegistry, rawOpts)
164164
if err != nil {
165165
return err
@@ -174,7 +174,7 @@ func main() {
174174
}
175175
return nil
176176
},
177-
SilenceUsage: true, // silence the usage, then print it out ourselves if it wasn't suppressed
177+
SilenceUsage: true, // silence the usage, then print it out ourselves if it wasn't suppressed.
178178
}
179179
cmd.Flags().CountVarP(&whichLevel, "which-markers", "w", "print out all markers available with the requested generators\n(up to -www for the most detailed output, or -wwww for json output)")
180180
cmd.Flags().CountVarP(&helpLevel, "detailed-help", "h", "print out more detailed help\n(up to -hhh for the most detailed output, or -hhhh for json output)")
@@ -194,7 +194,7 @@ func main() {
194194

195195
if err := cmd.Execute(); err != nil {
196196
if _, noUsage := err.(noUsageError); !noUsage {
197-
// print the usage unless we suppressed it
197+
// print the usage unless we suppressed it.
198198
if err := cmd.Usage(); err != nil {
199199
panic(err)
200200
}

pkg/flag/flags.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/spf13/pflag"
2323
)
2424

25-
// Flags - Options accepted by generator
25+
// Flags are options accepted by the generator.
2626
type Flags struct {
2727
// OutputDir is where the generated code is to be written to.
2828
OutputDir string
@@ -65,15 +65,15 @@ func (f *Flags) AddTo(flagset *pflag.FlagSet) {
6565
// https://github.com/kcp-dev/code-generator/issues/4
6666
func ValidateFlags(f Flags) error {
6767
if f.InputDir == "" {
68-
return errors.New("input path to API definition is required.")
68+
return errors.New("input path to API definition is required")
6969
}
7070

7171
if f.ClientsetAPIPath == "" {
72-
return errors.New("specifying client API path is required currently.")
72+
return errors.New("specifying client API path is required currently")
7373
}
7474

7575
if len(f.GroupVersions) == 0 {
76-
return errors.New("list of group versions for which the clients are to be generated is required.")
76+
return errors.New("list of group versions for which the clients are to be generated is required")
7777
}
7878

7979
return nil

0 commit comments

Comments
 (0)