Skip to content

Commit

Permalink
Merge pull request #4111 from camilamacedo86/fix-linter-samples
Browse files Browse the repository at this point in the history
 🐛  (go/v4): Fix linter issues in the scaffold
  • Loading branch information
k8s-ci-robot authored Aug 29, 2024
2 parents a1457ac + e4ef218 commit c1bacc7
Show file tree
Hide file tree
Showing 22 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ func main() {
We'll just make sure to set `ENABLE_WEBHOOKS=false` when we run locally.
*/
// nolint:goconst
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
if err = (&batchv1.CronJob{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "CronJob")
Expand Down
1 change: 1 addition & 0 deletions hack/docs/internal/cronjob-tutorial/generate_cronjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ func (sp *Sample) updateWebhook() {
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)
// nolint:unused
// log is for logging in this package.
`, WebhookIntro)
hackutils.CheckError("fixing cronjob_webhook.go", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ import (
)
// nolint:unused
// log is for logging in this package.
var {{ lower .Resource.Kind }}log = logf.Log.WithName("{{ lower .Resource.Kind }}-resource")
Expand Down
3 changes: 2 additions & 1 deletion pkg/plugins/golang/v4/scaffolds/internal/templates/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ const (
os.Exit(1)
}
`
webhookSetupCodeFragment = `if os.Getenv("ENABLE_WEBHOOKS") != "false" {
webhookSetupCodeFragment = `// nolint:goconst
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
if err = (&%s.%s{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "%s")
os.Exit(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// nolint:unused
// log is for logging in this package.
var captainlog = logf.Log.WithName("captain-resource")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook"
)

// nolint:unused
// log is for logging in this package.
var destroyerlog = logf.Log.WithName("destroyer-resource")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
)

// nolint:unused
// log is for logging in this package.
var frigatelog = logf.Log.WithName("frigate-resource")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// nolint:unused
// log is for logging in this package.
var cruiserlog = logf.Log.WithName("cruiser-resource")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// nolint:unused
// log is for logging in this package.
var lakerslog = logf.Log.WithName("lakers-resource")

Expand Down
5 changes: 5 additions & 0 deletions testdata/project-v4-multigroup-with-deploy-image/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "Captain")
os.Exit(1)
}
// nolint:goconst
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
if err = (&crewv1.Captain{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Captain")
Expand All @@ -189,6 +190,7 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "Frigate")
os.Exit(1)
}
// nolint:goconst
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
if err = (&shipv1beta1.Frigate{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Frigate")
Expand All @@ -202,6 +204,7 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "Destroyer")
os.Exit(1)
}
// nolint:goconst
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
if err = (&shipv1.Destroyer{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Destroyer")
Expand All @@ -215,6 +218,7 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "Cruiser")
os.Exit(1)
}
// nolint:goconst
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
if err = (&shipv2alpha1.Cruiser{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Cruiser")
Expand Down Expand Up @@ -270,6 +274,7 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "Lakers")
os.Exit(1)
}
// nolint:goconst
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
if err = (&testprojectorgv1.Lakers{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Lakers")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// nolint:unused
// log is for logging in this package.
var captainlog = logf.Log.WithName("captain-resource")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook"
)

// nolint:unused
// log is for logging in this package.
var destroyerlog = logf.Log.WithName("destroyer-resource")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
)

// nolint:unused
// log is for logging in this package.
var frigatelog = logf.Log.WithName("frigate-resource")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// nolint:unused
// log is for logging in this package.
var cruiserlog = logf.Log.WithName("cruiser-resource")

Expand Down
1 change: 1 addition & 0 deletions testdata/project-v4-multigroup/api/v1/lakers_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// nolint:unused
// log is for logging in this package.
var lakerslog = logf.Log.WithName("lakers-resource")

Expand Down
5 changes: 5 additions & 0 deletions testdata/project-v4-multigroup/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "Captain")
os.Exit(1)
}
// nolint:goconst
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
if err = (&crewv1.Captain{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Captain")
Expand All @@ -189,6 +190,7 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "Frigate")
os.Exit(1)
}
// nolint:goconst
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
if err = (&shipv1beta1.Frigate{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Frigate")
Expand All @@ -202,6 +204,7 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "Destroyer")
os.Exit(1)
}
// nolint:goconst
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
if err = (&shipv1.Destroyer{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Destroyer")
Expand All @@ -215,6 +218,7 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "Cruiser")
os.Exit(1)
}
// nolint:goconst
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
if err = (&shipv2alpha1.Cruiser{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Cruiser")
Expand Down Expand Up @@ -270,6 +274,7 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "Lakers")
os.Exit(1)
}
// nolint:goconst
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
if err = (&testprojectorgv1.Lakers{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Lakers")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// nolint:unused
// log is for logging in this package.
var memcachedlog = logf.Log.WithName("memcached-resource")

Expand Down
1 change: 1 addition & 0 deletions testdata/project-v4-with-deploy-image/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "Busybox")
os.Exit(1)
}
// nolint:goconst
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
if err = (&examplecomv1alpha1.Memcached{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Memcached")
Expand Down
1 change: 1 addition & 0 deletions testdata/project-v4/api/v1/admiral_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook"
)

// nolint:unused
// log is for logging in this package.
var admirallog = logf.Log.WithName("admiral-resource")

Expand Down
1 change: 1 addition & 0 deletions testdata/project-v4/api/v1/captain_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// nolint:unused
// log is for logging in this package.
var captainlog = logf.Log.WithName("captain-resource")

Expand Down
1 change: 1 addition & 0 deletions testdata/project-v4/api/v1/firstmate_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
)

// nolint:unused
// log is for logging in this package.
var firstmatelog = logf.Log.WithName("firstmate-resource")

Expand Down
3 changes: 3 additions & 0 deletions testdata/project-v4/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "Captain")
os.Exit(1)
}
// nolint:goconst
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
if err = (&crewv1.Captain{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Captain")
Expand All @@ -164,6 +165,7 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "FirstMate")
os.Exit(1)
}
// nolint:goconst
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
if err = (&crewv1.FirstMate{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "FirstMate")
Expand All @@ -177,6 +179,7 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "Admiral")
os.Exit(1)
}
// nolint:goconst
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
if err = (&crewv1.Admiral{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Admiral")
Expand Down

0 comments on commit c1bacc7

Please sign in to comment.