Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,17 @@ Please copy the appropriate `:text:` or icon to the beginning of your PR title:
## Related issue(s)

Fixes #

## Release Notes

<!--
Please add a release note using the following format:

```release-note
<description of change>
```
-->

```release-note
NONE
```
38 changes: 38 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
run:
timeout: 10m
allow-parallel-runners: true

linters:
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- dupword
- durationcheck
- errcheck
- errchkjson
- exportloopref
- gocritic
- godot
- gofmt
- goprintffuncname
- gosec
- gosimple
- govet
- importas
- ineffassign
- misspell
- nilerr
- noctx
- nolintlint
- nosprintfhostport
- prealloc
- revive
- staticcheck
- unconvert
- unused
- usestdlibvars
- whitespace
6 changes: 3 additions & 3 deletions .prow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ presubmits:
preset-goproxy: "true"
spec:
containers:
- image: ghcr.io/kcp-dev/infra/build:1.19.9-1
- image: ghcr.io/kcp-dev/infra/build:1.20.13-1
command:
- make
- verify-codegen
Expand All @@ -21,7 +21,7 @@ presubmits:
preset-goproxy: "true"
spec:
containers:
- image: ghcr.io/kcp-dev/infra/build:1.19.9-1
- image: ghcr.io/kcp-dev/infra/build:1.20.13-1
command:
- make
- lint
Expand All @@ -34,7 +34,7 @@ presubmits:
preset-goproxy: "true"
spec:
containers:
- image: ghcr.io/kcp-dev/infra/build:1.19.9-1
- image: ghcr.io/kcp-dev/infra/build:1.20.13-1
command:
- make
- test
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ CONTROLLER_GEN_BIN := controller-gen
CONTROLLER_GEN := $(GOBIN_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER)
export CONTROLLER_GEN

GOLANGCI_LINT_VER := v1.49.0
GOLANGCI_LINT_VER := v1.54.2
GOLANGCI_LINT_BIN := golangci-lint
GOLANGCI_LINT := $(GOBIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)

Expand Down
12 changes: 6 additions & 6 deletions OWNERS
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
approvers:
- ncdc
- stevekuznetsov
- fabianvf
- varshaprasad96
- njhale
- sttts
- clubanderson
- scheeles
- sttts
- xrstf
- mjudeikis
- embik
6 changes: 3 additions & 3 deletions examples/pkg/apis/example/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import (

const GroupName = "example.dev"

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

// Kind takes an unqualified kind and returns back a Group qualified GroupKind
// Kind takes an unqualified kind and returns back a Group qualified GroupKind.
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}

// Resource takes an unqualified resource and returns a Group qualified GroupResource
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
Expand Down
6 changes: 3 additions & 3 deletions examples/pkg/apis/example/v1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import (
"acme.corp/pkg/apis/example"
)

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

// Kind takes an unqualified kind and returns back a Group qualified GroupKind
// Kind takes an unqualified kind and returns back a Group qualified GroupKind.
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}

// Resource takes an unqualified resource and returns a Group qualified GroupResource
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
Expand Down
6 changes: 3 additions & 3 deletions examples/pkg/apis/example/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import (
"acme.corp/pkg/apis/example"
)

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

// Kind takes an unqualified kind and returns back a Group qualified GroupKind
// Kind takes an unqualified kind and returns back a Group qualified GroupKind.
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}

// Resource takes an unqualified resource and returns a Group qualified GroupResource
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
Expand Down
6 changes: 3 additions & 3 deletions examples/pkg/apis/example/v1beta1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import (
"acme.corp/pkg/apis/example"
)

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

// Kind takes an unqualified kind and returns back a Group qualified GroupKind
// Kind takes an unqualified kind and returns back a Group qualified GroupKind.
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}

// Resource takes an unqualified resource and returns a Group qualified GroupResource
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
Expand Down
6 changes: 3 additions & 3 deletions examples/pkg/apis/example/v2/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import (
"acme.corp/pkg/apis/example"
)

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

// Kind takes an unqualified kind and returns back a Group qualified GroupKind
// Kind takes an unqualified kind and returns back a Group qualified GroupKind.
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}

// Resource takes an unqualified resource and returns a Group qualified GroupResource
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
Expand Down
6 changes: 3 additions & 3 deletions examples/pkg/apis/example3/v1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import (
example "acme.corp/pkg/apis/example3"
)

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

// Kind takes an unqualified kind and returns back a Group qualified GroupKind
// Kind takes an unqualified kind and returns back a Group qualified GroupKind.
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}

// Resource takes an unqualified resource and returns a Group qualified GroupResource
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
Expand Down
6 changes: 3 additions & 3 deletions examples/pkg/apis/existinginterfaces/v1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import (
"acme.corp/pkg/apis/existinginterfaces"
)

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

// Kind takes an unqualified kind and returns back a Group qualified GroupKind
// Kind takes an unqualified kind and returns back a Group qualified GroupKind.
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}

// Resource takes an unqualified resource and returns a Group qualified GroupResource
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
Expand Down
6 changes: 3 additions & 3 deletions examples/pkg/apis/secondexample/v1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import (
example "acme.corp/pkg/apis/secondexample"
)

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

// Kind takes an unqualified kind and returns back a Group qualified GroupKind
// Kind takes an unqualified kind and returns back a Group qualified GroupKind.
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}

// Resource takes an unqualified resource and returns a Group qualified GroupResource
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
Expand Down
12 changes: 6 additions & 6 deletions hack/go-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ set -o errexit
set -o nounset
set -o pipefail

if [ -z "${1}" ]; then
if [[ -z "${1:-}" ]]; then
echo "must provide module as first parameter"
exit 1
fi

if [ -z "${2}" ]; then
if [[ -z "${2:-}" ]]; then
echo "must provide binary name as second parameter"
exit 1
fi

if [ -z "${3}" ]; then
if [[ -z "${3:-}" ]]; then
echo "must provide version as third parameter"
exit 1
fi

if [ -z "${GOBIN}" ]; then
if [[ -z "${GOBIN:-}" ]]; then
echo "GOBIN is not set. Must set GOBIN to install the bin in a specified directory."
exit 1
fi
Expand All @@ -57,6 +57,6 @@ cd "${tmp_dir}"
go mod init fake/mod

# install the golang module specified as the first argument
go install -tags tools "${1}@${3}"
go install -tags kcptools "${1}@${3}"
mv "${GOBIN}/${2}" "${GOBIN}/${2}-${3}"
ln -sf "${GOBIN}/${2}-${3}" "${GOBIN}/${2}"
ln -sf "${GOBIN}/${2}-${3}" "${GOBIN}/${2}"
24 changes: 12 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ var (
// them names for use on the command line.
// Each output rule turns into two command line options:
// - output:<generator>:<form> (per-generator output)
// - output:<form> (default output)
// - output:<form> (default output).
allOutputRules = map[string]genall.OutputRule{
"dir": genall.OutputToDirectory(""),
"none": genall.OutputToNothing,
"stdout": genall.OutputToStdout,
"artifacts": genall.OutputArtifacts{},
}

// optionsRegistry contains all the marker definitions used to process command line options
// optionsRegistry contains all the marker definitions used to process command line options.
optionsRegistry = &markers.Registry{}
)

func init() {
for genName, gen := range allGenerators {
// make the generator options marker itself
// make the generator options marker itself.
defn := markers.Must(markers.MakeDefinition(genName, markers.DescribesPackage, gen))
if err := optionsRegistry.Register(defn); err != nil {
panic(err)
Expand All @@ -80,7 +80,7 @@ func init() {
}
}

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

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

// add in the common options markers
// add in the common options markers.
if err := genall.RegisterOptionsMarkers(optionsRegistry); err != nil {
panic(err)
}
Expand Down Expand Up @@ -143,23 +143,23 @@ func main() {
code-generator lister -ww
`,
RunE: func(c *cobra.Command, rawOpts []string) error {
// print version if asked for it
// print version if asked for it.
if showVersion {
version.Print()
return nil
}

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

// print the marker docs if we asked for them, then bail
// print the marker docs if we asked for them, then bail.
if whichLevel > 0 {
return printMarkerDocs(c, rawOpts, whichLevel)
}

// otherwise, set up the runtime for actually running the generators
// otherwise, set up the runtime for actually running the generators.
rt, err := genall.FromOptions(optionsRegistry, rawOpts)
if err != nil {
return err
Expand All @@ -174,7 +174,7 @@ func main() {
}
return nil
},
SilenceUsage: true, // silence the usage, then print it out ourselves if it wasn't suppressed
SilenceUsage: true, // silence the usage, then print it out ourselves if it wasn't suppressed.
}
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)")
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)")
Expand All @@ -194,7 +194,7 @@ func main() {

if err := cmd.Execute(); err != nil {
if _, noUsage := err.(noUsageError); !noUsage {
// print the usage unless we suppressed it
// print the usage unless we suppressed it.
if err := cmd.Usage(); err != nil {
panic(err)
}
Expand Down
Loading