-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🌱 Improve samples linting & fix samples lint issues
This commit includes: - Fix linter issues - Refactor fetchCronJob in sample controller reconcile func - Fix getting-started tutorial lint issues - Fix multiversion tutorial lint issues - Fix cronjob-tutorial lint issues - Refactor cronjob controller reconcile to reduce cyclomatic complexity
- Loading branch information
Showing
16 changed files
with
94 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,7 @@ var ( | |
// | ||
// For more details, check Reconcile and its Result here: | ||
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
// nolint:gocyclo | ||
func (r *CronJobReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
log := log.FromContext(ctx) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,7 @@ var ( | |
// | ||
// For more details, check Reconcile and its Result here: | ||
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
// nolint:gocyclo | ||
func (r *CronJobReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
log := log.FromContext(ctx) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -286,6 +286,11 @@ func (sp *Sample) updateController() { | |
`// +kubebuilder:rbac:groups=batch.tutorial.kubebuilder.io,resources=cronjobs/finalizers,verbs=update`, controllerReconcile) | ||
hackutils.CheckError("fixing cronjob_controller.go", err) | ||
|
||
err = pluginutil.InsertCode( | ||
filepath.Join(sp.ctx.Dir, "internal/controller/cronjob_controller.go"), | ||
`// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile`, skipGoCycloLint) | ||
hackutils.CheckError("fixing cronjob_controller.go", err) | ||
|
||
err = pluginutil.ReplaceInFile( | ||
filepath.Join(sp.ctx.Dir, "internal/controller/cronjob_controller.go"), | ||
` _ = log.FromContext(ctx) | ||
|
@@ -398,6 +403,11 @@ func (sp *Sample) updateWebhookTests() { | |
webhookTestingValidatingExampleFragment) | ||
hackutils.CheckError("replace validating defaulting test", err) | ||
|
||
err = pluginutil.ReplaceInFile(file, | ||
webhookTestsVars, | ||
webhookTestsConstants) | ||
hackutils.CheckError("replace before each webhook test ", err) | ||
|
||
err = pluginutil.ReplaceInFile(file, | ||
webhookTestsBeforeEachOriginal, | ||
webhookTestsBeforeEachChanged) | ||
|
@@ -420,6 +430,7 @@ func (sp *Sample) updateWebhook() { | |
"context" | ||
"fmt"`, | ||
` | ||
"github.com/robfig/cron" | ||
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.