From 2487f18d1b1917748ea80895a59f49894b2f76ef Mon Sep 17 00:00:00 2001 From: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Date: Sat, 10 Aug 2024 15:42:42 -0400 Subject: [PATCH 1/2] chore: remove unused params Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> --- .../controllers/applicationset_controller.go | 60 ++++++------------- .../applicationset_controller_test.go | 8 +-- cmd/argocd/commands/app_resource_test.go | 4 +- cmd/argocd/commands/app_resources.go | 16 ++--- controller/state.go | 2 +- controller/sync.go | 2 +- controller/sync_namespace.go | 3 +- controller/sync_namespace_test.go | 4 +- .../generators/cluster_generator.go | 12 ++-- reposerver/repository/repository.go | 4 +- util/argo/argo.go | 6 +- util/argo/resource_tracking.go | 6 +- util/kube/kube.go | 19 +++--- util/manifeststream/stream.go | 4 +- 14 files changed, 60 insertions(+), 90 deletions(-) diff --git a/applicationset/controllers/applicationset_controller.go b/applicationset/controllers/applicationset_controller.go index 64d9ca4579404..69caef3117602 100644 --- a/applicationset/controllers/applicationset_controller.go +++ b/applicationset/controllers/applicationset_controller.go @@ -243,19 +243,7 @@ func (r *ApplicationSetReconciler) Reconcile(ctx context.Context, req ctrl.Reque if r.EnableProgressiveSyncs { // trigger appropriate application syncs if RollingSync strategy is enabled if progressiveSyncsStrategyEnabled(&applicationSetInfo, "RollingSync") { - validApps, err = r.syncValidApplications(logCtx, &applicationSetInfo, appSyncMap, appMap, validApps) - if err != nil { - _ = r.setApplicationSetStatusCondition(ctx, - &applicationSetInfo, - argov1alpha1.ApplicationSetCondition{ - Type: argov1alpha1.ApplicationSetConditionErrorOccurred, - Message: err.Error(), - Reason: argov1alpha1.ApplicationSetReasonSyncApplicationError, - Status: argov1alpha1.ApplicationSetConditionStatusTrue, - }, parametersGenerated, - ) - return ctrl.Result{}, err - } + validApps = r.syncValidApplications(logCtx, &applicationSetInfo, appSyncMap, appMap, validApps) } } @@ -859,12 +847,9 @@ func (r *ApplicationSetReconciler) removeOwnerReferencesOnDeleteAppSet(ctx conte } func (r *ApplicationSetReconciler) performProgressiveSyncs(ctx context.Context, logCtx *log.Entry, appset argov1alpha1.ApplicationSet, applications []argov1alpha1.Application, desiredApplications []argov1alpha1.Application, appMap map[string]argov1alpha1.Application) (map[string]bool, error) { - appDependencyList, appStepMap, err := r.buildAppDependencyList(logCtx, appset, desiredApplications) - if err != nil { - return nil, fmt.Errorf("failed to build app dependency list: %w", err) - } + appDependencyList, appStepMap := r.buildAppDependencyList(logCtx, appset, desiredApplications) - _, err = r.updateApplicationSetApplicationStatus(ctx, logCtx, &appset, applications, appStepMap) + _, err := r.updateApplicationSetApplicationStatus(ctx, logCtx, &appset, applications, appStepMap) if err != nil { return nil, fmt.Errorf("failed to update applicationset app status: %w", err) } @@ -874,30 +859,23 @@ func (r *ApplicationSetReconciler) performProgressiveSyncs(ctx context.Context, logCtx.Infof("step %v: %+v", i+1, step) } - appSyncMap, err := r.buildAppSyncMap(ctx, appset, appDependencyList, appMap) - if err != nil { - return nil, fmt.Errorf("failed to build app sync map: %w", err) - } - + appSyncMap := r.buildAppSyncMap(ctx, appset, appDependencyList, appMap) logCtx.Infof("Application allowed to sync before maxUpdate?: %+v", appSyncMap) - _, err = r.updateApplicationSetApplicationStatusProgress(ctx, logCtx, &appset, appSyncMap, appStepMap, appMap) + _, err = r.updateApplicationSetApplicationStatusProgress(ctx, logCtx, &appset, appSyncMap, appStepMap) if err != nil { return nil, fmt.Errorf("failed to update applicationset application status progress: %w", err) } - _, err = r.updateApplicationSetApplicationStatusConditions(ctx, &appset) - if err != nil { - return nil, fmt.Errorf("failed to update applicationset application status conditions: %w", err) - } + _ = r.updateApplicationSetApplicationStatusConditions(ctx, &appset) return appSyncMap, nil } // this list tracks which Applications belong to each RollingUpdate step -func (r *ApplicationSetReconciler) buildAppDependencyList(logCtx *log.Entry, applicationSet argov1alpha1.ApplicationSet, applications []argov1alpha1.Application) ([][]string, map[string]int, error) { +func (r *ApplicationSetReconciler) buildAppDependencyList(logCtx *log.Entry, applicationSet argov1alpha1.ApplicationSet, applications []argov1alpha1.Application) ([][]string, map[string]int) { if applicationSet.Spec.Strategy == nil || applicationSet.Spec.Strategy.Type == "" || applicationSet.Spec.Strategy.Type == "AllAtOnce" { - return [][]string{}, map[string]int{}, nil + return [][]string{}, map[string]int{} } steps := []argov1alpha1.ApplicationSetRolloutStep{} @@ -942,7 +920,7 @@ func (r *ApplicationSetReconciler) buildAppDependencyList(logCtx *log.Entry, app } } - return appDependencyList, appStepMap, nil + return appDependencyList, appStepMap } func labelMatchedExpression(logCtx *log.Entry, val string, matchExpression argov1alpha1.ApplicationMatchExpression) bool { @@ -966,7 +944,7 @@ func labelMatchedExpression(logCtx *log.Entry, val string, matchExpression argov } // this map is used to determine which stage of Applications are ready to be updated in the reconciler loop -func (r *ApplicationSetReconciler) buildAppSyncMap(ctx context.Context, applicationSet argov1alpha1.ApplicationSet, appDependencyList [][]string, appMap map[string]argov1alpha1.Application) (map[string]bool, error) { +func (r *ApplicationSetReconciler) buildAppSyncMap(ctx context.Context, applicationSet argov1alpha1.ApplicationSet, appDependencyList [][]string, appMap map[string]argov1alpha1.Application) map[string]bool { appSyncMap := map[string]bool{} syncEnabled := true @@ -1003,7 +981,7 @@ func (r *ApplicationSetReconciler) buildAppSyncMap(ctx context.Context, applicat } } - return appSyncMap, nil + return appSyncMap } func appSyncEnabledForNextStep(appset *argov1alpha1.ApplicationSet, app argov1alpha1.Application, appStatus argov1alpha1.ApplicationSetApplicationStatus) bool { @@ -1148,7 +1126,7 @@ func (r *ApplicationSetReconciler) updateApplicationSetApplicationStatus(ctx con } // check Applications that are in Waiting status and promote them to Pending if needed -func (r *ApplicationSetReconciler) updateApplicationSetApplicationStatusProgress(ctx context.Context, logCtx *log.Entry, applicationSet *argov1alpha1.ApplicationSet, appSyncMap map[string]bool, appStepMap map[string]int, appMap map[string]argov1alpha1.Application) ([]argov1alpha1.ApplicationSetApplicationStatus, error) { +func (r *ApplicationSetReconciler) updateApplicationSetApplicationStatusProgress(ctx context.Context, logCtx *log.Entry, applicationSet *argov1alpha1.ApplicationSet, appSyncMap map[string]bool, appStepMap map[string]int) ([]argov1alpha1.ApplicationSetApplicationStatus, error) { now := metav1.Now() appStatuses := make([]argov1alpha1.ApplicationSetApplicationStatus, 0, len(applicationSet.Status.ApplicationStatus)) @@ -1225,7 +1203,7 @@ func (r *ApplicationSetReconciler) updateApplicationSetApplicationStatusProgress return appStatuses, nil } -func (r *ApplicationSetReconciler) updateApplicationSetApplicationStatusConditions(ctx context.Context, applicationSet *argov1alpha1.ApplicationSet) ([]argov1alpha1.ApplicationSetCondition, error) { +func (r *ApplicationSetReconciler) updateApplicationSetApplicationStatusConditions(ctx context.Context, applicationSet *argov1alpha1.ApplicationSet) []argov1alpha1.ApplicationSetCondition { appSetProgressing := false for _, appStatus := range applicationSet.Status.ApplicationStatus { if appStatus.Status != "Healthy" { @@ -1264,7 +1242,7 @@ func (r *ApplicationSetReconciler) updateApplicationSetApplicationStatusConditio ) } - return applicationSet.Status.Conditions, nil + return applicationSet.Status.Conditions } func findApplicationStatusIndex(appStatuses []argov1alpha1.ApplicationSetApplicationStatus, application string) int { @@ -1374,7 +1352,7 @@ func (r *ApplicationSetReconciler) setAppSetApplicationStatus(ctx context.Contex return nil } -func (r *ApplicationSetReconciler) syncValidApplications(logCtx *log.Entry, applicationSet *argov1alpha1.ApplicationSet, appSyncMap map[string]bool, appMap map[string]argov1alpha1.Application, validApps []argov1alpha1.Application) ([]argov1alpha1.Application, error) { +func (r *ApplicationSetReconciler) syncValidApplications(logCtx *log.Entry, applicationSet *argov1alpha1.ApplicationSet, appSyncMap map[string]bool, appMap map[string]argov1alpha1.Application, validApps []argov1alpha1.Application) []argov1alpha1.Application { rolloutApps := []argov1alpha1.Application{} for i := range validApps { pruneEnabled := false @@ -1395,15 +1373,15 @@ func (r *ApplicationSetReconciler) syncValidApplications(logCtx *log.Entry, appl // check appSyncMap to determine which Applications are ready to be updated and which should be skipped if appSyncMap[validApps[i].Name] && appMap[validApps[i].Name].Status.Sync.Status == "OutOfSync" && appSetStatusPending { logCtx.Infof("triggering sync for application: %v, prune enabled: %v", validApps[i].Name, pruneEnabled) - validApps[i], _ = syncApplication(validApps[i], pruneEnabled) + validApps[i] = syncApplication(validApps[i], pruneEnabled) } rolloutApps = append(rolloutApps, validApps[i]) } - return rolloutApps, nil + return rolloutApps } // used by the RollingSync Progressive Sync strategy to trigger a sync of a particular Application resource -func syncApplication(application argov1alpha1.Application, prune bool) (argov1alpha1.Application, error) { +func syncApplication(application argov1alpha1.Application, prune bool) argov1alpha1.Application { operation := argov1alpha1.Operation{ InitiatedBy: argov1alpha1.OperationInitiator{ Username: "applicationset-controller", @@ -1429,7 +1407,7 @@ func syncApplication(application argov1alpha1.Application, prune bool) (argov1al } application.Operation = &operation - return application, nil + return application } func getOwnsHandlerPredicates(enableProgressiveSyncs bool) predicate.Funcs { diff --git a/applicationset/controllers/applicationset_controller_test.go b/applicationset/controllers/applicationset_controller_test.go index 006ae1cc34998..fa4344f9903af 100644 --- a/applicationset/controllers/applicationset_controller_test.go +++ b/applicationset/controllers/applicationset_controller_test.go @@ -3666,8 +3666,7 @@ func TestBuildAppDependencyList(t *testing.T) { KubeClientset: kubeclientset, } - appDependencyList, appStepMap, err := r.buildAppDependencyList(log.NewEntry(log.StandardLogger()), cc.appSet, cc.apps) - require.NoError(t, err, "expected no errors, but errors occurred") + appDependencyList, appStepMap := r.buildAppDependencyList(log.NewEntry(log.StandardLogger()), cc.appSet, cc.apps) assert.Equal(t, cc.expectedList, appDependencyList, "expected appDependencyList did not match actual") assert.Equal(t, cc.expectedStepMap, appStepMap, "expected appStepMap did not match actual") }) @@ -4257,8 +4256,7 @@ func TestBuildAppSyncMap(t *testing.T) { KubeClientset: kubeclientset, } - appSyncMap, err := r.buildAppSyncMap(context.TODO(), cc.appSet, cc.appDependencyList, cc.appMap) - require.NoError(t, err, "expected no errors, but errors occurred") + appSyncMap := r.buildAppSyncMap(context.TODO(), cc.appSet, cc.appDependencyList, cc.appMap) assert.Equal(t, cc.expectedMap, appSyncMap, "expected appSyncMap did not match actual") }) } @@ -5800,7 +5798,7 @@ func TestUpdateApplicationSetApplicationStatusProgress(t *testing.T) { KubeClientset: kubeclientset, } - appStatuses, err := r.updateApplicationSetApplicationStatusProgress(context.TODO(), log.NewEntry(log.StandardLogger()), &cc.appSet, cc.appSyncMap, cc.appStepMap, cc.appMap) + appStatuses, err := r.updateApplicationSetApplicationStatusProgress(context.TODO(), log.NewEntry(log.StandardLogger()), &cc.appSet, cc.appSyncMap, cc.appStepMap) // opt out of testing the LastTransitionTime is accurate for i := range appStatuses { diff --git a/cmd/argocd/commands/app_resource_test.go b/cmd/argocd/commands/app_resource_test.go index 5b85f96050109..4a6cd50d6800f 100644 --- a/cmd/argocd/commands/app_resource_test.go +++ b/cmd/argocd/commands/app_resource_test.go @@ -36,7 +36,7 @@ func TestPrintTreeViewAppResources(t *testing.T) { buf := &bytes.Buffer{} w := tabwriter.NewWriter(buf, 0, 0, 2, ' ', 0) - printTreeViewAppResourcesNotOrphaned(nodeMapping, mapParentToChild, parentNode, false, false, w) + printTreeViewAppResourcesNotOrphaned(nodeMapping, mapParentToChild, parentNode, w) if err := w.Flush(); err != nil { t.Fatal(err) } @@ -77,7 +77,7 @@ func TestPrintTreeViewDetailedAppResources(t *testing.T) { buf := &bytes.Buffer{} w := tabwriter.NewWriter(buf, 0, 0, 2, ' ', 0) - printDetailedTreeViewAppResourcesNotOrphaned(nodeMapping, mapParentToChild, parentNode, false, false, w) + printDetailedTreeViewAppResourcesNotOrphaned(nodeMapping, mapParentToChild, parentNode, w) if err := w.Flush(); err != nil { t.Fatal(err) } diff --git a/cmd/argocd/commands/app_resources.go b/cmd/argocd/commands/app_resources.go index c1fc1dfc82f2a..f86ab0669661b 100644 --- a/cmd/argocd/commands/app_resources.go +++ b/cmd/argocd/commands/app_resources.go @@ -175,25 +175,25 @@ func parentChildInfo(nodes []v1alpha1.ResourceNode) (map[string]v1alpha1.Resourc return mapUidToNode, mapParentToChild, parentNode } -func printDetailedTreeViewAppResourcesNotOrphaned(nodeMapping map[string]v1alpha1.ResourceNode, parentChildMapping map[string][]string, parentNodes map[string]struct{}, orphaned bool, listAll bool, w *tabwriter.Writer) { +func printDetailedTreeViewAppResourcesNotOrphaned(nodeMapping map[string]v1alpha1.ResourceNode, parentChildMapping map[string][]string, parentNodes map[string]struct{}, w *tabwriter.Writer) { for uid := range parentNodes { detailedTreeViewAppResourcesNotOrphaned("", nodeMapping, parentChildMapping, nodeMapping[uid], w) } } -func printDetailedTreeViewAppResourcesOrphaned(nodeMapping map[string]v1alpha1.ResourceNode, parentChildMapping map[string][]string, parentNodes map[string]struct{}, orphaned bool, listAll bool, w *tabwriter.Writer) { +func printDetailedTreeViewAppResourcesOrphaned(nodeMapping map[string]v1alpha1.ResourceNode, parentChildMapping map[string][]string, parentNodes map[string]struct{}, w *tabwriter.Writer) { for uid := range parentNodes { detailedTreeViewAppResourcesOrphaned("", nodeMapping, parentChildMapping, nodeMapping[uid], w) } } -func printTreeViewAppResourcesNotOrphaned(nodeMapping map[string]v1alpha1.ResourceNode, parentChildMapping map[string][]string, parentNodes map[string]struct{}, orphaned bool, listAll bool, w *tabwriter.Writer) { +func printTreeViewAppResourcesNotOrphaned(nodeMapping map[string]v1alpha1.ResourceNode, parentChildMapping map[string][]string, parentNodes map[string]struct{}, w *tabwriter.Writer) { for uid := range parentNodes { treeViewAppResourcesNotOrphaned("", nodeMapping, parentChildMapping, nodeMapping[uid], w) } } -func printTreeViewAppResourcesOrphaned(nodeMapping map[string]v1alpha1.ResourceNode, parentChildMapping map[string][]string, parentNodes map[string]struct{}, orphaned bool, listAll bool, w *tabwriter.Writer) { +func printTreeViewAppResourcesOrphaned(nodeMapping map[string]v1alpha1.ResourceNode, parentChildMapping map[string][]string, parentNodes map[string]struct{}, w *tabwriter.Writer) { for uid := range parentNodes { treeViewAppResourcesOrphaned("", nodeMapping, parentChildMapping, nodeMapping[uid], w) } @@ -206,24 +206,24 @@ func printResources(listAll bool, orphaned bool, appResourceTree *v1alpha1.Appli if !orphaned || listAll { mapUidToNode, mapParentToChild, parentNode := parentChildInfo(appResourceTree.Nodes) - printDetailedTreeViewAppResourcesNotOrphaned(mapUidToNode, mapParentToChild, parentNode, orphaned, listAll, w) + printDetailedTreeViewAppResourcesNotOrphaned(mapUidToNode, mapParentToChild, parentNode, w) } if orphaned || listAll { mapUidToNode, mapParentToChild, parentNode := parentChildInfo(appResourceTree.OrphanedNodes) - printDetailedTreeViewAppResourcesOrphaned(mapUidToNode, mapParentToChild, parentNode, orphaned, listAll, w) + printDetailedTreeViewAppResourcesOrphaned(mapUidToNode, mapParentToChild, parentNode, w) } } else if output == "tree" { fmt.Fprintf(w, "GROUP\tKIND\tNAMESPACE\tNAME\tORPHANED\n") if !orphaned || listAll { mapUidToNode, mapParentToChild, parentNode := parentChildInfo(appResourceTree.Nodes) - printTreeViewAppResourcesNotOrphaned(mapUidToNode, mapParentToChild, parentNode, orphaned, listAll, w) + printTreeViewAppResourcesNotOrphaned(mapUidToNode, mapParentToChild, parentNode, w) } if orphaned || listAll { mapUidToNode, mapParentToChild, parentNode := parentChildInfo(appResourceTree.OrphanedNodes) - printTreeViewAppResourcesOrphaned(mapUidToNode, mapParentToChild, parentNode, orphaned, listAll, w) + printTreeViewAppResourcesOrphaned(mapUidToNode, mapParentToChild, parentNode, w) } } else { headers := []interface{}{"GROUP", "KIND", "NAMESPACE", "NAME", "ORPHANED"} diff --git a/controller/state.go b/controller/state.go index a9a3be4bdd6b8..8c6b24c643965 100644 --- a/controller/state.go +++ b/controller/state.go @@ -591,7 +591,7 @@ func (m *appStateManager) CompareAppState(app *v1alpha1.Application, project *v1 } // No need to care about the return value here, we just want the modified managedNs - _, err = syncNamespace(m.resourceTracking, appLabelKey, trackingMethod, app.Name, app.Spec.SyncPolicy)(managedNs, liveObj) + _, err = syncNamespace(app.Spec.SyncPolicy)(managedNs, liveObj) if err != nil { conditions = append(conditions, v1alpha1.ApplicationCondition{Type: v1alpha1.ApplicationConditionComparisonError, Message: err.Error(), LastTransitionTime: &now}) failedToLoadObjs = true diff --git a/controller/sync.go b/controller/sync.go index 9cd4b1f0c6e93..ecfeec709ee3c 100644 --- a/controller/sync.go +++ b/controller/sync.go @@ -324,7 +324,7 @@ func (m *appStateManager) SyncAppState(app *v1alpha1.Application, state *v1alpha } if syncOp.SyncOptions.HasOption("CreateNamespace=true") { - opts = append(opts, sync.WithNamespaceModifier(syncNamespace(m.resourceTracking, appLabelKey, trackingMethod, app.Name, app.Spec.SyncPolicy))) + opts = append(opts, sync.WithNamespaceModifier(syncNamespace(app.Spec.SyncPolicy))) } syncCtx, cleanup, err := sync.NewSyncContext( diff --git a/controller/sync_namespace.go b/controller/sync_namespace.go index 9578dc8651322..43e0dc6170f48 100644 --- a/controller/sync_namespace.go +++ b/controller/sync_namespace.go @@ -5,12 +5,11 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" - "github.com/argoproj/argo-cd/v2/util/argo" ) // syncNamespace determine if Argo CD should create and/or manage the namespace // where the application will be deployed. -func syncNamespace(resourceTracking argo.ResourceTracking, appLabelKey string, trackingMethod v1alpha1.TrackingMethod, appName string, syncPolicy *v1alpha1.SyncPolicy) func(m, l *unstructured.Unstructured) (bool, error) { +func syncNamespace(syncPolicy *v1alpha1.SyncPolicy) func(m *unstructured.Unstructured, l *unstructured.Unstructured) (bool, error) { // This function must return true for the managed namespace to be synced. return func(managedNs, liveNs *unstructured.Unstructured) (bool, error) { if managedNs == nil { diff --git a/controller/sync_namespace_test.go b/controller/sync_namespace_test.go index 7e60b0d287789..0124d99532b91 100644 --- a/controller/sync_namespace_test.go +++ b/controller/sync_namespace_test.go @@ -8,9 +8,7 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/types" - "github.com/argoproj/argo-cd/v2/common" "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" - "github.com/argoproj/argo-cd/v2/util/argo" ) func createFakeNamespace(uid string, resourceVersion string, labels map[string]string, annotations map[string]string) *unstructured.Unstructured { @@ -250,7 +248,7 @@ func Test_shouldNamespaceSync(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - actual, err := syncNamespace(argo.NewResourceTracking(), common.LabelKeyAppInstance, argo.TrackingMethodAnnotation, "some-app", tt.syncPolicy)(tt.managedNs, tt.liveNs) + actual, err := syncNamespace(tt.syncPolicy)(tt.managedNs, tt.liveNs) require.NoError(t, err) if tt.managedNs != nil { diff --git a/hack/gen-resources/generators/cluster_generator.go b/hack/gen-resources/generators/cluster_generator.go index 6f125723c35ef..c07343f15c6d5 100644 --- a/hack/gen-resources/generators/cluster_generator.go +++ b/hack/gen-resources/generators/cluster_generator.go @@ -161,7 +161,7 @@ func (cg *ClusterGenerator) getClusterServerUri(namespace string, releaseSuffix return "https://" + pod.Status.PodIP + ":8443", nil } -func (cg *ClusterGenerator) retrieveClusterUri(namespace, releaseSuffix string) (string, error) { +func (cg *ClusterGenerator) retrieveClusterUri(namespace, releaseSuffix string) string { for i := 0; i < 10; i++ { log.Printf("Attempting to get cluster uri") uri, err := cg.getClusterServerUri(namespace, releaseSuffix) @@ -170,9 +170,9 @@ func (cg *ClusterGenerator) retrieveClusterUri(namespace, releaseSuffix string) time.Sleep(10 * time.Second) continue } - return uri, nil + return uri } - return "", nil + return "" } func (cg *ClusterGenerator) generate(i int, opts *util.GenerateOpts) error { @@ -208,11 +208,7 @@ func (cg *ClusterGenerator) generate(i int, opts *util.GenerateOpts) error { log.Print("Get cluster server uri") - uri, err := cg.retrieveClusterUri(namespace, releaseSuffix) - if err != nil { - return err - } - + uri := cg.retrieveClusterUri(namespace, releaseSuffix) log.Printf("Cluster server uri is %s", uri) log.Print("Create cluster") diff --git a/reposerver/repository/repository.go b/reposerver/repository/repository.go index d530f1a6e0c15..a729ca1b1af51 100644 --- a/reposerver/repository/repository.go +++ b/reposerver/repository/repository.go @@ -2042,7 +2042,7 @@ func (s *Service) GetAppDetails(ctx context.Context, q *apiclient.RepoServerAppD return err } case v1alpha1.ApplicationSourceTypePlugin: - if err := populatePluginAppDetails(ctx, res, opContext.appPath, repoRoot, q, s.gitCredsStore, s.initConstants.CMPTarExcludedGlobs); err != nil { + if err := populatePluginAppDetails(ctx, res, opContext.appPath, repoRoot, q, s.initConstants.CMPTarExcludedGlobs); err != nil { return fmt.Errorf("failed to populate plugin app details: %w", err) } } @@ -2196,7 +2196,7 @@ func populateKustomizeAppDetails(res *apiclient.RepoAppDetailsResponse, q *apicl return nil } -func populatePluginAppDetails(ctx context.Context, res *apiclient.RepoAppDetailsResponse, appPath string, repoPath string, q *apiclient.RepoServerAppDetailsQuery, store git.CredsStore, tarExcludedGlobs []string) error { +func populatePluginAppDetails(ctx context.Context, res *apiclient.RepoAppDetailsResponse, appPath string, repoPath string, q *apiclient.RepoServerAppDetailsQuery, tarExcludedGlobs []string) error { res.Plugin = &apiclient.PluginAppSpec{} envVars := []string{ diff --git a/util/argo/argo.go b/util/argo/argo.go index a4d4ed603533c..91a47904a05f2 100644 --- a/util/argo/argo.go +++ b/util/argo/argo.go @@ -509,7 +509,7 @@ func ValidateDestination(ctx context.Context, dest *argoappv1.ApplicationDestina return nil } -func validateSourcePermissions(ctx context.Context, source argoappv1.ApplicationSource, proj *argoappv1.AppProject, project string, hasMultipleSources bool) []argoappv1.ApplicationCondition { +func validateSourcePermissions(source argoappv1.ApplicationSource, hasMultipleSources bool) []argoappv1.ApplicationCondition { var conditions []argoappv1.ApplicationCondition if hasMultipleSources { if source.RepoURL == "" || (source.Path == "" && source.Chart == "" && source.Ref == "") { @@ -545,7 +545,7 @@ func ValidatePermissions(ctx context.Context, spec *argoappv1.ApplicationSpec, p if spec.HasMultipleSources() { for _, source := range spec.Sources { - condition := validateSourcePermissions(ctx, source, proj, spec.Project, spec.HasMultipleSources()) + condition := validateSourcePermissions(source, spec.HasMultipleSources()) if len(condition) > 0 { conditions = append(conditions, condition...) return conditions, nil @@ -559,7 +559,7 @@ func ValidatePermissions(ctx context.Context, spec *argoappv1.ApplicationSpec, p } } } else { - conditions = validateSourcePermissions(ctx, spec.GetSource(), proj, spec.Project, spec.HasMultipleSources()) + conditions = validateSourcePermissions(spec.GetSource(), spec.HasMultipleSources()) if len(conditions) > 0 { return conditions, nil } diff --git a/util/argo/resource_tracking.go b/util/argo/resource_tracking.go index 476f739c13924..312637104a01c 100644 --- a/util/argo/resource_tracking.go +++ b/util/argo/resource_tracking.go @@ -65,7 +65,7 @@ func IsOldTrackingMethod(trackingMethod string) bool { return trackingMethod == "" || trackingMethod == string(TrackingMethodLabel) } -func (rt *resourceTracking) getAppInstanceValue(un *unstructured.Unstructured, key string, trackingMethod v1alpha1.TrackingMethod) *AppInstanceValue { +func (rt *resourceTracking) getAppInstanceValue(un *unstructured.Unstructured) *AppInstanceValue { appInstanceAnnotation, err := argokube.GetAppInstanceAnnotation(un, common.AnnotationKeyAppInstance) if err != nil { return nil @@ -80,7 +80,7 @@ func (rt *resourceTracking) getAppInstanceValue(un *unstructured.Unstructured, k // GetAppName retrieve application name base on tracking method func (rt *resourceTracking) GetAppName(un *unstructured.Unstructured, key string, trackingMethod v1alpha1.TrackingMethod) string { retrieveAppInstanceValue := func() string { - value := rt.getAppInstanceValue(un, key, trackingMethod) + value := rt.getAppInstanceValue(un) if value != nil { return value.ApplicationName } @@ -112,7 +112,7 @@ func (rt *resourceTracking) GetAppName(un *unstructured.Unstructured, key string func (rt *resourceTracking) GetAppInstance(un *unstructured.Unstructured, key string, trackingMethod v1alpha1.TrackingMethod) *AppInstanceValue { switch trackingMethod { case TrackingMethodAnnotation, TrackingMethodAnnotationAndLabel: - return rt.getAppInstanceValue(un, key, trackingMethod) + return rt.getAppInstanceValue(un) default: return nil } diff --git a/util/kube/kube.go b/util/kube/kube.go index 5ea4394b726f0..700f5d2f8420e 100644 --- a/util/kube/kube.go +++ b/util/kube/kube.go @@ -21,7 +21,7 @@ func IsValidResourceName(name string) bool { // SetAppInstanceLabel the recommended app.kubernetes.io/instance label against an unstructured object // Uses the legacy labeling if environment variable is set func SetAppInstanceLabel(target *unstructured.Unstructured, key, val string) error { - labels, _, err := nestedNullableStringMap(target.Object, "metadata", "labels") + labels, err := nestedNullableStringMap(target.Object, "metadata", "labels") if err != nil { return fmt.Errorf("failed to get labels from target object %s %s/%s: %w", target.GroupVersionKind().String(), target.GetNamespace(), target.GetName(), err) } @@ -100,7 +100,7 @@ func SetAppInstanceLabel(target *unstructured.Unstructured, key, val string) err // SetAppInstanceAnnotation the recommended app.kubernetes.io/instance annotation against an unstructured object // Uses the legacy labeling if environment variable is set func SetAppInstanceAnnotation(target *unstructured.Unstructured, key, val string) error { - annotations, _, err := nestedNullableStringMap(target.Object, "metadata", "annotations") + annotations, err := nestedNullableStringMap(target.Object, "metadata", "annotations") if err != nil { return fmt.Errorf("failed to get annotations from target object %s %s/%s: %w", target.GroupVersionKind().String(), target.GetNamespace(), target.GetName(), err) } @@ -115,7 +115,7 @@ func SetAppInstanceAnnotation(target *unstructured.Unstructured, key, val string // GetAppInstanceAnnotation returns the application instance name from annotation func GetAppInstanceAnnotation(un *unstructured.Unstructured, key string) (string, error) { - annotations, _, err := nestedNullableStringMap(un.Object, "metadata", "annotations") + annotations, err := nestedNullableStringMap(un.Object, "metadata", "annotations") if err != nil { return "", fmt.Errorf("failed to get annotations from target object %s %s/%s: %w", un.GroupVersionKind().String(), un.GetNamespace(), un.GetName(), err) } @@ -127,7 +127,7 @@ func GetAppInstanceAnnotation(un *unstructured.Unstructured, key string) (string // GetAppInstanceLabel returns the application instance name from labels func GetAppInstanceLabel(un *unstructured.Unstructured, key string) (string, error) { - labels, _, err := nestedNullableStringMap(un.Object, "metadata", "labels") + labels, err := nestedNullableStringMap(un.Object, "metadata", "labels") if err != nil { return "", fmt.Errorf("failed to get labels for %s %s/%s: %w", un.GroupVersionKind().String(), un.GetNamespace(), un.GetName(), err) } @@ -139,7 +139,7 @@ func GetAppInstanceLabel(un *unstructured.Unstructured, key string) (string, err // RemoveLabel removes label with the specified name func RemoveLabel(un *unstructured.Unstructured, key string) error { - labels, _, err := nestedNullableStringMap(un.Object, "metadata", "labels") + labels, err := nestedNullableStringMap(un.Object, "metadata", "labels") if err != nil { return fmt.Errorf("failed to get labels for %s %s/%s: %w", un.GroupVersionKind().String(), un.GetNamespace(), un.GetName(), err) } @@ -163,14 +163,15 @@ func RemoveLabel(un *unstructured.Unstructured, key string) error { // nestedNullableStringMap returns a copy of map[string]string value of a nested field. // Returns false if value is not found and an error if not one of map[string]interface{} or nil, or contains non-string values in the map. -func nestedNullableStringMap(obj map[string]interface{}, fields ...string) (map[string]string, bool, error) { +func nestedNullableStringMap(obj map[string]interface{}, fields ...string) (map[string]string, error) { var m map[string]string val, found, err := unstructured.NestedFieldNoCopy(obj, fields...) if err != nil { - return nil, found, err + return nil, err } if found && val != nil { - return unstructured.NestedStringMap(obj, fields...) + m, _, err = unstructured.NestedStringMap(obj, fields...) + return m, err } - return m, found, err + return m, err } diff --git a/util/manifeststream/stream.go b/util/manifeststream/stream.go index 9243b735fc53c..dd02f2570d975 100644 --- a/util/manifeststream/stream.go +++ b/util/manifeststream/stream.go @@ -179,7 +179,7 @@ func ReceiveManifestFileStream(ctx context.Context, receiver RepoStreamReceiver, } metadata := header2.GetMetadata() - tgzFile, err := receiveFile(ctx, receiver, metadata.GetChecksum(), destDir, maxTarSize) + tgzFile, err := receiveFile(ctx, receiver, metadata.GetChecksum(), maxTarSize) if err != nil { return nil, nil, fmt.Errorf("error receiving tgz file: %w", err) } @@ -197,7 +197,7 @@ func ReceiveManifestFileStream(ctx context.Context, receiver RepoStreamReceiver, // receiveFile will receive the file from the gRPC stream and save it in the dst folder. // Returns error if checksum doesn't match the one provided in the fileMetadata. // It is responsibility of the caller to close the returned file. -func receiveFile(ctx context.Context, receiver RepoStreamReceiver, checksum, dst string, maxSize int64) (*os.File, error) { +func receiveFile(ctx context.Context, receiver RepoStreamReceiver, checksum string, maxSize int64) (*os.File, error) { hasher := sha256.New() tmpDir, err := files.CreateTempDir("") if err != nil { From d259b67692906bd9393964b6696cb8860a6e6b04 Mon Sep 17 00:00:00 2001 From: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Date: Sat, 10 Aug 2024 17:16:21 -0400 Subject: [PATCH 2/2] more Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> --- .golangci.yaml | 5 ++++ .../controllers/applicationset_controller.go | 30 +++++++------------ .../applicationset_controller_test.go | 2 +- server/application/application.go | 4 +-- server/applicationset/applicationset.go | 8 ++--- util/kube/kube.go | 1 - util/oidc/oidc.go | 12 ++++---- util/oidc/oidc_test.go | 18 +++++------ 8 files changed, 38 insertions(+), 42 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 2351f11e0fecc..8a1e59816ad27 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -4,6 +4,10 @@ issues: - SA5011 max-issues-per-linter: 0 max-same-issues: 0 + exclude-rules: + - path: '(.+)_test\.go' + linters: + - unparam linters: enable: - errcheck @@ -17,6 +21,7 @@ linters: - misspell - staticcheck - testifylint + - unparam - unused - whitespace linters-settings: diff --git a/applicationset/controllers/applicationset_controller.go b/applicationset/controllers/applicationset_controller.go index 69caef3117602..cec1f23400e86 100644 --- a/applicationset/controllers/applicationset_controller.go +++ b/applicationset/controllers/applicationset_controller.go @@ -242,7 +242,7 @@ func (r *ApplicationSetReconciler) Reconcile(ctx context.Context, req ctrl.Reque if r.EnableProgressiveSyncs { // trigger appropriate application syncs if RollingSync strategy is enabled - if progressiveSyncsStrategyEnabled(&applicationSetInfo, "RollingSync") { + if progressiveSyncsRollingSyncStrategyEnabled(&applicationSetInfo) { validApps = r.syncValidApplications(logCtx, &applicationSetInfo, appSyncMap, appMap, validApps) } } @@ -859,7 +859,7 @@ func (r *ApplicationSetReconciler) performProgressiveSyncs(ctx context.Context, logCtx.Infof("step %v: %+v", i+1, step) } - appSyncMap := r.buildAppSyncMap(ctx, appset, appDependencyList, appMap) + appSyncMap := r.buildAppSyncMap(appset, appDependencyList, appMap) logCtx.Infof("Application allowed to sync before maxUpdate?: %+v", appSyncMap) _, err = r.updateApplicationSetApplicationStatusProgress(ctx, logCtx, &appset, appSyncMap, appStepMap) @@ -879,7 +879,7 @@ func (r *ApplicationSetReconciler) buildAppDependencyList(logCtx *log.Entry, app } steps := []argov1alpha1.ApplicationSetRolloutStep{} - if progressiveSyncsStrategyEnabled(&applicationSet, "RollingSync") { + if progressiveSyncsRollingSyncStrategyEnabled(&applicationSet) { steps = applicationSet.Spec.Strategy.RollingSync.Steps } @@ -944,7 +944,7 @@ func labelMatchedExpression(logCtx *log.Entry, val string, matchExpression argov } // this map is used to determine which stage of Applications are ready to be updated in the reconciler loop -func (r *ApplicationSetReconciler) buildAppSyncMap(ctx context.Context, applicationSet argov1alpha1.ApplicationSet, appDependencyList [][]string, appMap map[string]argov1alpha1.Application) map[string]bool { +func (r *ApplicationSetReconciler) buildAppSyncMap(applicationSet argov1alpha1.ApplicationSet, appDependencyList [][]string, appMap map[string]argov1alpha1.Application) map[string]bool { appSyncMap := map[string]bool{} syncEnabled := true @@ -985,7 +985,7 @@ func (r *ApplicationSetReconciler) buildAppSyncMap(ctx context.Context, applicat } func appSyncEnabledForNextStep(appset *argov1alpha1.ApplicationSet, app argov1alpha1.Application, appStatus argov1alpha1.ApplicationSetApplicationStatus) bool { - if progressiveSyncsStrategyEnabled(appset, "RollingSync") { + if progressiveSyncsRollingSyncStrategyEnabled(appset) { // we still need to complete the current step if the Application is not yet Healthy or there are still pending Application changes return isApplicationHealthy(app) && appStatus.Status == "Healthy" } @@ -993,16 +993,8 @@ func appSyncEnabledForNextStep(appset *argov1alpha1.ApplicationSet, app argov1al return true } -func progressiveSyncsStrategyEnabled(appset *argov1alpha1.ApplicationSet, strategyType string) bool { - if appset.Spec.Strategy == nil || appset.Spec.Strategy.Type != strategyType { - return false - } - - if strategyType == "RollingSync" && appset.Spec.Strategy.RollingSync == nil { - return false - } - - return true +func progressiveSyncsRollingSyncStrategyEnabled(appset *argov1alpha1.ApplicationSet) bool { + return appset.Spec.Strategy != nil && appset.Spec.Strategy.RollingSync != nil && appset.Spec.Strategy.Type == "RollingSync" } func isApplicationHealthy(app argov1alpha1.Application) bool { @@ -1060,7 +1052,7 @@ func (r *ApplicationSetReconciler) updateApplicationSetApplicationStatus(ctx con } appOutdated := false - if progressiveSyncsStrategyEnabled(applicationSet, "RollingSync") { + if progressiveSyncsRollingSyncStrategyEnabled(applicationSet) { appOutdated = syncStatusString == "OutOfSync" } @@ -1137,7 +1129,7 @@ func (r *ApplicationSetReconciler) updateApplicationSetApplicationStatusProgress totalCountMap := []int{} length := 0 - if progressiveSyncsStrategyEnabled(applicationSet, "RollingSync") { + if progressiveSyncsRollingSyncStrategyEnabled(applicationSet) { length = len(applicationSet.Spec.Strategy.RollingSync.Steps) } for s := 0; s < length; s++ { @@ -1149,7 +1141,7 @@ func (r *ApplicationSetReconciler) updateApplicationSetApplicationStatusProgress for _, appStatus := range applicationSet.Status.ApplicationStatus { totalCountMap[appStepMap[appStatus.Application]] += 1 - if progressiveSyncsStrategyEnabled(applicationSet, "RollingSync") { + if progressiveSyncsRollingSyncStrategyEnabled(applicationSet) { if appStatus.Status == "Pending" || appStatus.Status == "Progressing" { updateCountMap[appStepMap[appStatus.Application]] += 1 } @@ -1159,7 +1151,7 @@ func (r *ApplicationSetReconciler) updateApplicationSetApplicationStatusProgress for _, appStatus := range applicationSet.Status.ApplicationStatus { maxUpdateAllowed := true maxUpdate := &intstr.IntOrString{} - if progressiveSyncsStrategyEnabled(applicationSet, "RollingSync") { + if progressiveSyncsRollingSyncStrategyEnabled(applicationSet) { maxUpdate = applicationSet.Spec.Strategy.RollingSync.Steps[appStepMap[appStatus.Application]].MaxUpdate } diff --git a/applicationset/controllers/applicationset_controller_test.go b/applicationset/controllers/applicationset_controller_test.go index fa4344f9903af..dba734c8410b5 100644 --- a/applicationset/controllers/applicationset_controller_test.go +++ b/applicationset/controllers/applicationset_controller_test.go @@ -4256,7 +4256,7 @@ func TestBuildAppSyncMap(t *testing.T) { KubeClientset: kubeclientset, } - appSyncMap := r.buildAppSyncMap(context.TODO(), cc.appSet, cc.appDependencyList, cc.appMap) + appSyncMap := r.buildAppSyncMap(cc.appSet, cc.appDependencyList, cc.appMap) assert.Equal(t, cc.expectedMap, appSyncMap, "expected appSyncMap did not match actual") }) } diff --git a/server/application/application.go b/server/application/application.go index 0640bbaa13ebb..3972ee9dc6608 100644 --- a/server/application/application.go +++ b/server/application/application.go @@ -2444,7 +2444,7 @@ func (s *Server) RunResourceAction(ctx context.Context, q *application.ResourceA // the dry-run for relevant apply/delete operation would have to be invoked as well. for _, impactedResource := range newObjects { newObj := impactedResource.UnstructuredObj - err := s.verifyResourcePermitted(ctx, app, proj, newObj) + err := s.verifyResourcePermitted(app, proj, newObj) if err != nil { return nil, err } @@ -2537,7 +2537,7 @@ func (s *Server) patchResource(ctx context.Context, config *rest.Config, liveObj return &application.ApplicationResponse{}, nil } -func (s *Server) verifyResourcePermitted(ctx context.Context, app *appv1.Application, proj *appv1.AppProject, obj *unstructured.Unstructured) error { +func (s *Server) verifyResourcePermitted(app *appv1.Application, proj *appv1.AppProject, obj *unstructured.Unstructured) error { permitted, err := proj.IsResourcePermitted(schema.GroupKind{Group: obj.GroupVersionKind().Group, Kind: obj.GroupVersionKind().Kind}, obj.GetNamespace(), app.Spec.Destination, func(project string) ([]*appv1.Cluster, error) { clusters, err := s.db.GetProjectClusters(context.TODO(), project) if err != nil { diff --git a/server/applicationset/applicationset.go b/server/applicationset/applicationset.go index a66173384e8c1..23bf93344d6d3 100644 --- a/server/applicationset/applicationset.go +++ b/server/applicationset/applicationset.go @@ -185,7 +185,7 @@ func (s *Server) Create(ctx context.Context, q *applicationset.ApplicationSetCre return nil, fmt.Errorf("error creating ApplicationSets: ApplicationSets is nil in request") } - projectName, err := s.validateAppSet(ctx, appset) + projectName, err := s.validateAppSet(appset) if err != nil { return nil, fmt.Errorf("error validating ApplicationSets: %w", err) } @@ -363,10 +363,10 @@ func (s *Server) ResourceTree(ctx context.Context, q *applicationset.Application return nil, err } - return s.buildApplicationSetTree(ctx, a) + return s.buildApplicationSetTree(a) } -func (s *Server) buildApplicationSetTree(ctx context.Context, a *v1alpha1.ApplicationSet) (*v1alpha1.ApplicationSetTree, error) { +func (s *Server) buildApplicationSetTree(a *v1alpha1.ApplicationSet) (*v1alpha1.ApplicationSetTree, error) { var tree v1alpha1.ApplicationSetTree gvk := v1alpha1.ApplicationSetSchemaGroupVersionKind @@ -393,7 +393,7 @@ func (s *Server) buildApplicationSetTree(ctx context.Context, a *v1alpha1.Applic return &tree, nil } -func (s *Server) validateAppSet(ctx context.Context, appset *v1alpha1.ApplicationSet) (string, error) { +func (s *Server) validateAppSet(appset *v1alpha1.ApplicationSet) (string, error) { if appset == nil { return "", fmt.Errorf("ApplicationSet cannot be validated for nil value") } diff --git a/util/kube/kube.go b/util/kube/kube.go index 700f5d2f8420e..a982460e331e6 100644 --- a/util/kube/kube.go +++ b/util/kube/kube.go @@ -171,7 +171,6 @@ func nestedNullableStringMap(obj map[string]interface{}, fields ...string) (map[ } if found && val != nil { m, _, err = unstructured.NestedStringMap(obj, fields...) - return m, err } return m, err } diff --git a/util/oidc/oidc.go b/util/oidc/oidc.go index e56448e48b638..5708532061d6a 100644 --- a/util/oidc/oidc.go +++ b/util/oidc/oidc.go @@ -404,7 +404,7 @@ func (a *ClientApp) HandleCallback(w http.ResponseWriter, r *http.Request) { } sub := jwtutil.StringField(claims, "sub") err = a.clientCache.Set(&cache.Item{ - Key: formatAccessTokenCacheKey(AccessTokenCachePrefix, sub), + Key: formatAccessTokenCacheKey(sub), Object: encToken, CacheActionOpts: cache.CacheActionOpts{ Expiration: getTokenExpiration(claims), @@ -557,7 +557,7 @@ func (a *ClientApp) GetUserInfo(actualClaims jwt.MapClaims, issuerURL, userInfoP var encClaims []byte // in case we got it in the cache, we just return the item - clientCacheKey := formatUserInfoResponseCacheKey(UserInfoResponseCachePrefix, sub) + clientCacheKey := formatUserInfoResponseCacheKey(sub) if err := a.clientCache.Get(clientCacheKey, &encClaims); err == nil { claimsRaw, err := crypto.Decrypt(encClaims, a.encryptionKey) if err != nil { @@ -575,7 +575,7 @@ func (a *ClientApp) GetUserInfo(actualClaims jwt.MapClaims, issuerURL, userInfoP // check if the accessToken for the user is still present var encAccessToken []byte - err := a.clientCache.Get(formatAccessTokenCacheKey(AccessTokenCachePrefix, sub), &encAccessToken) + err := a.clientCache.Get(formatAccessTokenCacheKey(sub), &encAccessToken) // without an accessToken we can't query the user info endpoint // thus the user needs to reauthenticate for argocd to get a new accessToken if errors.Is(err, cache.ErrCacheMiss) { @@ -684,11 +684,11 @@ func getTokenExpiration(claims jwt.MapClaims) time.Duration { } // formatUserInfoResponseCacheKey returns the key which is used to store userinfo of user in cache -func formatUserInfoResponseCacheKey(prefix, sub string) string { +func formatUserInfoResponseCacheKey(sub string) string { return fmt.Sprintf("%s_%s", UserInfoResponseCachePrefix, sub) } // formatAccessTokenCacheKey returns the key which is used to store the accessToken of a user in cache -func formatAccessTokenCacheKey(prefix, sub string) string { - return fmt.Sprintf("%s_%s", prefix, sub) +func formatAccessTokenCacheKey(sub string) string { + return fmt.Sprintf("%s_%s", AccessTokenCachePrefix, sub) } diff --git a/util/oidc/oidc_test.go b/util/oidc/oidc_test.go index c7a47bcdfb3de..8332acaf98885 100644 --- a/util/oidc/oidc_test.go +++ b/util/oidc/oidc_test.go @@ -639,7 +639,7 @@ func TestGetUserInfo(t *testing.T) { expectError bool }{ { - key: formatUserInfoResponseCacheKey(UserInfoResponseCachePrefix, "randomUser"), + key: formatUserInfoResponseCacheKey("randomUser"), expectError: true, }, }, @@ -654,7 +654,7 @@ func TestGetUserInfo(t *testing.T) { encrypt bool }{ { - key: formatAccessTokenCacheKey(AccessTokenCachePrefix, "randomUser"), + key: formatAccessTokenCacheKey("randomUser"), value: "FakeAccessToken", encrypt: true, }, @@ -673,7 +673,7 @@ func TestGetUserInfo(t *testing.T) { expectError bool }{ { - key: formatUserInfoResponseCacheKey(UserInfoResponseCachePrefix, "randomUser"), + key: formatUserInfoResponseCacheKey("randomUser"), expectError: true, }, }, @@ -688,7 +688,7 @@ func TestGetUserInfo(t *testing.T) { encrypt bool }{ { - key: formatAccessTokenCacheKey(AccessTokenCachePrefix, "randomUser"), + key: formatAccessTokenCacheKey("randomUser"), value: "FakeAccessToken", encrypt: true, }, @@ -707,7 +707,7 @@ func TestGetUserInfo(t *testing.T) { expectError bool }{ { - key: formatUserInfoResponseCacheKey(UserInfoResponseCachePrefix, "randomUser"), + key: formatUserInfoResponseCacheKey("randomUser"), expectError: true, }, }, @@ -730,7 +730,7 @@ func TestGetUserInfo(t *testing.T) { encrypt bool }{ { - key: formatAccessTokenCacheKey(AccessTokenCachePrefix, "randomUser"), + key: formatAccessTokenCacheKey("randomUser"), value: "FakeAccessToken", encrypt: true, }, @@ -749,7 +749,7 @@ func TestGetUserInfo(t *testing.T) { expectError bool }{ { - key: formatUserInfoResponseCacheKey(UserInfoResponseCachePrefix, "randomUser"), + key: formatUserInfoResponseCacheKey("randomUser"), expectError: true, }, }, @@ -782,7 +782,7 @@ func TestGetUserInfo(t *testing.T) { expectError bool }{ { - key: formatUserInfoResponseCacheKey(UserInfoResponseCachePrefix, "randomUser"), + key: formatUserInfoResponseCacheKey("randomUser"), value: "{\"groups\":[\"githubOrg:engineers\"]}", expectEncrypted: true, expectError: false, @@ -809,7 +809,7 @@ func TestGetUserInfo(t *testing.T) { encrypt bool }{ { - key: formatAccessTokenCacheKey(AccessTokenCachePrefix, "randomUser"), + key: formatAccessTokenCacheKey("randomUser"), value: "FakeAccessToken", encrypt: true, },