Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: enable context-as-argument from revive #8674

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ linters-settings:
- name: blank-imports
disabled: true
- name: context-as-argument
disabled: true
arguments:
- allowTypesBefore: "*testing.T"
- name: context-keys-type
- name: dot-imports
disabled: true
Expand Down
1 change: 1 addition & 0 deletions pkg/client/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
kbclient "sigs.k8s.io/controller-runtime/pkg/client"
)

//nolint:revive //FIXME
kaovilai marked this conversation as resolved.
Show resolved Hide resolved
func CreateRetryGenerateName(client kbclient.Client, ctx context.Context, obj kbclient.Object) error {
retryCreateFn := func() error {
// needed to ensure that the name from the failed create isn't left on the object between retries
Expand Down
3 changes: 3 additions & 0 deletions pkg/controller/backup_repository_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,17 @@ func TestCheckNotReadyRepo(t *testing.T) {
assert.Equal(t, "s3:test.amazonaws.com/bucket/restic/volume-ns-1", rr.Spec.ResticIdentifier)
}

//nolint:revive //FIXME
func startMaintenanceJobFail(client.Client, context.Context, *velerov1api.BackupRepository, string, kube.PodResources, logrus.Level, *logging.FormatFlag, logrus.FieldLogger) (string, error) {
return "", errors.New("fake-start-error")
}

//nolint:revive //FIXME
func startMaintenanceJobSucceed(client.Client, context.Context, *velerov1api.BackupRepository, string, kube.PodResources, logrus.Level, *logging.FormatFlag, logrus.FieldLogger) (string, error) {
return "fake-job-name", nil
}

//nolint:revive //FIXME
func waitMaintenanceJobCompleteFail(client.Client, context.Context, string, string, logrus.FieldLogger) (velerov1api.BackupRepositoryMaintenanceStatus, error) {
return velerov1api.BackupRepositoryMaintenanceStatus{}, errors.New("fake-wait-error")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/data_download_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ type ddResumeTestHelper struct {
asyncBR datapath.AsyncBR
}

func (dt *ddResumeTestHelper) resumeCancellableDataPath(_ *DataUploadReconciler, _ context.Context, _ *velerov2alpha1api.DataUpload, _ logrus.FieldLogger) error {
func (dt *ddResumeTestHelper) resumeCancellableDataPath(_ context.Context, _ *DataUploadReconciler, _ *velerov2alpha1api.DataUpload, _ logrus.FieldLogger) error {
return dt.resumeErr
}

Expand Down
1 change: 1 addition & 0 deletions pkg/controller/data_upload_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,7 @@ type duResumeTestHelper struct {
asyncBR datapath.AsyncBR
}

//nolint:revive //FIXME
func (dt *duResumeTestHelper) resumeCancellableDataPath(_ *DataUploadReconciler, _ context.Context, _ *velerov2alpha1api.DataUpload, _ logrus.FieldLogger) error {
return dt.resumeErr
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/datapath/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ func NewManager(cocurrentNum int) *Manager {
}

// CreateFileSystemBR creates a new file system backup/restore data path instance
//
//nolint:revive //FIXME
func (m *Manager) CreateFileSystemBR(jobName string, requestorType string, ctx context.Context, client client.Client, namespace string, callbacks Callbacks, log logrus.FieldLogger) (AsyncBR, error) {
m.trackerLock.Lock()
defer m.trackerLock.Unlock()
Expand Down
8 changes: 6 additions & 2 deletions pkg/repository/maintenance/maintenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@
}

// WaitJobComplete waits the completion of the specified maintenance job and return the BackupRepositoryMaintenanceStatus
//
//nolint:revive //FIXME
func WaitJobComplete(cli client.Client, ctx context.Context, jobName, ns string, logger logrus.FieldLogger) (velerov1api.BackupRepositoryMaintenanceStatus, error) {
log := logger.WithField("job name", jobName)

Expand Down Expand Up @@ -360,6 +362,8 @@
}

// StartNewJob creates a new maintenance job
//
//nolint:revive //FIXME
func StartNewJob(cli client.Client, ctx context.Context, repo *velerov1api.BackupRepository, repoMaintenanceJobConfig string,
podResources kube.PodResources, logLevel logrus.Level, logFormat *logging.FormatFlag, logger logrus.FieldLogger) (string, error) {
bsl := &velerov1api.BackupStorageLocation{}
Expand Down Expand Up @@ -391,7 +395,7 @@

log.Info("Starting maintenance repo")

maintenanceJob, err := buildJob(cli, ctx, repo, bsl.Name, jobConfig, podResources, logLevel, logFormat)
maintenanceJob, err := buildJob(ctx, cli, repo, bsl.Name, jobConfig, podResources, logLevel, logFormat)

Check warning on line 398 in pkg/repository/maintenance/maintenance.go

View check run for this annotation

Codecov / codecov/patch

pkg/repository/maintenance/maintenance.go#L398

Added line #L398 was not covered by tests
if err != nil {
return "", errors.Wrap(err, "error to build maintenance job")
}
Expand All @@ -407,7 +411,7 @@
return maintenanceJob.Name, nil
}

func buildJob(cli client.Client, ctx context.Context, repo *velerov1api.BackupRepository, bslName string, config *JobConfigs,
func buildJob(ctx context.Context, cli client.Client, repo *velerov1api.BackupRepository, bslName string, config *JobConfigs,
podResources kube.PodResources, logLevel logrus.Level, logFormat *logging.FormatFlag) (*batchv1.Job, error) {
// Get the Velero server deployment
deployment := &appsv1.Deployment{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/repository/maintenance/maintenance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ func TestBuildJob(t *testing.T) {
cli := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(objs...).Build()

// Call the function to test
job, err := buildJob(cli, context.TODO(), param.BackupRepo, param.BackupLocation.Name, tc.m, *tc.m.PodResources, tc.logLevel, tc.logFormat)
job, err := buildJob(context.TODO(), cli, param.BackupRepo, param.BackupLocation.Name, tc.m, *tc.m.PodResources, tc.logLevel, tc.logFormat)

// Check the error
if tc.expectedError {
Expand Down
2 changes: 2 additions & 0 deletions pkg/uploader/provider/kopia.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ type kopiaProvider struct {
}

// NewKopiaUploaderProvider initialized with open or create a repository
//
//nolint:revive //FIXME
func NewKopiaUploaderProvider(
requestorType string,
ctx context.Context,
Expand Down
1 change: 1 addition & 0 deletions test/util/kibishii/kibishii_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ func KibishiiPrepareBeforeBackup(oneHourTimeout context.Context, client TestClie
return nil
}

//nolint:revive //FIXME
func KibishiiVerifyAfterRestore(client TestClient, kibishiiNamespace string, oneHourTimeout context.Context,
kibishiiData *KibishiiData, incrementalFileName string) error {
if kibishiiData == nil {
Expand Down
Loading