mirror of
https://github.com/argoproj/argo-cd
synced 2026-04-21 08:57:17 +00:00
chore(ci): upgrade golangci-lint to v2 (#22484)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
parent
4a987ddbf2
commit
0ec46f6857
150 changed files with 817 additions and 815 deletions
2
.github/workflows/ci-build.yaml
vendored
2
.github/workflows/ci-build.yaml
vendored
|
|
@ -112,7 +112,7 @@ jobs:
|
|||
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
|
||||
with:
|
||||
# renovate: datasource=go packageName=github.com/golangci/golangci-lint versioning=regex:^v(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)?$
|
||||
version: v1.64.8
|
||||
version: v2.0.1
|
||||
args: --verbose
|
||||
|
||||
test-go:
|
||||
|
|
|
|||
286
.golangci.yaml
286
.golangci.yaml
|
|
@ -1,156 +1,166 @@
|
|||
version: "2"
|
||||
issues:
|
||||
exclude:
|
||||
- SA5011
|
||||
max-issues-per-linter: 0
|
||||
max-same-issues: 0
|
||||
exclude-rules:
|
||||
- path: '(.+)_test\.go'
|
||||
linters:
|
||||
- unparam
|
||||
linters:
|
||||
exclusions:
|
||||
rules:
|
||||
- linters:
|
||||
- unparam
|
||||
path: (.+)_test\.go
|
||||
- path: (.+)\.go$
|
||||
text: SA5011
|
||||
paths:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
presets:
|
||||
- comments
|
||||
- common-false-positives
|
||||
- legacy
|
||||
- std-error-handling
|
||||
enable:
|
||||
- errcheck
|
||||
- errorlint
|
||||
- gocritic
|
||||
- gofumpt
|
||||
- goimports
|
||||
- gomodguard
|
||||
- gosimple
|
||||
- govet
|
||||
- importas
|
||||
- ineffassign
|
||||
- misspell
|
||||
# Disabled because of https://github.com/argoproj/argo-cd/issues/21705
|
||||
# - nolintlint
|
||||
- perfsprint
|
||||
- revive
|
||||
- staticcheck
|
||||
- testifylint
|
||||
- thelper
|
||||
- unparam
|
||||
- unused
|
||||
- usestdlibvars
|
||||
- usetesting
|
||||
- whitespace
|
||||
linters-settings:
|
||||
gocritic:
|
||||
disabled-checks:
|
||||
- appendAssign
|
||||
- assignOp # Keep it disabled for readability
|
||||
- exitAfterDefer
|
||||
- mapKey
|
||||
- typeSwitchVar
|
||||
goimports:
|
||||
local-prefixes: github.com/argoproj/argo-cd/v3
|
||||
gomodguard:
|
||||
blocked:
|
||||
modules:
|
||||
- github.com/golang-jwt/jwt/v4:
|
||||
recommendations:
|
||||
- github.com/golang-jwt/jwt/v5
|
||||
- github.com/imdario/mergo:
|
||||
recommendations:
|
||||
- dario.cat/mergo
|
||||
reason: '`github.com/imdario/mergo` has been renamed.'
|
||||
- github.com/pkg/errors:
|
||||
recommendations:
|
||||
- errors
|
||||
importas:
|
||||
alias:
|
||||
- alias: jwtgo
|
||||
pkg: github.com/golang-jwt/jwt/v5
|
||||
- alias: appsv1
|
||||
pkg: k8s.io/api/apps/v1
|
||||
- alias: corev1
|
||||
pkg: k8s.io/api/core/v1
|
||||
- alias: rbacv1
|
||||
pkg: k8s.io/api/rbac/v1
|
||||
- alias: apierrors
|
||||
pkg: k8s.io/apimachinery/pkg/api/errors
|
||||
- alias: apiextensionsv1
|
||||
pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
|
||||
- alias: metav1
|
||||
pkg: k8s.io/apimachinery/pkg/apis/meta/v1
|
||||
- alias: informersv1
|
||||
pkg: k8s.io/client-go/informers/core/v1
|
||||
- alias: stderrors
|
||||
pkg: errors
|
||||
nolintlint:
|
||||
require-specific: true
|
||||
perfsprint:
|
||||
# Optimizes even if it requires an int or uint type cast.
|
||||
int-conversion: true
|
||||
# Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.
|
||||
err-error: true
|
||||
# Optimizes `fmt.Errorf`.
|
||||
errorf: true
|
||||
# Optimizes `fmt.Sprintf` with only one argument.
|
||||
sprintf1: true
|
||||
# Optimizes into strings concatenation.
|
||||
strconcat: true
|
||||
revive:
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
|
||||
rules:
|
||||
- name: bool-literal-in-expr
|
||||
- name: blank-imports
|
||||
disabled: true
|
||||
- name: context-as-argument
|
||||
arguments:
|
||||
- allowTypesBefore: '*testing.T,testing.TB'
|
||||
- name: context-keys-type
|
||||
disabled: true
|
||||
- name: dot-imports
|
||||
disabled: true
|
||||
- name: duplicated-imports
|
||||
- name: early-return
|
||||
arguments:
|
||||
- 'preserveScope'
|
||||
- name: empty-block
|
||||
disabled: true
|
||||
- name: error-naming
|
||||
disabled: true
|
||||
- name: error-return
|
||||
- name: error-strings
|
||||
disabled: true
|
||||
- name: errorf
|
||||
- name: identical-branches
|
||||
- name: if-return
|
||||
- name: increment-decrement
|
||||
- name: indent-error-flow
|
||||
arguments:
|
||||
- 'preserveScope'
|
||||
- name: modifies-parameter
|
||||
- name: optimize-operands-order
|
||||
- name: range
|
||||
- name: receiver-naming
|
||||
- name: redefines-builtin-id
|
||||
disabled: true
|
||||
- name: redundant-import-alias
|
||||
- name: superfluous-else
|
||||
arguments:
|
||||
- 'preserveScope'
|
||||
- name: time-equal
|
||||
- name: time-naming
|
||||
disabled: true
|
||||
- name: unexported-return
|
||||
disabled: true
|
||||
- name: unnecessary-stmt
|
||||
- name: unreachable-code
|
||||
- name: unused-parameter
|
||||
- name: use-any
|
||||
- name: useless-break
|
||||
- name: var-declaration
|
||||
- name: var-naming
|
||||
arguments:
|
||||
- ["ID"]
|
||||
- ["VM"]
|
||||
- - skipPackageNameChecks: true
|
||||
upperCaseConst: true
|
||||
testifylint:
|
||||
enable-all: true
|
||||
disable:
|
||||
- go-require
|
||||
usetesting:
|
||||
os-mkdir-temp: false
|
||||
run:
|
||||
timeout: 50m
|
||||
settings:
|
||||
gocritic:
|
||||
disabled-checks:
|
||||
- appendAssign
|
||||
- assignOp
|
||||
- exitAfterDefer
|
||||
- mapKey
|
||||
- typeSwitchVar
|
||||
gomodguard:
|
||||
blocked:
|
||||
modules:
|
||||
- github.com/golang-jwt/jwt/v4:
|
||||
recommendations:
|
||||
- github.com/golang-jwt/jwt/v5
|
||||
- github.com/imdario/mergo:
|
||||
recommendations:
|
||||
- dario.cat/mergo
|
||||
reason: '`github.com/imdario/mergo` has been renamed.'
|
||||
- github.com/pkg/errors:
|
||||
recommendations:
|
||||
- errors
|
||||
importas:
|
||||
alias:
|
||||
- pkg: github.com/golang-jwt/jwt/v5
|
||||
alias: jwtgo
|
||||
- pkg: k8s.io/api/apps/v1
|
||||
alias: appsv1
|
||||
- pkg: k8s.io/api/core/v1
|
||||
alias: corev1
|
||||
- pkg: k8s.io/api/rbac/v1
|
||||
alias: rbacv1
|
||||
- pkg: k8s.io/apimachinery/pkg/api/errors
|
||||
alias: apierrors
|
||||
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
|
||||
alias: apiextensionsv1
|
||||
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
|
||||
alias: metav1
|
||||
- pkg: k8s.io/client-go/informers/core/v1
|
||||
alias: informersv1
|
||||
- pkg: errors
|
||||
alias: stderrors
|
||||
nolintlint:
|
||||
require-specific: true
|
||||
perfsprint:
|
||||
# Optimizes even if it requires an int or uint type cast.
|
||||
int-conversion: true
|
||||
# Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.
|
||||
err-error: true
|
||||
# Optimizes `fmt.Errorf`.
|
||||
errorf: true
|
||||
# Optimizes `fmt.Sprintf` with only one argument.
|
||||
sprintf1: true
|
||||
# Optimizes into strings concatenation.
|
||||
strconcat: true
|
||||
revive:
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
|
||||
rules:
|
||||
- name: bool-literal-in-expr
|
||||
- name: blank-imports
|
||||
disabled: true
|
||||
- name: context-as-argument
|
||||
arguments:
|
||||
- allowTypesBefore: '*testing.T,testing.TB'
|
||||
- name: context-keys-type
|
||||
disabled: true
|
||||
- name: dot-imports
|
||||
disabled: true
|
||||
- name: duplicated-imports
|
||||
- name: early-return
|
||||
arguments:
|
||||
- preserveScope
|
||||
- name: empty-block
|
||||
disabled: true
|
||||
- name: error-naming
|
||||
disabled: true
|
||||
- name: error-return
|
||||
- name: error-strings
|
||||
disabled: true
|
||||
- name: errorf
|
||||
- name: identical-branches
|
||||
- name: if-return
|
||||
- name: increment-decrement
|
||||
- name: indent-error-flow
|
||||
arguments:
|
||||
- preserveScope
|
||||
- name: modifies-parameter
|
||||
- name: optimize-operands-order
|
||||
- name: range
|
||||
- name: receiver-naming
|
||||
- name: redefines-builtin-id
|
||||
disabled: true
|
||||
- name: redundant-import-alias
|
||||
- name: superfluous-else
|
||||
arguments:
|
||||
- preserveScope
|
||||
- name: time-equal
|
||||
- name: time-naming
|
||||
disabled: true
|
||||
- name: unexported-return
|
||||
disabled: true
|
||||
- name: unnecessary-stmt
|
||||
- name: unreachable-code
|
||||
- name: unused-parameter
|
||||
- name: use-any
|
||||
- name: useless-break
|
||||
- name: var-declaration
|
||||
- name: var-naming
|
||||
arguments:
|
||||
- - ID
|
||||
- - VM
|
||||
- - skipPackageNameChecks: true
|
||||
upperCaseConst: true
|
||||
testifylint:
|
||||
enable-all: true
|
||||
disable:
|
||||
- go-require
|
||||
usetesting:
|
||||
os-mkdir-temp: false
|
||||
formatters:
|
||||
enable:
|
||||
- gofumpt
|
||||
- goimports
|
||||
settings:
|
||||
goimports:
|
||||
local-prefixes:
|
||||
- github.com/argoproj/argo-cd/v3
|
||||
exclusions:
|
||||
paths:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
|
|
|
|||
|
|
@ -127,8 +127,8 @@ func (r *ApplicationSetReconciler) Reconcile(ctx context.Context, req ctrl.Reque
|
|||
}()
|
||||
|
||||
// Do not attempt to further reconcile the ApplicationSet if it is being deleted.
|
||||
if applicationSetInfo.ObjectMeta.DeletionTimestamp != nil {
|
||||
appsetName := applicationSetInfo.ObjectMeta.Name
|
||||
if applicationSetInfo.DeletionTimestamp != nil {
|
||||
appsetName := applicationSetInfo.Name
|
||||
logCtx.Debugf("DeletionTimestamp is set on %s", appsetName)
|
||||
deleteAllowed := utils.DefaultPolicy(applicationSetInfo.Spec.SyncPolicy, r.Policy, r.EnablePolicyOverride).AllowDelete()
|
||||
if !deleteAllowed {
|
||||
|
|
@ -314,7 +314,7 @@ func (r *ApplicationSetReconciler) Reconcile(ctx context.Context, req ctrl.Reque
|
|||
|
||||
if applicationSetInfo.RefreshRequired() {
|
||||
delete(applicationSetInfo.Annotations, common.AnnotationApplicationSetRefresh)
|
||||
err := r.Client.Update(ctx, &applicationSetInfo)
|
||||
err := r.Update(ctx, &applicationSetInfo)
|
||||
if err != nil {
|
||||
logCtx.Warnf("error occurred while updating ApplicationSet: %v", err)
|
||||
_ = r.setApplicationSetStatusCondition(ctx,
|
||||
|
|
@ -488,7 +488,7 @@ func (r *ApplicationSetReconciler) validateGeneratedApplications(ctx context.Con
|
|||
namesSet[app.Name] = true
|
||||
|
||||
appProject := &argov1alpha1.AppProject{}
|
||||
err := r.Client.Get(ctx, types.NamespacedName{Name: app.Spec.Project, Namespace: r.ArgoCDNamespace}, appProject)
|
||||
err := r.Get(ctx, types.NamespacedName{Name: app.Spec.Project, Namespace: r.ArgoCDNamespace}, appProject)
|
||||
if err != nil {
|
||||
if apierrors.IsNotFound(err) {
|
||||
errorsByIndex[i] = fmt.Errorf("application references project %s which does not exist", app.Spec.Project)
|
||||
|
|
@ -624,7 +624,7 @@ func (r *ApplicationSetReconciler) createOrUpdateInCluster(ctx context.Context,
|
|||
preservedAnnotations = append(preservedAnnotations, defaultPreservedAnnotations...)
|
||||
|
||||
for _, key := range preservedAnnotations {
|
||||
if state, exists := found.ObjectMeta.Annotations[key]; exists {
|
||||
if state, exists := found.Annotations[key]; exists {
|
||||
if generatedApp.Annotations == nil {
|
||||
generatedApp.Annotations = map[string]string{}
|
||||
}
|
||||
|
|
@ -633,7 +633,7 @@ func (r *ApplicationSetReconciler) createOrUpdateInCluster(ctx context.Context,
|
|||
}
|
||||
|
||||
for _, key := range preservedLabels {
|
||||
if state, exists := found.ObjectMeta.Labels[key]; exists {
|
||||
if state, exists := found.Labels[key]; exists {
|
||||
if generatedApp.Labels == nil {
|
||||
generatedApp.Labels = map[string]string{}
|
||||
}
|
||||
|
|
@ -643,7 +643,7 @@ func (r *ApplicationSetReconciler) createOrUpdateInCluster(ctx context.Context,
|
|||
|
||||
// Preserve post-delete finalizers:
|
||||
// https://github.com/argoproj/argo-cd/issues/17181
|
||||
for _, finalizer := range found.ObjectMeta.Finalizers {
|
||||
for _, finalizer := range found.Finalizers {
|
||||
if strings.HasPrefix(finalizer, argov1alpha1.PostDeleteFinalizerName) {
|
||||
if generatedApp.Finalizers == nil {
|
||||
generatedApp.Finalizers = []string{}
|
||||
|
|
@ -652,10 +652,10 @@ func (r *ApplicationSetReconciler) createOrUpdateInCluster(ctx context.Context,
|
|||
}
|
||||
}
|
||||
|
||||
found.ObjectMeta.Annotations = generatedApp.Annotations
|
||||
found.Annotations = generatedApp.Annotations
|
||||
|
||||
found.ObjectMeta.Finalizers = generatedApp.Finalizers
|
||||
found.ObjectMeta.Labels = generatedApp.Labels
|
||||
found.Finalizers = generatedApp.Finalizers
|
||||
found.Labels = generatedApp.Labels
|
||||
|
||||
return controllerutil.SetControllerReference(&applicationSet, found, r.Scheme)
|
||||
})
|
||||
|
|
@ -709,7 +709,7 @@ func (r *ApplicationSetReconciler) createInCluster(ctx context.Context, logCtx *
|
|||
|
||||
func (r *ApplicationSetReconciler) getCurrentApplications(ctx context.Context, applicationSet argov1alpha1.ApplicationSet) ([]argov1alpha1.Application, error) {
|
||||
var current argov1alpha1.ApplicationList
|
||||
err := r.Client.List(ctx, ¤t, client.MatchingFields{".metadata.controller": applicationSet.Name}, client.InNamespace(applicationSet.Namespace))
|
||||
err := r.List(ctx, ¤t, client.MatchingFields{".metadata.controller": applicationSet.Name}, client.InNamespace(applicationSet.Namespace))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error retrieving applications: %w", err)
|
||||
}
|
||||
|
|
@ -754,7 +754,7 @@ func (r *ApplicationSetReconciler) deleteInCluster(ctx context.Context, logCtx *
|
|||
continue
|
||||
}
|
||||
|
||||
err = r.Client.Delete(ctx, &app)
|
||||
err = r.Delete(ctx, &app)
|
||||
if err != nil {
|
||||
logCtx.WithError(err).Error("failed to delete Application")
|
||||
if firstError != nil {
|
||||
|
|
@ -823,7 +823,7 @@ func (r *ApplicationSetReconciler) removeFinalizerOnInvalidDestination(ctx conte
|
|||
if log.IsLevelEnabled(log.DebugLevel) {
|
||||
utils.LogPatch(appLog, patch, updated)
|
||||
}
|
||||
if err := r.Client.Patch(ctx, updated, patch); err != nil {
|
||||
if err := r.Patch(ctx, updated, patch); err != nil {
|
||||
return fmt.Errorf("error updating finalizers: %w", err)
|
||||
}
|
||||
// Application must have updated list of finalizers
|
||||
|
|
@ -845,7 +845,7 @@ func (r *ApplicationSetReconciler) removeOwnerReferencesOnDeleteAppSet(ctx conte
|
|||
|
||||
for _, app := range applications {
|
||||
app.SetOwnerReferences([]metav1.OwnerReference{})
|
||||
err := r.Client.Update(ctx, &app)
|
||||
err := r.Update(ctx, &app)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error updating application: %w", err)
|
||||
}
|
||||
|
|
@ -1521,9 +1521,9 @@ func shouldRequeueForApplication(appOld *argov1alpha1.Application, appNew *argov
|
|||
// https://pkg.go.dev/reflect#DeepEqual
|
||||
// ApplicationDestination has an unexported field so we can just use the == for comparison
|
||||
if !cmp.Equal(appOld.Spec, appNew.Spec, cmpopts.EquateEmpty(), cmpopts.EquateComparable(argov1alpha1.ApplicationDestination{})) ||
|
||||
!cmp.Equal(appOld.ObjectMeta.GetAnnotations(), appNew.ObjectMeta.GetAnnotations(), cmpopts.EquateEmpty()) ||
|
||||
!cmp.Equal(appOld.ObjectMeta.GetLabels(), appNew.ObjectMeta.GetLabels(), cmpopts.EquateEmpty()) ||
|
||||
!cmp.Equal(appOld.ObjectMeta.GetFinalizers(), appNew.ObjectMeta.GetFinalizers(), cmpopts.EquateEmpty()) {
|
||||
!cmp.Equal(appOld.GetAnnotations(), appNew.GetAnnotations(), cmpopts.EquateEmpty()) ||
|
||||
!cmp.Equal(appOld.GetLabels(), appNew.GetLabels(), cmpopts.EquateEmpty()) ||
|
||||
!cmp.Equal(appOld.GetFinalizers(), appNew.GetFinalizers(), cmpopts.EquateEmpty()) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
@ -1601,14 +1601,14 @@ func shouldRequeueForApplicationSet(appSetOld, appSetNew *argov1alpha1.Applicati
|
|||
// NB: the ApplicationDestination comes from the ApplicationSpec being embedded
|
||||
// in the ApplicationSetTemplate from the generators
|
||||
if !cmp.Equal(appSetOld.Spec, appSetNew.Spec, cmpopts.EquateEmpty(), cmpopts.EquateComparable(argov1alpha1.ApplicationDestination{})) ||
|
||||
!cmp.Equal(appSetOld.ObjectMeta.GetLabels(), appSetNew.ObjectMeta.GetLabels(), cmpopts.EquateEmpty()) ||
|
||||
!cmp.Equal(appSetOld.ObjectMeta.GetFinalizers(), appSetNew.ObjectMeta.GetFinalizers(), cmpopts.EquateEmpty()) {
|
||||
!cmp.Equal(appSetOld.GetLabels(), appSetNew.GetLabels(), cmpopts.EquateEmpty()) ||
|
||||
!cmp.Equal(appSetOld.GetFinalizers(), appSetNew.GetFinalizers(), cmpopts.EquateEmpty()) {
|
||||
return true
|
||||
}
|
||||
|
||||
// Requeue only when the refresh annotation is newly added to the ApplicationSet.
|
||||
// Changes to other annotations made simultaneously might be missed, but such cases are rare.
|
||||
if !cmp.Equal(appSetOld.ObjectMeta.GetAnnotations(), appSetNew.ObjectMeta.GetAnnotations(), cmpopts.EquateEmpty()) {
|
||||
if !cmp.Equal(appSetOld.GetAnnotations(), appSetNew.GetAnnotations(), cmpopts.EquateEmpty()) {
|
||||
_, oldHasRefreshAnnotation := appSetOld.Annotations[common.AnnotationApplicationSetRefresh]
|
||||
_, newHasRefreshAnnotation := appSetNew.Annotations[common.AnnotationApplicationSetRefresh]
|
||||
|
||||
|
|
|
|||
|
|
@ -2184,12 +2184,12 @@ func TestReconcilerValidationProjectErrorBehaviour(t *testing.T) {
|
|||
var app v1alpha1.Application
|
||||
|
||||
// make sure good app got created
|
||||
err = r.Client.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "good-project"}, &app)
|
||||
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "good-project"}, &app)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "good-project", app.Name)
|
||||
|
||||
// make sure bad app was not created
|
||||
err = r.Client.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "bad-project"}, &app)
|
||||
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "bad-project"}, &app)
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
|
|
@ -2472,13 +2472,13 @@ func applicationsUpdateSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
|
|||
var app v1alpha1.Application
|
||||
|
||||
// make sure good app got created
|
||||
err = r.Client.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "good-cluster"}, &app)
|
||||
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "good-cluster"}, &app)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "good-cluster", app.Name)
|
||||
|
||||
// Update resource
|
||||
var retrievedApplicationSet v1alpha1.ApplicationSet
|
||||
err = r.Client.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "name"}, &retrievedApplicationSet)
|
||||
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "name"}, &retrievedApplicationSet)
|
||||
require.NoError(t, err)
|
||||
|
||||
retrievedApplicationSet.Spec.Template.Annotations = map[string]string{"annotation-key": "annotation-value"}
|
||||
|
|
@ -2488,13 +2488,13 @@ func applicationsUpdateSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
|
|||
Values: "global.test: test",
|
||||
}
|
||||
|
||||
err = r.Client.Update(t.Context(), &retrievedApplicationSet)
|
||||
err = r.Update(t.Context(), &retrievedApplicationSet)
|
||||
require.NoError(t, err)
|
||||
|
||||
resUpdate, err := r.Reconcile(t.Context(), req)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = r.Client.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "good-cluster"}, &app)
|
||||
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "good-cluster"}, &app)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, time.Duration(0), resUpdate.RequeueAfter)
|
||||
assert.Equal(t, "good-cluster", app.Name)
|
||||
|
|
@ -2508,7 +2508,7 @@ func TestUpdateNotPerformedWithSyncPolicyCreateOnly(t *testing.T) {
|
|||
app := applicationsUpdateSyncPolicyTest(t, applicationsSyncPolicy, 1, true)
|
||||
|
||||
assert.Nil(t, app.Spec.Source.Helm)
|
||||
assert.Nil(t, app.ObjectMeta.Annotations)
|
||||
assert.Nil(t, app.Annotations)
|
||||
}
|
||||
|
||||
func TestUpdateNotPerformedWithSyncPolicyCreateDelete(t *testing.T) {
|
||||
|
|
@ -2517,7 +2517,7 @@ func TestUpdateNotPerformedWithSyncPolicyCreateDelete(t *testing.T) {
|
|||
app := applicationsUpdateSyncPolicyTest(t, applicationsSyncPolicy, 1, true)
|
||||
|
||||
assert.Nil(t, app.Spec.Source.Helm)
|
||||
assert.Nil(t, app.ObjectMeta.Annotations)
|
||||
assert.Nil(t, app.Annotations)
|
||||
}
|
||||
|
||||
func TestUpdatePerformedWithSyncPolicyCreateUpdate(t *testing.T) {
|
||||
|
|
@ -2526,8 +2526,8 @@ func TestUpdatePerformedWithSyncPolicyCreateUpdate(t *testing.T) {
|
|||
app := applicationsUpdateSyncPolicyTest(t, applicationsSyncPolicy, 2, true)
|
||||
|
||||
assert.Equal(t, "global.test: test", app.Spec.Source.Helm.Values)
|
||||
assert.Equal(t, map[string]string{"annotation-key": "annotation-value"}, app.ObjectMeta.Annotations)
|
||||
assert.Equal(t, map[string]string{"label-key": "label-value"}, app.ObjectMeta.Labels)
|
||||
assert.Equal(t, map[string]string{"annotation-key": "annotation-value"}, app.Annotations)
|
||||
assert.Equal(t, map[string]string{"label-key": "label-value"}, app.Labels)
|
||||
}
|
||||
|
||||
func TestUpdatePerformedWithSyncPolicySync(t *testing.T) {
|
||||
|
|
@ -2536,8 +2536,8 @@ func TestUpdatePerformedWithSyncPolicySync(t *testing.T) {
|
|||
app := applicationsUpdateSyncPolicyTest(t, applicationsSyncPolicy, 2, true)
|
||||
|
||||
assert.Equal(t, "global.test: test", app.Spec.Source.Helm.Values)
|
||||
assert.Equal(t, map[string]string{"annotation-key": "annotation-value"}, app.ObjectMeta.Annotations)
|
||||
assert.Equal(t, map[string]string{"label-key": "label-value"}, app.ObjectMeta.Labels)
|
||||
assert.Equal(t, map[string]string{"annotation-key": "annotation-value"}, app.Annotations)
|
||||
assert.Equal(t, map[string]string{"label-key": "label-value"}, app.Labels)
|
||||
}
|
||||
|
||||
func TestUpdatePerformedWithSyncPolicyCreateOnlyAndAllowPolicyOverrideFalse(t *testing.T) {
|
||||
|
|
@ -2546,8 +2546,8 @@ func TestUpdatePerformedWithSyncPolicyCreateOnlyAndAllowPolicyOverrideFalse(t *t
|
|||
app := applicationsUpdateSyncPolicyTest(t, applicationsSyncPolicy, 2, false)
|
||||
|
||||
assert.Equal(t, "global.test: test", app.Spec.Source.Helm.Values)
|
||||
assert.Equal(t, map[string]string{"annotation-key": "annotation-value"}, app.ObjectMeta.Annotations)
|
||||
assert.Equal(t, map[string]string{"label-key": "label-value"}, app.ObjectMeta.Labels)
|
||||
assert.Equal(t, map[string]string{"annotation-key": "annotation-value"}, app.Annotations)
|
||||
assert.Equal(t, map[string]string{"label-key": "label-value"}, app.Labels)
|
||||
}
|
||||
|
||||
func applicationsDeleteSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alpha1.ApplicationsSyncPolicy, recordBuffer int, allowPolicyOverride bool) v1alpha1.ApplicationList {
|
||||
|
|
@ -2647,13 +2647,13 @@ func applicationsDeleteSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
|
|||
var app v1alpha1.Application
|
||||
|
||||
// make sure good app got created
|
||||
err = r.Client.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "good-cluster"}, &app)
|
||||
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "good-cluster"}, &app)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "good-cluster", app.Name)
|
||||
|
||||
// Update resource
|
||||
var retrievedApplicationSet v1alpha1.ApplicationSet
|
||||
err = r.Client.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "name"}, &retrievedApplicationSet)
|
||||
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "name"}, &retrievedApplicationSet)
|
||||
require.NoError(t, err)
|
||||
retrievedApplicationSet.Spec.Generators = []v1alpha1.ApplicationSetGenerator{
|
||||
{
|
||||
|
|
@ -2663,7 +2663,7 @@ func applicationsDeleteSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
|
|||
},
|
||||
}
|
||||
|
||||
err = r.Client.Update(t.Context(), &retrievedApplicationSet)
|
||||
err = r.Update(t.Context(), &retrievedApplicationSet)
|
||||
require.NoError(t, err)
|
||||
|
||||
resUpdate, err := r.Reconcile(t.Context(), req)
|
||||
|
|
@ -2671,7 +2671,7 @@ func applicationsDeleteSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
|
|||
|
||||
var apps v1alpha1.ApplicationList
|
||||
|
||||
err = r.Client.List(t.Context(), &apps)
|
||||
err = r.List(t.Context(), &apps)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, time.Duration(0), resUpdate.RequeueAfter)
|
||||
|
||||
|
|
@ -2833,20 +2833,20 @@ func TestPolicies(t *testing.T) {
|
|||
assert.Equal(t, time.Duration(0), res.RequeueAfter)
|
||||
|
||||
var app v1alpha1.Application
|
||||
err = r.Client.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "my-app"}, &app)
|
||||
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "my-app"}, &app)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "value", app.Annotations["key"])
|
||||
|
||||
// Check if Application is updated
|
||||
app.Annotations["key"] = "edited"
|
||||
err = r.Client.Update(t.Context(), &app)
|
||||
err = r.Update(t.Context(), &app)
|
||||
require.NoError(t, err)
|
||||
|
||||
res, err = r.Reconcile(t.Context(), req)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, time.Duration(0), res.RequeueAfter)
|
||||
|
||||
err = r.Client.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "my-app"}, &app)
|
||||
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "my-app"}, &app)
|
||||
require.NoError(t, err)
|
||||
|
||||
if c.allowedUpdate {
|
||||
|
|
@ -2856,21 +2856,21 @@ func TestPolicies(t *testing.T) {
|
|||
}
|
||||
|
||||
// Check if Application is deleted
|
||||
err = r.Client.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "name"}, &appSet)
|
||||
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "name"}, &appSet)
|
||||
require.NoError(t, err)
|
||||
appSet.Spec.Generators[0] = v1alpha1.ApplicationSetGenerator{
|
||||
List: &v1alpha1.ListGenerator{
|
||||
Elements: []apiextensionsv1.JSON{},
|
||||
},
|
||||
}
|
||||
err = r.Client.Update(t.Context(), &appSet)
|
||||
err = r.Update(t.Context(), &appSet)
|
||||
require.NoError(t, err)
|
||||
|
||||
res, err = r.Reconcile(t.Context(), req)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, time.Duration(0), res.RequeueAfter)
|
||||
|
||||
err = r.Client.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "my-app"}, &app)
|
||||
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "my-app"}, &app)
|
||||
require.NoError(t, err)
|
||||
if c.allowedDelete {
|
||||
assert.NotNil(t, app.DeletionTimestamp)
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ func TestRequeueAfter(t *testing.T) {
|
|||
}},
|
||||
},
|
||||
},
|
||||
}, ""}, want: generators.DefaultRequeueAfterSeconds, wantErr: assert.NoError},
|
||||
}, ""}, want: generators.DefaultRequeueAfter, wantErr: assert.NoError},
|
||||
{name: "ClusterMatrixNested", args: args{&argov1alpha1.ApplicationSet{
|
||||
Spec: argov1alpha1.ApplicationSetSpec{
|
||||
Generators: []argov1alpha1.ApplicationSetGenerator{
|
||||
|
|
@ -144,7 +144,7 @@ func TestRequeueAfter(t *testing.T) {
|
|||
}},
|
||||
},
|
||||
},
|
||||
}, ""}, want: generators.DefaultRequeueAfterSeconds, wantErr: assert.NoError},
|
||||
}, ""}, want: generators.DefaultRequeueAfter, wantErr: assert.NoError},
|
||||
{name: "ListGenerator", args: args{appset: &argov1alpha1.ApplicationSet{
|
||||
Spec: argov1alpha1.ApplicationSetSpec{
|
||||
Generators: []argov1alpha1.ApplicationSetGenerator{{List: &argov1alpha1.ListGenerator{}}},
|
||||
|
|
@ -154,7 +154,7 @@ func TestRequeueAfter(t *testing.T) {
|
|||
Spec: argov1alpha1.ApplicationSetSpec{
|
||||
Generators: []argov1alpha1.ApplicationSetGenerator{{ClusterDecisionResource: &argov1alpha1.DuckTypeGenerator{}}},
|
||||
},
|
||||
}}, want: generators.DefaultRequeueAfterSeconds, wantErr: assert.NoError},
|
||||
}}, want: generators.DefaultRequeueAfter, wantErr: assert.NoError},
|
||||
{name: "OverrideRequeueDuck", args: args{
|
||||
appset: &argov1alpha1.ApplicationSet{
|
||||
Spec: argov1alpha1.ApplicationSetSpec{
|
||||
|
|
|
|||
|
|
@ -341,10 +341,10 @@ func TestGenerateAppsUsingPullRequestGenerator(t *testing.T) {
|
|||
renderer,
|
||||
nil,
|
||||
)
|
||||
assert.EqualValues(t, cases.expectedApp[0].ObjectMeta.Name, gotApp[0].ObjectMeta.Name)
|
||||
assert.EqualValues(t, cases.expectedApp[0].Spec.Source.TargetRevision, gotApp[0].Spec.Source.TargetRevision)
|
||||
assert.EqualValues(t, cases.expectedApp[0].Spec.Destination.Namespace, gotApp[0].Spec.Destination.Namespace)
|
||||
assert.True(t, maps.Equal(cases.expectedApp[0].ObjectMeta.Labels, gotApp[0].ObjectMeta.Labels))
|
||||
assert.Equal(t, cases.expectedApp[0].Name, gotApp[0].Name)
|
||||
assert.Equal(t, cases.expectedApp[0].Spec.Source.TargetRevision, gotApp[0].Spec.Source.TargetRevision)
|
||||
assert.Equal(t, cases.expectedApp[0].Spec.Destination.Namespace, gotApp[0].Spec.Destination.Namespace)
|
||||
assert.True(t, maps.Equal(cases.expectedApp[0].Labels, gotApp[0].Labels))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,11 +59,11 @@ func (g *ClusterGenerator) GetTemplate(appSetGenerator *argoappsetv1alpha1.Appli
|
|||
func (g *ClusterGenerator) GenerateParams(appSetGenerator *argoappsetv1alpha1.ApplicationSetGenerator, appSet *argoappsetv1alpha1.ApplicationSet, _ client.Client) ([]map[string]any, error) {
|
||||
logCtx := log.WithField("applicationset", appSet.GetName()).WithField("namespace", appSet.GetNamespace())
|
||||
if appSetGenerator == nil {
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
return nil, ErrEmptyAppSetGenerator
|
||||
}
|
||||
|
||||
if appSetGenerator.Clusters == nil {
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
return nil, ErrEmptyAppSetGenerator
|
||||
}
|
||||
|
||||
// Do not include the local cluster in the cluster parameters IF there is a non-empty selector
|
||||
|
|
@ -139,20 +139,20 @@ func (g *ClusterGenerator) GenerateParams(appSetGenerator *argoappsetv1alpha1.Ap
|
|||
if appSet.Spec.GoTemplate {
|
||||
meta := map[string]any{}
|
||||
|
||||
if len(cluster.ObjectMeta.Annotations) > 0 {
|
||||
meta["annotations"] = cluster.ObjectMeta.Annotations
|
||||
if len(cluster.Annotations) > 0 {
|
||||
meta["annotations"] = cluster.Annotations
|
||||
}
|
||||
if len(cluster.ObjectMeta.Labels) > 0 {
|
||||
meta["labels"] = cluster.ObjectMeta.Labels
|
||||
if len(cluster.Labels) > 0 {
|
||||
meta["labels"] = cluster.Labels
|
||||
}
|
||||
|
||||
params["metadata"] = meta
|
||||
} else {
|
||||
for key, value := range cluster.ObjectMeta.Annotations {
|
||||
for key, value := range cluster.Annotations {
|
||||
params["metadata.annotations."+key] = value
|
||||
}
|
||||
|
||||
for key, value := range cluster.ObjectMeta.Labels {
|
||||
for key, value := range cluster.Labels {
|
||||
params["metadata.labels."+key] = value
|
||||
}
|
||||
}
|
||||
|
|
@ -188,7 +188,7 @@ func (g *ClusterGenerator) getSecretsByClusterName(log *log.Entry, appSetGenerat
|
|||
return nil, fmt.Errorf("error converting label selector: %w", err)
|
||||
}
|
||||
|
||||
if err := g.Client.List(context.Background(), clusterSecretList, client.MatchingLabelsSelector{Selector: secretSelector}); err != nil {
|
||||
if err := g.List(context.Background(), clusterSecretList, client.MatchingLabelsSelector{Selector: secretSelector}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Debugf("clusters matching labels: %d", len(clusterSecretList.Items))
|
||||
|
|
|
|||
|
|
@ -62,12 +62,12 @@ func (g *DuckTypeGenerator) GetTemplate(appSetGenerator *argoprojiov1alpha1.Appl
|
|||
|
||||
func (g *DuckTypeGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator, appSet *argoprojiov1alpha1.ApplicationSet, _ client.Client) ([]map[string]any, error) {
|
||||
if appSetGenerator == nil {
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
return nil, ErrEmptyAppSetGenerator
|
||||
}
|
||||
|
||||
// Not likely to happen
|
||||
if appSetGenerator.ClusterDecisionResource == nil {
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
return nil, ErrEmptyAppSetGenerator
|
||||
}
|
||||
|
||||
// ListCluster from Argo CD's util/db package will include the local cluster in the list of clusters
|
||||
|
|
@ -97,13 +97,13 @@ func (g *DuckTypeGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.A
|
|||
// Validate the fields
|
||||
if kind == "" || versionIdx < 1 {
|
||||
log.Warningf("kind=%v, resourceName=%v, versionIdx=%v", kind, resourceName, versionIdx)
|
||||
return nil, errors.New("There is a problem with the apiVersion, kind or resourceName provided")
|
||||
return nil, errors.New("there is a problem with the apiVersion, kind or resourceName provided")
|
||||
}
|
||||
|
||||
if (resourceName == "" && labelSelector.MatchLabels == nil && labelSelector.MatchExpressions == nil) ||
|
||||
(resourceName != "" && (labelSelector.MatchExpressions != nil || labelSelector.MatchLabels != nil)) {
|
||||
log.Warningf("You must choose either resourceName=%v, labelSelector.matchLabels=%v or labelSelect.matchExpressions=%v", resourceName, labelSelector.MatchLabels, labelSelector.MatchExpressions)
|
||||
return nil, errors.New("There is a problem with the definition of the ClusterDecisionResource generator")
|
||||
return nil, errors.New("there is a problem with the definition of the ClusterDecisionResource generator")
|
||||
}
|
||||
|
||||
// Split up the apiVersion
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ func TestGenerateParamsForDuckType(t *testing.T) {
|
|||
resource: duckType,
|
||||
values: nil,
|
||||
expected: []map[string]any{},
|
||||
expectedError: errors.New("There is a problem with the definition of the ClusterDecisionResource generator"),
|
||||
expectedError: errors.New("there is a problem with the definition of the ClusterDecisionResource generator"),
|
||||
},
|
||||
/*** This does not work with the FAKE runtime client, fieldSelectors are broken.
|
||||
{
|
||||
|
|
@ -270,7 +270,7 @@ func TestGenerateParamsForDuckType(t *testing.T) {
|
|||
resource: duckType,
|
||||
values: nil,
|
||||
expected: nil,
|
||||
expectedError: errors.New("There is a problem with the definition of the ClusterDecisionResource generator"),
|
||||
expectedError: errors.New("there is a problem with the definition of the ClusterDecisionResource generator"),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -455,7 +455,7 @@ func TestGenerateParamsForDuckTypeGoTemplate(t *testing.T) {
|
|||
resource: duckType,
|
||||
values: nil,
|
||||
expected: []map[string]any{},
|
||||
expectedError: errors.New("There is a problem with the definition of the ClusterDecisionResource generator"),
|
||||
expectedError: errors.New("there is a problem with the definition of the ClusterDecisionResource generator"),
|
||||
},
|
||||
/*** This does not work with the FAKE runtime client, fieldSelectors are broken.
|
||||
{
|
||||
|
|
@ -566,7 +566,7 @@ func TestGenerateParamsForDuckTypeGoTemplate(t *testing.T) {
|
|||
resource: duckType,
|
||||
values: nil,
|
||||
expected: nil,
|
||||
expectedError: errors.New("There is a problem with the definition of the ClusterDecisionResource generator"),
|
||||
expectedError: errors.New("there is a problem with the definition of the ClusterDecisionResource generator"),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,11 +53,11 @@ func (g *GitGenerator) GetRequeueAfter(appSetGenerator *argoprojiov1alpha1.Appli
|
|||
|
||||
func (g *GitGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator, appSet *argoprojiov1alpha1.ApplicationSet, client client.Client) ([]map[string]any, error) {
|
||||
if appSetGenerator == nil {
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
return nil, ErrEmptyAppSetGenerator
|
||||
}
|
||||
|
||||
if appSetGenerator.Git == nil {
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
return nil, ErrEmptyAppSetGenerator
|
||||
}
|
||||
|
||||
noRevisionCache := appSet.RefreshRequired()
|
||||
|
|
@ -93,7 +93,7 @@ func (g *GitGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.Applic
|
|||
case len(appSetGenerator.Git.Files) != 0:
|
||||
res, err = g.generateParamsForGitFiles(appSetGenerator, noRevisionCache, verifyCommit, appSet.Spec.GoTemplate, project, appSet.Spec.GoTemplateOptions)
|
||||
default:
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
return nil, ErrEmptyAppSetGenerator
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error generating params from git: %w", err)
|
||||
|
|
|
|||
|
|
@ -27,15 +27,15 @@ type Generator interface {
|
|||
}
|
||||
|
||||
var (
|
||||
EmptyAppSetGeneratorError = errors.New("ApplicationSet is empty")
|
||||
NoRequeueAfter time.Duration
|
||||
ErrEmptyAppSetGenerator = errors.New("ApplicationSet is empty")
|
||||
NoRequeueAfter time.Duration
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultRequeueAfterSeconds = 3 * time.Minute
|
||||
DefaultRequeueAfter = 3 * time.Minute
|
||||
)
|
||||
|
||||
func getDefaultRequeueAfter() time.Duration {
|
||||
// Default is 3 minutes, min is 1 second, max is 1 year
|
||||
return env.ParseDurationFromEnv("ARGOCD_APPLICATIONSET_CONTROLLER_REQUEUE_AFTER", DefaultRequeueAfterSeconds, 1*time.Second, 8760*time.Hour)
|
||||
return env.ParseDurationFromEnv("ARGOCD_APPLICATIONSET_CONTROLLER_REQUEUE_AFTER", DefaultRequeueAfter, 1*time.Second, 8760*time.Hour)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ func Test_getDefaultRequeueAfter(t *testing.T) {
|
|||
requeueAfterEnv string
|
||||
want time.Duration
|
||||
}{
|
||||
{name: "Default", requeueAfterEnv: "", want: DefaultRequeueAfterSeconds},
|
||||
{name: "Default", requeueAfterEnv: "", want: DefaultRequeueAfter},
|
||||
{name: "Min", requeueAfterEnv: "1s", want: 1 * time.Second},
|
||||
{name: "Max", requeueAfterEnv: "8760h", want: 8760 * time.Hour},
|
||||
{name: "Override", requeueAfterEnv: "10m", want: 10 * time.Minute},
|
||||
{name: "LessThanMin", requeueAfterEnv: "1ms", want: DefaultRequeueAfterSeconds},
|
||||
{name: "MoreThanMax", requeueAfterEnv: "8761h", want: DefaultRequeueAfterSeconds},
|
||||
{name: "LessThanMin", requeueAfterEnv: "1ms", want: DefaultRequeueAfter},
|
||||
{name: "MoreThanMax", requeueAfterEnv: "8761h", want: DefaultRequeueAfter},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@ func (g *ListGenerator) GetTemplate(appSetGenerator *argoprojiov1alpha1.Applicat
|
|||
|
||||
func (g *ListGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator, appSet *argoprojiov1alpha1.ApplicationSet, _ client.Client) ([]map[string]any, error) {
|
||||
if appSetGenerator == nil {
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
return nil, ErrEmptyAppSetGenerator
|
||||
}
|
||||
|
||||
if appSetGenerator.List == nil {
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
return nil, ErrEmptyAppSetGenerator
|
||||
}
|
||||
|
||||
res := make([]map[string]any, len(appSetGenerator.List.Elements))
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ func NewMatrixGenerator(supportedGenerators map[string]Generator) Generator {
|
|||
|
||||
func (m *MatrixGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator, appSet *argoprojiov1alpha1.ApplicationSet, client client.Client) ([]map[string]any, error) {
|
||||
if appSetGenerator.Matrix == nil {
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
return nil, ErrEmptyAppSetGenerator
|
||||
}
|
||||
|
||||
if len(appSetGenerator.Matrix.Generators) < 2 {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ func (m *MergeGenerator) getParamSetsForAllGenerators(generators []argoprojiov1a
|
|||
// GenerateParams gets the params produced by the MergeGenerator.
|
||||
func (m *MergeGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator, appSet *argoprojiov1alpha1.ApplicationSet, client client.Client) ([]map[string]any, error) {
|
||||
if appSetGenerator.Merge == nil {
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
return nil, ErrEmptyAppSetGenerator
|
||||
}
|
||||
|
||||
if len(appSetGenerator.Merge.Generators) < 2 {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
DefaultPluginRequeueAfterSeconds = 30 * time.Minute
|
||||
DefaultPluginRequeueAfter = 30 * time.Minute
|
||||
)
|
||||
|
||||
var _ Generator = (*PluginGenerator)(nil)
|
||||
|
|
@ -49,7 +49,7 @@ func (g *PluginGenerator) GetRequeueAfter(appSetGenerator *argoprojiov1alpha1.Ap
|
|||
return time.Duration(*appSetGenerator.Plugin.RequeueAfterSeconds) * time.Second
|
||||
}
|
||||
|
||||
return DefaultPluginRequeueAfterSeconds
|
||||
return DefaultPluginRequeueAfter
|
||||
}
|
||||
|
||||
func (g *PluginGenerator) GetTemplate(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator) *argoprojiov1alpha1.ApplicationSetTemplate {
|
||||
|
|
@ -58,11 +58,11 @@ func (g *PluginGenerator) GetTemplate(appSetGenerator *argoprojiov1alpha1.Applic
|
|||
|
||||
func (g *PluginGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator, applicationSetInfo *argoprojiov1alpha1.ApplicationSet, _ client.Client) ([]map[string]any, error) {
|
||||
if appSetGenerator == nil {
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
return nil, ErrEmptyAppSetGenerator
|
||||
}
|
||||
|
||||
if appSetGenerator.Plugin == nil {
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
return nil, ErrEmptyAppSetGenerator
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import (
|
|||
var _ Generator = (*PullRequestGenerator)(nil)
|
||||
|
||||
const (
|
||||
DefaultPullRequestRequeueAfterSeconds = 30 * time.Minute
|
||||
DefaultPullRequestRequeueAfter = 30 * time.Minute
|
||||
)
|
||||
|
||||
type PullRequestGenerator struct {
|
||||
|
|
@ -44,7 +44,7 @@ func (g *PullRequestGenerator) GetRequeueAfter(appSetGenerator *argoprojiov1alph
|
|||
return time.Duration(*appSetGenerator.PullRequest.RequeueAfterSeconds) * time.Second
|
||||
}
|
||||
|
||||
return DefaultPullRequestRequeueAfterSeconds
|
||||
return DefaultPullRequestRequeueAfter
|
||||
}
|
||||
|
||||
func (g *PullRequestGenerator) GetTemplate(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator) *argoprojiov1alpha1.ApplicationSetTemplate {
|
||||
|
|
@ -53,11 +53,11 @@ func (g *PullRequestGenerator) GetTemplate(appSetGenerator *argoprojiov1alpha1.A
|
|||
|
||||
func (g *PullRequestGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator, applicationSetInfo *argoprojiov1alpha1.ApplicationSet, _ client.Client) ([]map[string]any, error) {
|
||||
if appSetGenerator == nil {
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
return nil, ErrEmptyAppSetGenerator
|
||||
}
|
||||
|
||||
if appSetGenerator.PullRequest == nil {
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
return nil, ErrEmptyAppSetGenerator
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import (
|
|||
var _ Generator = (*SCMProviderGenerator)(nil)
|
||||
|
||||
const (
|
||||
DefaultSCMProviderRequeueAfterSeconds = 30 * time.Minute
|
||||
DefaultSCMProviderRequeueAfter = 30 * time.Minute
|
||||
)
|
||||
|
||||
type SCMProviderGenerator struct {
|
||||
|
|
@ -69,7 +69,7 @@ func (g *SCMProviderGenerator) GetRequeueAfter(appSetGenerator *argoprojiov1alph
|
|||
return time.Duration(*appSetGenerator.SCMProvider.RequeueAfterSeconds) * time.Second
|
||||
}
|
||||
|
||||
return DefaultSCMProviderRequeueAfterSeconds
|
||||
return DefaultSCMProviderRequeueAfter
|
||||
}
|
||||
|
||||
func (g *SCMProviderGenerator) GetTemplate(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator) *argoprojiov1alpha1.ApplicationSetTemplate {
|
||||
|
|
@ -118,11 +118,11 @@ func ScmProviderAllowed(applicationSetInfo *argoprojiov1alpha1.ApplicationSet, g
|
|||
|
||||
func (g *SCMProviderGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator, applicationSetInfo *argoprojiov1alpha1.ApplicationSet, _ client.Client) ([]map[string]any, error) {
|
||||
if appSetGenerator == nil {
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
return nil, ErrEmptyAppSetGenerator
|
||||
}
|
||||
|
||||
if appSetGenerator.SCMProvider == nil {
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
return nil, ErrEmptyAppSetGenerator
|
||||
}
|
||||
|
||||
if !g.enableSCMProviders {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ func TestValueInterpolation(t *testing.T) {
|
|||
t.Run(testCase.name, func(t *testing.T) {
|
||||
err := appendTemplatedValues(testCase.values, testCase.params, false, nil)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, testCase.expected, testCase.params)
|
||||
assert.Equal(t, testCase.expected, testCase.params)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -118,7 +118,7 @@ func TestValueInterpolationWithGoTemplating(t *testing.T) {
|
|||
t.Run(testCase.name, func(t *testing.T) {
|
||||
err := appendTemplatedValues(testCase.values, testCase.params, true, nil)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, testCase.expected, testCase.params)
|
||||
assert.Equal(t, testCase.expected, testCase.params)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,9 +172,10 @@ func getApplicableFilters(filters []*Filter) map[FilterType][]*Filter {
|
|||
FilterTypeRepo: {},
|
||||
}
|
||||
for _, filter := range filters {
|
||||
if filter.FilterType == FilterTypeBranch {
|
||||
switch filter.FilterType {
|
||||
case FilterTypeBranch:
|
||||
filterMap[FilterTypeBranch] = append(filterMap[FilterTypeBranch], filter)
|
||||
} else if filter.FilterType == FilterTypeRepo {
|
||||
case FilterTypeRepo:
|
||||
filterMap[FilterTypeRepo] = append(filterMap[FilterTypeRepo], filter)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import (
|
|||
"k8s.io/apimachinery/pkg/labels"
|
||||
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
. "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
. "github.com/argoproj/argo-cd/v3/pkg/client/listers/application/v1alpha1"
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
listers "github.com/argoproj/argo-cd/v3/pkg/client/listers/application/v1alpha1"
|
||||
)
|
||||
|
||||
// Implements AppsetLister interface with controller-runtime client
|
||||
|
|
@ -15,16 +15,16 @@ type AppsetLister struct {
|
|||
Client ctrlclient.Client
|
||||
}
|
||||
|
||||
func NewAppsetLister(client ctrlclient.Client) ApplicationSetLister {
|
||||
func NewAppsetLister(client ctrlclient.Client) listers.ApplicationSetLister {
|
||||
return &AppsetLister{Client: client}
|
||||
}
|
||||
|
||||
func (l *AppsetLister) List(_ labels.Selector) (ret []*ApplicationSet, err error) {
|
||||
func (l *AppsetLister) List(_ labels.Selector) (ret []*v1alpha1.ApplicationSet, err error) {
|
||||
return clientListAppsets(l.Client, ctrlclient.ListOptions{})
|
||||
}
|
||||
|
||||
// ApplicationSets returns an object that can list and get ApplicationSets.
|
||||
func (l *AppsetLister) ApplicationSets(namespace string) ApplicationSetNamespaceLister {
|
||||
func (l *AppsetLister) ApplicationSets(namespace string) listers.ApplicationSetNamespaceLister {
|
||||
return &appsetNamespaceLister{
|
||||
Client: l.Client,
|
||||
Namespace: namespace,
|
||||
|
|
@ -37,19 +37,19 @@ type appsetNamespaceLister struct {
|
|||
Namespace string
|
||||
}
|
||||
|
||||
func (n *appsetNamespaceLister) List(_ labels.Selector) (ret []*ApplicationSet, err error) {
|
||||
func (n *appsetNamespaceLister) List(_ labels.Selector) (ret []*v1alpha1.ApplicationSet, err error) {
|
||||
return clientListAppsets(n.Client, ctrlclient.ListOptions{Namespace: n.Namespace})
|
||||
}
|
||||
|
||||
func (n *appsetNamespaceLister) Get(_ string) (*ApplicationSet, error) {
|
||||
appset := ApplicationSet{}
|
||||
func (n *appsetNamespaceLister) Get(_ string) (*v1alpha1.ApplicationSet, error) {
|
||||
appset := v1alpha1.ApplicationSet{}
|
||||
err := n.Client.Get(context.TODO(), ctrlclient.ObjectKeyFromObject(&appset), &appset)
|
||||
return &appset, err
|
||||
}
|
||||
|
||||
func clientListAppsets(client ctrlclient.Client, listOptions ctrlclient.ListOptions) (ret []*ApplicationSet, err error) {
|
||||
var appsetlist ApplicationSetList
|
||||
var results []*ApplicationSet
|
||||
func clientListAppsets(client ctrlclient.Client, listOptions ctrlclient.ListOptions) (ret []*v1alpha1.ApplicationSet, err error) {
|
||||
var appsetlist v1alpha1.ApplicationSetList
|
||||
var results []*v1alpha1.ApplicationSet
|
||||
|
||||
err = client.List(context.TODO(), &appsetlist, &listOptions)
|
||||
|
||||
|
|
|
|||
|
|
@ -79,10 +79,10 @@ func CreateOrUpdate(ctx context.Context, logCtx *log.Entry, c client.Client, ign
|
|||
return a.Cmp(b) == 0
|
||||
},
|
||||
func(a, b metav1.MicroTime) bool {
|
||||
return a.UTC() == b.UTC()
|
||||
return a.UTC().Equal(b.UTC())
|
||||
},
|
||||
func(a, b metav1.Time) bool {
|
||||
return a.UTC() == b.UTC()
|
||||
return a.UTC().Equal(b.UTC())
|
||||
},
|
||||
func(a, b labels.Selector) bool {
|
||||
return a.String() == b.String()
|
||||
|
|
|
|||
|
|
@ -274,8 +274,8 @@ func (r *Render) RenderTemplateParams(tmpl *argoappsv1.Application, syncPolicy *
|
|||
// b) there IS a syncPolicy, but preserveResourcesOnDeletion is set to false
|
||||
// See TestRenderTemplateParamsFinalizers in util_test.go for test-based definition of behaviour
|
||||
if (syncPolicy == nil || !syncPolicy.PreserveResourcesOnDeletion) &&
|
||||
len(replacedTmpl.ObjectMeta.Finalizers) == 0 {
|
||||
replacedTmpl.ObjectMeta.Finalizers = []string{"resources-finalizer.argocd.argoproj.io"}
|
||||
len(replacedTmpl.Finalizers) == 0 {
|
||||
replacedTmpl.Finalizers = []string{"resources-finalizer.argocd.argoproj.io"}
|
||||
}
|
||||
|
||||
return replacedTmpl, nil
|
||||
|
|
@ -336,7 +336,7 @@ func (r *Render) Replace(tmpl string, replaceMap map[string]any, useGoTemplate b
|
|||
trimmedTag := strings.TrimSpace(tag)
|
||||
replacement, ok := replaceMap[trimmedTag].(string)
|
||||
if len(trimmedTag) == 0 || !ok {
|
||||
return w.Write([]byte(fmt.Sprintf("{{%s}}", tag)))
|
||||
return fmt.Fprintf(w, "{{%s}}", tag)
|
||||
}
|
||||
return w.Write([]byte(replacement))
|
||||
})
|
||||
|
|
@ -353,12 +353,12 @@ func CheckInvalidGenerators(applicationSetInfo *argoappsv1.ApplicationSet) error
|
|||
gnames = append(gnames, n)
|
||||
}
|
||||
sort.Strings(gnames)
|
||||
aname := applicationSetInfo.ObjectMeta.Name
|
||||
aname := applicationSetInfo.Name
|
||||
msg := "ApplicationSet %s contains unrecognized generators: %s"
|
||||
errorMessage = fmt.Errorf(msg, aname, strings.Join(gnames, ", "))
|
||||
log.Warnf(msg, aname, strings.Join(gnames, ", "))
|
||||
} else if hasInvalidGenerators {
|
||||
name := applicationSetInfo.ObjectMeta.Name
|
||||
name := applicationSetInfo.Name
|
||||
msg := "ApplicationSet %s contains unrecognized generators"
|
||||
errorMessage = fmt.Errorf(msg, name)
|
||||
log.Warnf(msg, name)
|
||||
|
|
@ -394,7 +394,7 @@ func invalidGenerators(applicationSetInfo *argoappsv1.ApplicationSet) (bool, map
|
|||
|
||||
func addInvalidGeneratorNames(names map[string]bool, applicationSetInfo *argoappsv1.ApplicationSet, index int) {
|
||||
// The generator names are stored in the "kubectl.kubernetes.io/last-applied-configuration" annotation
|
||||
config := applicationSetInfo.ObjectMeta.Annotations["kubectl.kubernetes.io/last-applied-configuration"]
|
||||
config := applicationSetInfo.Annotations["kubectl.kubernetes.io/last-applied-configuration"]
|
||||
var values map[string]any
|
||||
err := json.Unmarshal([]byte(config), &values)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -180,14 +180,14 @@ func TestRenderTemplateParams(t *testing.T) {
|
|||
// the target field has been templated into the expected value
|
||||
actualValue := *getPtrFunc(newApplication)
|
||||
assert.Equal(t, test.expectedVal, actualValue, "Field '%s' had an unexpected value. expected: '%s' value: '%s'", fieldName, test.expectedVal, actualValue)
|
||||
assert.Equal(t, "annotation-value", newApplication.ObjectMeta.Annotations["annotation-key"])
|
||||
assert.Equal(t, "annotation-value2", newApplication.ObjectMeta.Annotations["annotation-key2"])
|
||||
assert.Equal(t, "label-value", newApplication.ObjectMeta.Labels["label-key"])
|
||||
assert.Equal(t, "label-value2", newApplication.ObjectMeta.Labels["label-key2"])
|
||||
assert.Equal(t, "application-one", newApplication.ObjectMeta.Name)
|
||||
assert.Equal(t, "default", newApplication.ObjectMeta.Namespace)
|
||||
assert.Equal(t, newApplication.ObjectMeta.UID, types.UID("d546da12-06b7-4f9a-8ea2-3adb16a20e2b"))
|
||||
assert.Equal(t, newApplication.ObjectMeta.CreationTimestamp, application.ObjectMeta.CreationTimestamp)
|
||||
assert.Equal(t, "annotation-value", newApplication.Annotations["annotation-key"])
|
||||
assert.Equal(t, "annotation-value2", newApplication.Annotations["annotation-key2"])
|
||||
assert.Equal(t, "label-value", newApplication.Labels["label-key"])
|
||||
assert.Equal(t, "label-value2", newApplication.Labels["label-key2"])
|
||||
assert.Equal(t, "application-one", newApplication.Name)
|
||||
assert.Equal(t, "default", newApplication.Namespace)
|
||||
assert.Equal(t, newApplication.UID, types.UID("d546da12-06b7-4f9a-8ea2-3adb16a20e2b"))
|
||||
assert.Equal(t, newApplication.CreationTimestamp, application.CreationTimestamp)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
})
|
||||
|
|
@ -627,14 +627,14 @@ func TestRenderTemplateParamsGoTemplate(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
actualValue := *getPtrFunc(newApplication)
|
||||
assert.Equal(t, test.expectedVal, actualValue, "Field '%s' had an unexpected value. expected: '%s' value: '%s'", fieldName, test.expectedVal, actualValue)
|
||||
assert.Equal(t, "annotation-value", newApplication.ObjectMeta.Annotations["annotation-key"])
|
||||
assert.Equal(t, "annotation-value2", newApplication.ObjectMeta.Annotations["annotation-key2"])
|
||||
assert.Equal(t, "label-value", newApplication.ObjectMeta.Labels["label-key"])
|
||||
assert.Equal(t, "label-value2", newApplication.ObjectMeta.Labels["label-key2"])
|
||||
assert.Equal(t, "application-one", newApplication.ObjectMeta.Name)
|
||||
assert.Equal(t, "default", newApplication.ObjectMeta.Namespace)
|
||||
assert.Equal(t, newApplication.ObjectMeta.UID, types.UID("d546da12-06b7-4f9a-8ea2-3adb16a20e2b"))
|
||||
assert.Equal(t, newApplication.ObjectMeta.CreationTimestamp, application.ObjectMeta.CreationTimestamp)
|
||||
assert.Equal(t, "annotation-value", newApplication.Annotations["annotation-key"])
|
||||
assert.Equal(t, "annotation-value2", newApplication.Annotations["annotation-key2"])
|
||||
assert.Equal(t, "label-value", newApplication.Labels["label-key"])
|
||||
assert.Equal(t, "label-value2", newApplication.Labels["label-key2"])
|
||||
assert.Equal(t, "application-one", newApplication.Name)
|
||||
assert.Equal(t, "default", newApplication.Namespace)
|
||||
assert.Equal(t, newApplication.UID, types.UID("d546da12-06b7-4f9a-8ea2-3adb16a20e2b"))
|
||||
assert.Equal(t, newApplication.CreationTimestamp, application.CreationTimestamp)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -687,8 +687,8 @@ func TestRenderTemplateKeys(t *testing.T) {
|
|||
render := Render{}
|
||||
newApplication, err := render.RenderTemplateParams(application, nil, params, false, nil)
|
||||
require.NoError(t, err)
|
||||
require.Contains(t, newApplication.ObjectMeta.Annotations, "annotation-some-key")
|
||||
assert.Equal(t, "annotation-some-value", newApplication.ObjectMeta.Annotations["annotation-some-key"])
|
||||
require.Contains(t, newApplication.Annotations, "annotation-some-key")
|
||||
assert.Equal(t, "annotation-some-value", newApplication.Annotations["annotation-some-key"])
|
||||
})
|
||||
t.Run("gotemplate", func(t *testing.T) {
|
||||
application := &argoappsv1.Application{
|
||||
|
|
@ -707,8 +707,8 @@ func TestRenderTemplateKeys(t *testing.T) {
|
|||
render := Render{}
|
||||
newApplication, err := render.RenderTemplateParams(application, nil, params, true, nil)
|
||||
require.NoError(t, err)
|
||||
require.Contains(t, newApplication.ObjectMeta.Annotations, "annotation-some-key")
|
||||
assert.Equal(t, "annotation-some-value", newApplication.ObjectMeta.Annotations["annotation-some-key"])
|
||||
require.Contains(t, newApplication.Annotations, "annotation-some-key")
|
||||
assert.Equal(t, "annotation-some-value", newApplication.Annotations["annotation-some-key"])
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,19 +72,19 @@ func NewWebhookHandler(namespace string, webhookParallelism int, argocdSettingsM
|
|||
// register the webhook secrets stored under "argocd-secret" for verifying incoming payloads
|
||||
argocdSettings, err := argocdSettingsMgr.GetSettings()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to get argocd settings: %w", err)
|
||||
return nil, fmt.Errorf("failed to get argocd settings: %w", err)
|
||||
}
|
||||
githubHandler, err := github.New(github.Options.Secret(argocdSettings.WebhookGitHubSecret))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to init GitHub webhook: %w", err)
|
||||
return nil, fmt.Errorf("unable to init GitHub webhook: %w", err)
|
||||
}
|
||||
gitlabHandler, err := gitlab.New(gitlab.Options.Secret(argocdSettings.WebhookGitLabSecret))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to init GitLab webhook: %w", err)
|
||||
return nil, fmt.Errorf("unable to init GitLab webhook: %w", err)
|
||||
}
|
||||
azuredevopsHandler, err := azuredevops.New(azuredevops.Options.BasicAuth(argocdSettings.WebhookAzureDevOpsUsername, argocdSettings.WebhookAzureDevOpsPassword))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to init Azure DevOps webhook: %w", err)
|
||||
return nil, fmt.Errorf("unable to init Azure DevOps webhook: %w", err)
|
||||
}
|
||||
|
||||
webhookHandler := &WebhookHandler{
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ func TestGetSignedRequestWithRetry(t *testing.T) {
|
|||
|
||||
// then
|
||||
require.Error(t, err)
|
||||
assert.Equal(t, "", signed)
|
||||
assert.Empty(t, signed)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ func getOutWriter(inline bool, filePath string) (io.Writer, io.Closer, error) {
|
|||
}
|
||||
|
||||
if filePath == "" {
|
||||
return nil, nil, errors.New("The file path must be specified using flag '--file'")
|
||||
return nil, nil, errors.New("the file path must be specified using flag '--file'")
|
||||
}
|
||||
|
||||
err := os.Rename(filePath, filePath+".back")
|
||||
|
|
|
|||
|
|
@ -97,10 +97,10 @@ func getModification(modification string, resource string, scope string, permiss
|
|||
switch modification {
|
||||
case "set":
|
||||
if scope == "" {
|
||||
return nil, stderrors.New("Flag --group cannot be empty if permission should be set in role")
|
||||
return nil, stderrors.New("flag --group cannot be empty if permission should be set in role")
|
||||
}
|
||||
if permission == "" {
|
||||
return nil, stderrors.New("Flag --permission cannot be empty if permission should be set in role")
|
||||
return nil, stderrors.New("flag --permission cannot be empty if permission should be set in role")
|
||||
}
|
||||
return func(proj string, action string) string {
|
||||
return fmt.Sprintf("%s, %s, %s/%s, %s", resource, action, proj, scope, permission)
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ func TestUpdateProjects_FindMatchingProject(t *testing.T) {
|
|||
|
||||
barProj, err := clientset.ArgoprojV1alpha1().AppProjects(namespace).Get(ctx, "bar", metav1.GetOptions{})
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, []string{"p, proj:bar:test, *, set, bar/*, allow"}, barProj.Spec.Roles[0].Policies)
|
||||
assert.Equal(t, []string{"p, proj:bar:test, *, set, bar/*, allow"}, barProj.Spec.Roles[0].Policies)
|
||||
}
|
||||
|
||||
func TestUpdateProjects_FindMatchingRole(t *testing.T) {
|
||||
|
|
@ -59,7 +59,7 @@ func TestUpdateProjects_FindMatchingRole(t *testing.T) {
|
|||
|
||||
proj, err := clientset.ArgoprojV1alpha1().AppProjects(namespace).Get(ctx, "proj", metav1.GetOptions{})
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, []string{"p, proj:proj:foo, *, set, proj/*, allow"}, proj.Spec.Roles[0].Policies)
|
||||
assert.Equal(t, []string{"p, proj:proj:foo, *, set, proj/*, allow"}, proj.Spec.Roles[0].Policies)
|
||||
assert.Empty(t, proj.Spec.Roles[1].Policies)
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ func TestGetModification_RemovePolicy(t *testing.T) {
|
|||
modification, err := getModification("remove", "*", "*", "allow")
|
||||
require.NoError(t, err)
|
||||
policy := modification("proj", "myaction")
|
||||
assert.Equal(t, "", policy)
|
||||
assert.Empty(t, policy)
|
||||
}
|
||||
|
||||
func TestGetModification_NotSupported(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -85,8 +85,7 @@ func NewRedisInitialPasswordCommand() *cobra.Command {
|
|||
if _, ok := secret.Data[redisInitialCredentialsKey]; ok {
|
||||
fmt.Println("Password secret is configured properly.")
|
||||
} else {
|
||||
err := fmt.Errorf("key %s doesn't exist in secret %s. \n", redisInitialCredentialsKey, redisInitialCredentials)
|
||||
errors.CheckError(err)
|
||||
errors.Fatal(errors.ErrorGeneric, fmt.Sprintf("key %s doesn't exist in secret %s. \n", redisInitialCredentialsKey, redisInitialCredentials))
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ func Test_PolicyFromK8s(t *testing.T) {
|
|||
uPol, dRole, matchMode := getPolicy(ctx, "", kubeclientset, "argocd")
|
||||
require.NotEmpty(t, uPol)
|
||||
require.Equal(t, "role:unknown", dRole)
|
||||
require.Equal(t, "", matchMode)
|
||||
require.Empty(t, matchMode)
|
||||
|
||||
t.Run("get applications", func(t *testing.T) {
|
||||
ok := checkPolicy("role:user", "get", "applications", "*/*", assets.BuiltinPolicyCSV, uPol, dRole, "", true)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package admin
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
|
|
@ -68,8 +67,6 @@ func newSettingsManager(data map[string]string) *settings.SettingsManager {
|
|||
|
||||
type fakeCmdContext struct {
|
||||
mgr *settings.SettingsManager
|
||||
//nolint:unused,structcheck
|
||||
out bytes.Buffer
|
||||
}
|
||||
|
||||
func newCmdContext(data map[string]string) *fakeCmdContext {
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ func NewApplicationCreateCommand(clientOpts *argocdclient.ClientOptions) *cobra.
|
|||
action = "updated"
|
||||
}
|
||||
|
||||
fmt.Printf("application '%s' %s\n", created.ObjectMeta.Name, action)
|
||||
fmt.Printf("application '%s' %s\n", created.Name, action)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
@ -267,7 +267,7 @@ func hasAppChanged(appReq, appRes *argoappv1.Application, upsert bool) bool {
|
|||
|
||||
if reflect.DeepEqual(appRes.Spec, appReq.Spec) &&
|
||||
reflect.DeepEqual(appRes.Labels, appReq.Labels) &&
|
||||
reflect.DeepEqual(appRes.ObjectMeta.Annotations, appReq.Annotations) &&
|
||||
reflect.DeepEqual(appRes.Annotations, appReq.Annotations) &&
|
||||
reflect.DeepEqual(appRes.Finalizers, appReq.Finalizers) {
|
||||
return false
|
||||
}
|
||||
|
|
@ -401,7 +401,7 @@ func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
|
|||
errors.CheckError(err)
|
||||
|
||||
if sourceName != "" && sourcePosition != -1 {
|
||||
errors.CheckError(stderrors.New("Only one of source-position and source-name can be specified."))
|
||||
errors.Fatal(errors.ErrorGeneric, "Only one of source-position and source-name can be specified.")
|
||||
}
|
||||
|
||||
if sourceName != "" {
|
||||
|
|
@ -416,10 +416,10 @@ func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
|
|||
// check for source position if --show-params is set
|
||||
if app.Spec.HasMultipleSources() && showParams {
|
||||
if sourcePosition <= 0 {
|
||||
errors.CheckError(stderrors.New("Source position should be specified and must be greater than 0 for applications with multiple sources"))
|
||||
errors.Fatal(errors.ErrorGeneric, "Source position should be specified and must be greater than 0 for applications with multiple sources")
|
||||
}
|
||||
if len(app.Spec.GetSources()) < sourcePosition {
|
||||
errors.CheckError(stderrors.New("Source position should be less than the number of sources in the application"))
|
||||
errors.Fatal(errors.ErrorGeneric, "Source position should be less than the number of sources in the application")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -841,7 +841,7 @@ func NewApplicationSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
|
|||
|
||||
sourceName = appOpts.SourceName
|
||||
if sourceName != "" && sourcePosition != -1 {
|
||||
errors.CheckError(stderrors.New("Only one of source-position and source-name can be specified."))
|
||||
errors.Fatal(errors.ErrorGeneric, "Only one of source-position and source-name can be specified.")
|
||||
}
|
||||
|
||||
if sourceName != "" {
|
||||
|
|
@ -855,10 +855,10 @@ func NewApplicationSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
|
|||
|
||||
if app.Spec.HasMultipleSources() {
|
||||
if sourcePosition <= 0 {
|
||||
errors.CheckError(stderrors.New("Source position should be specified and must be greater than 0 for applications with multiple sources"))
|
||||
errors.Fatal(errors.ErrorGeneric, "Source position should be specified and must be greater than 0 for applications with multiple sources")
|
||||
}
|
||||
if len(app.Spec.GetSources()) < sourcePosition {
|
||||
errors.CheckError(stderrors.New("Source position should be less than the number of sources in the application"))
|
||||
errors.Fatal(errors.ErrorGeneric, "Source position should be less than the number of sources in the application")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -956,7 +956,7 @@ func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.C
|
|||
|
||||
sourceName = appOpts.SourceName
|
||||
if sourceName != "" && sourcePosition != -1 {
|
||||
errors.CheckError(stderrors.New("Only one of source-position and source-name can be specified."))
|
||||
errors.Fatal(errors.ErrorGeneric, "Only one of source-position and source-name can be specified.")
|
||||
}
|
||||
|
||||
if sourceName != "" {
|
||||
|
|
@ -970,10 +970,10 @@ func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.C
|
|||
|
||||
if app.Spec.HasMultipleSources() {
|
||||
if sourcePosition <= 0 {
|
||||
errors.CheckError(stderrors.New("Source position should be specified and must be greater than 0 for applications with multiple sources"))
|
||||
errors.Fatal(errors.ErrorGeneric, "Source position should be specified and must be greater than 0 for applications with multiple sources")
|
||||
}
|
||||
if len(app.Spec.GetSources()) < sourcePosition {
|
||||
errors.CheckError(stderrors.New("Source position should be less than the number of sources in the application"))
|
||||
errors.Fatal(errors.ErrorGeneric, "Source position should be less than the number of sources in the application")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1214,7 +1214,7 @@ func groupObjsByKey(localObs []*unstructured.Unstructured, liveObjs []*unstructu
|
|||
objByKey := make(map[kube.ResourceKey]*unstructured.Unstructured)
|
||||
for i := range localObs {
|
||||
obj := localObs[i]
|
||||
if !(hook.IsHook(obj) || ignore.Ignore(obj)) {
|
||||
if !hook.IsHook(obj) && !ignore.Ignore(obj) {
|
||||
objByKey[kube.GetResourceKey(obj)] = obj
|
||||
}
|
||||
}
|
||||
|
|
@ -1259,15 +1259,15 @@ func NewApplicationDiffCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
|
|||
}
|
||||
|
||||
if len(sourceNames) > 0 && len(sourcePositions) > 0 {
|
||||
errors.CheckError(stderrors.New("Only one of source-positions and source-names can be specified."))
|
||||
errors.Fatal(errors.ErrorGeneric, "Only one of source-positions and source-names can be specified.")
|
||||
}
|
||||
|
||||
if len(sourcePositions) > 0 && len(revisions) != len(sourcePositions) {
|
||||
errors.CheckError(stderrors.New("While using --revisions and --source-positions, length of values for both flags should be same."))
|
||||
errors.Fatal(errors.ErrorGeneric, "While using --revisions and --source-positions, length of values for both flags should be same.")
|
||||
}
|
||||
|
||||
if len(sourceNames) > 0 && len(revisions) != len(sourceNames) {
|
||||
errors.CheckError(stderrors.New("While using --revisions and --source-names, length of values for both flags should be same."))
|
||||
errors.Fatal(errors.ErrorGeneric, "While using --revisions and --source-names, length of values for both flags should be same.")
|
||||
}
|
||||
|
||||
clientset := headless.NewClientOrDie(clientOpts, c)
|
||||
|
|
@ -1548,7 +1548,7 @@ func NewApplicationDeleteCommand(clientOpts *argocdclient.ClientOptions) *cobra.
|
|||
acdClient := headless.NewClientOrDie(clientOpts, c)
|
||||
conn, appIf := acdClient.NewApplicationClientOrDie()
|
||||
defer argoio.Close(conn)
|
||||
var isTerminal bool = isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd())
|
||||
isTerminal := isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd())
|
||||
promptFlag := c.Flag("yes")
|
||||
if promptFlag.Changed && promptFlag.Value.String() == "true" {
|
||||
noPrompt = true
|
||||
|
|
@ -1779,7 +1779,7 @@ func parseSelectedResources(resources []string) ([]*argoappv1.SyncOperationResou
|
|||
}
|
||||
nameFields := strings.Split(resourceName, resourceFieldNamespaceDelimiter)
|
||||
if len(nameFields) != resourceFieldNameWithNamespaceCount {
|
||||
return "", "", fmt.Errorf("Resource with namespace should have GROUP%sKIND%sNAMESPACE%sNAME, but instead got: %s", resourceFieldDelimiter, resourceFieldDelimiter, resourceFieldNamespaceDelimiter, resource)
|
||||
return "", "", fmt.Errorf("resource with namespace should have GROUP%sKIND%sNAMESPACE%sNAME, but instead got: %s", resourceFieldDelimiter, resourceFieldDelimiter, resourceFieldNamespaceDelimiter, resource)
|
||||
}
|
||||
namespace := nameFields[0]
|
||||
name := nameFields[1]
|
||||
|
|
@ -1800,7 +1800,7 @@ func parseSelectedResources(resources []string) ([]*argoappv1.SyncOperationResou
|
|||
}
|
||||
fields := strings.Split(resource, resourceFieldDelimiter)
|
||||
if len(fields) != resourceFieldCount {
|
||||
return nil, fmt.Errorf("Resource should have GROUP%sKIND%sNAME, but instead got: %s", resourceFieldDelimiter, resourceFieldDelimiter, resource)
|
||||
return nil, fmt.Errorf("resource should have GROUP%sKIND%sNAME, but instead got: %s", resourceFieldDelimiter, resourceFieldDelimiter, resource)
|
||||
}
|
||||
name, namespace, err := nameRetriever(fields[2], resource)
|
||||
if err != nil {
|
||||
|
|
@ -2852,7 +2852,7 @@ func findRevisionHistory(application *argoappv1.Application, historyId int64) (*
|
|||
if historyId == -1 {
|
||||
l := len(application.Status.History)
|
||||
if l < 2 {
|
||||
return nil, fmt.Errorf("Application '%s' should have at least two successful deployments", application.ObjectMeta.Name)
|
||||
return nil, fmt.Errorf("application '%s' should have at least two successful deployments", application.Name)
|
||||
}
|
||||
return &application.Status.History[l-2], nil
|
||||
}
|
||||
|
|
@ -2861,7 +2861,7 @@ func findRevisionHistory(application *argoappv1.Application, historyId int64) (*
|
|||
return &di, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("Application '%s' does not have deployment id '%d' in history\n", application.ObjectMeta.Name, historyId)
|
||||
return nil, fmt.Errorf("application '%s' does not have deployment id '%d' in history", application.Name, historyId)
|
||||
}
|
||||
|
||||
// NewApplicationRollbackCommand returns a new instance of an `argocd app rollback` command
|
||||
|
|
@ -2989,15 +2989,15 @@ func NewApplicationManifestsCommand(clientOpts *argocdclient.ClientOptions) *cob
|
|||
}
|
||||
|
||||
if len(sourceNames) > 0 && len(sourcePositions) > 0 {
|
||||
errors.CheckError(stderrors.New("Only one of source-positions and source-names can be specified."))
|
||||
errors.Fatal(errors.ErrorGeneric, "Only one of source-positions and source-names can be specified.")
|
||||
}
|
||||
|
||||
if len(sourcePositions) > 0 && len(revisions) != len(sourcePositions) {
|
||||
errors.CheckError(stderrors.New("While using --revisions and --source-positions, length of values for both flags should be same."))
|
||||
errors.Fatal(errors.ErrorGeneric, "While using --revisions and --source-positions, length of values for both flags should be same.")
|
||||
}
|
||||
|
||||
if len(sourceNames) > 0 && len(revisions) != len(sourceNames) {
|
||||
errors.CheckError(stderrors.New("While using --revisions and --source-names, length of values for both flags should be same."))
|
||||
errors.Fatal(errors.ErrorGeneric, "While using --revisions and --source-names, length of values for both flags should be same.")
|
||||
}
|
||||
|
||||
for _, pos := range sourcePositions {
|
||||
|
|
@ -3280,7 +3280,7 @@ func NewApplicationAddSourceCommand(clientOpts *argocdclient.ClientOptions) *cob
|
|||
errors.CheckError(err)
|
||||
|
||||
if c.Flags() == nil {
|
||||
errors.CheckError(stderrors.New("ApplicationSource needs atleast repoUrl, path or chart or ref field. No source to add."))
|
||||
errors.Fatal(errors.ErrorGeneric, "ApplicationSource needs atleast repoUrl, path or chart or ref field. No source to add.")
|
||||
}
|
||||
|
||||
if len(app.Spec.Sources) > 0 {
|
||||
|
|
@ -3300,9 +3300,9 @@ func NewApplicationAddSourceCommand(clientOpts *argocdclient.ClientOptions) *cob
|
|||
})
|
||||
errors.CheckError(err)
|
||||
|
||||
fmt.Printf("Application '%s' updated successfully\n", app.ObjectMeta.Name)
|
||||
fmt.Printf("Application '%s' updated successfully\n", app.Name)
|
||||
} else {
|
||||
errors.CheckError(fmt.Errorf("Cannot add source: application %s does not have spec.sources defined", appName))
|
||||
errors.Fatal(errors.ErrorGeneric, fmt.Sprintf("Cannot add source: application %s does not have spec.sources defined", appName))
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
@ -3335,7 +3335,7 @@ func NewApplicationRemoveSourceCommand(clientOpts *argocdclient.ClientOptions) *
|
|||
}
|
||||
|
||||
if sourceName == "" && sourcePosition <= 0 {
|
||||
errors.CheckError(stderrors.New("Value of source-position must be greater than 0"))
|
||||
errors.Fatal(errors.ErrorGeneric, "Value of source-position must be greater than 0")
|
||||
}
|
||||
|
||||
argocdClient := headless.NewClientOrDie(clientOpts, c)
|
||||
|
|
@ -3352,7 +3352,7 @@ func NewApplicationRemoveSourceCommand(clientOpts *argocdclient.ClientOptions) *
|
|||
errors.CheckError(err)
|
||||
|
||||
if sourceName != "" && sourcePosition != -1 {
|
||||
errors.CheckError(stderrors.New("Only one of source-position and source-name can be specified."))
|
||||
errors.Fatal(errors.ErrorGeneric, "Only one of source-position and source-name can be specified.")
|
||||
}
|
||||
|
||||
if sourceName != "" {
|
||||
|
|
@ -3365,15 +3365,15 @@ func NewApplicationRemoveSourceCommand(clientOpts *argocdclient.ClientOptions) *
|
|||
}
|
||||
|
||||
if !app.Spec.HasMultipleSources() {
|
||||
errors.CheckError(stderrors.New("Application does not have multiple sources configured"))
|
||||
errors.Fatal(errors.ErrorGeneric, "Application does not have multiple sources configured")
|
||||
}
|
||||
|
||||
if len(app.Spec.GetSources()) == 1 {
|
||||
errors.CheckError(stderrors.New("Cannot remove the only source remaining in the app"))
|
||||
errors.Fatal(errors.ErrorGeneric, "Cannot remove the only source remaining in the app")
|
||||
}
|
||||
|
||||
if len(app.Spec.GetSources()) < sourcePosition {
|
||||
errors.CheckError(fmt.Errorf("Application does not have source at %d\n", sourcePosition))
|
||||
errors.Fatal(errors.ErrorGeneric, fmt.Sprintf("Application does not have source at %d\n", sourcePosition))
|
||||
}
|
||||
|
||||
app.Spec.Sources = append(app.Spec.Sources[:sourcePosition-1], app.Spec.Sources[sourcePosition:]...)
|
||||
|
|
@ -3388,7 +3388,7 @@ func NewApplicationRemoveSourceCommand(clientOpts *argocdclient.ClientOptions) *
|
|||
})
|
||||
errors.CheckError(err)
|
||||
|
||||
fmt.Printf("Application '%s' updated successfully\n", app.ObjectMeta.Name)
|
||||
fmt.Printf("Application '%s' updated successfully\n", app.Name)
|
||||
} else {
|
||||
fmt.Println("The command to delete the source was cancelled")
|
||||
}
|
||||
|
|
@ -3440,7 +3440,7 @@ func NewApplicationConfirmDeletionCommand(clientOpts *argocdclient.ClientOptions
|
|||
})
|
||||
errors.CheckError(err)
|
||||
|
||||
fmt.Printf("Application '%s' updated successfully\n", app.ObjectMeta.Name)
|
||||
fmt.Printf("Application '%s' updated successfully\n", app.Name)
|
||||
},
|
||||
}
|
||||
command.Flags().StringVarP(&appNamespace, "app-namespace", "N", "", "Namespace of the target application where the source will be appended")
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ func TestFindRevisionHistoryWithoutPassedIdAndEmptyHistoryList(t *testing.T) {
|
|||
|
||||
require.Error(t, err, "Find revision history should fail with errors")
|
||||
require.Nil(t, history, "History should be empty")
|
||||
require.EqualError(t, err, "Application '' should have at least two successful deployments", "Find revision history should fail with correct error message")
|
||||
require.EqualError(t, err, "application '' should have at least two successful deployments", "Find revision history should fail with correct error message")
|
||||
}
|
||||
|
||||
func TestFindRevisionHistoryWithPassedId(t *testing.T) {
|
||||
|
|
@ -356,7 +356,7 @@ func TestFindRevisionHistoryWithPassedIdThatNotExist(t *testing.T) {
|
|||
|
||||
require.Error(t, err, "Find revision history should fail with errors")
|
||||
require.Nil(t, history, "History should be not found")
|
||||
require.EqualError(t, err, "Application '' does not have deployment id '4' in history\n", "Find revision history should fail with correct error message")
|
||||
require.EqualError(t, err, "application '' does not have deployment id '4' in history", "Find revision history should fail with correct error message")
|
||||
}
|
||||
|
||||
func Test_groupObjsByKey(t *testing.T) {
|
||||
|
|
@ -1112,7 +1112,7 @@ func Test_unset(t *testing.T) {
|
|||
|
||||
assert.Equal(t, "some-prefix", kustomizeSource.Kustomize.NamePrefix)
|
||||
updated, nothingToUnset := unset(kustomizeSource, unsetOpts{namePrefix: true})
|
||||
assert.Equal(t, "", kustomizeSource.Kustomize.NamePrefix)
|
||||
assert.Empty(t, kustomizeSource.Kustomize.NamePrefix)
|
||||
assert.True(t, updated)
|
||||
assert.False(t, nothingToUnset)
|
||||
updated, nothingToUnset = unset(kustomizeSource, unsetOpts{namePrefix: true})
|
||||
|
|
@ -1121,7 +1121,7 @@ func Test_unset(t *testing.T) {
|
|||
|
||||
assert.Equal(t, "some-suffix", kustomizeSource.Kustomize.NameSuffix)
|
||||
updated, nothingToUnset = unset(kustomizeSource, unsetOpts{nameSuffix: true})
|
||||
assert.Equal(t, "", kustomizeSource.Kustomize.NameSuffix)
|
||||
assert.Empty(t, kustomizeSource.Kustomize.NameSuffix)
|
||||
assert.True(t, updated)
|
||||
assert.False(t, nothingToUnset)
|
||||
updated, nothingToUnset = unset(kustomizeSource, unsetOpts{nameSuffix: true})
|
||||
|
|
@ -1130,7 +1130,7 @@ func Test_unset(t *testing.T) {
|
|||
|
||||
assert.Equal(t, "123", kustomizeSource.Kustomize.Version)
|
||||
updated, nothingToUnset = unset(kustomizeSource, unsetOpts{kustomizeVersion: true})
|
||||
assert.Equal(t, "", kustomizeSource.Kustomize.Version)
|
||||
assert.Empty(t, kustomizeSource.Kustomize.Version)
|
||||
assert.True(t, updated)
|
||||
assert.False(t, nothingToUnset)
|
||||
updated, nothingToUnset = unset(kustomizeSource, unsetOpts{kustomizeVersion: true})
|
||||
|
|
@ -1184,7 +1184,7 @@ func Test_unset(t *testing.T) {
|
|||
|
||||
assert.Equal(t, "some: yaml", helmSource.Helm.ValuesString())
|
||||
updated, nothingToUnset = unset(helmSource, unsetOpts{valuesLiteral: true})
|
||||
assert.Equal(t, "", helmSource.Helm.ValuesString())
|
||||
assert.Empty(t, helmSource.Helm.ValuesString())
|
||||
assert.True(t, updated)
|
||||
assert.False(t, nothingToUnset)
|
||||
updated, nothingToUnset = unset(helmSource, unsetOpts{valuesLiteral: true})
|
||||
|
|
|
|||
|
|
@ -146,8 +146,7 @@ func NewApplicationSetCreateCommand(clientOpts *argocdclient.ClientOptions) *cob
|
|||
|
||||
for _, appset := range appsets {
|
||||
if appset.Name == "" {
|
||||
err := fmt.Errorf("Error creating ApplicationSet %s. ApplicationSet does not have Name field set", appset)
|
||||
errors.CheckError(err)
|
||||
errors.Fatal(errors.ErrorGeneric, fmt.Sprintf("Error creating ApplicationSet %s. ApplicationSet does not have Name field set", appset))
|
||||
}
|
||||
|
||||
conn, appIf := argocdClient.NewApplicationSetClientOrDie()
|
||||
|
|
@ -182,7 +181,7 @@ func NewApplicationSetCreateCommand(clientOpts *argocdclient.ClientOptions) *cob
|
|||
action = "updated"
|
||||
}
|
||||
|
||||
c.PrintErrf("ApplicationSet '%s' %s%s\n", created.ObjectMeta.Name, action, dryRunMsg)
|
||||
c.PrintErrf("ApplicationSet '%s' %s%s\n", created.Name, action, dryRunMsg)
|
||||
|
||||
switch output {
|
||||
case "yaml", "json":
|
||||
|
|
@ -238,8 +237,7 @@ func NewApplicationSetGenerateCommand(clientOpts *argocdclient.ClientOptions) *c
|
|||
}
|
||||
appset := appsets[0]
|
||||
if appset.Name == "" {
|
||||
err := fmt.Errorf("Error generating apps for ApplicationSet %s. ApplicationSet does not have Name field set", appset)
|
||||
errors.CheckError(err)
|
||||
errors.Fatal(errors.ErrorGeneric, fmt.Sprintf("Error generating apps for ApplicationSet %s. ApplicationSet does not have Name field set", appset))
|
||||
}
|
||||
|
||||
conn, appIf := argocdClient.NewApplicationSetClientOrDie()
|
||||
|
|
@ -344,7 +342,7 @@ func NewApplicationSetDeleteCommand(clientOpts *argocdclient.ClientOptions) *cob
|
|||
}
|
||||
conn, appIf := headless.NewClientOrDie(clientOpts, c).NewApplicationSetClientOrDie()
|
||||
defer argoio.Close(conn)
|
||||
var isTerminal bool = isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd())
|
||||
isTerminal := isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd())
|
||||
numOfApps := len(args)
|
||||
promptFlag := c.Flag("yes")
|
||||
if promptFlag.Changed && promptFlag.Value.String() == "true" {
|
||||
|
|
@ -497,7 +495,7 @@ func hasAppSetChanged(appReq, appRes *arogappsetv1.ApplicationSet, upsert bool)
|
|||
|
||||
if reflect.DeepEqual(appRes.Spec, appReq.Spec) &&
|
||||
reflect.DeepEqual(appRes.Labels, appReq.Labels) &&
|
||||
reflect.DeepEqual(appRes.ObjectMeta.Annotations, appReq.Annotations) &&
|
||||
reflect.DeepEqual(appRes.Annotations, appReq.Annotations) &&
|
||||
reflect.DeepEqual(appRes.Finalizers, appReq.Finalizers) {
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,13 +167,13 @@ func NewCertAddSSHCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command
|
|||
sshKnownHostsLists, err = certutil.ParseSSHKnownHostsFromStream(os.Stdin)
|
||||
}
|
||||
} else {
|
||||
err = stderrors.New("You need to specify --batch or specify --help for usage instructions")
|
||||
err = stderrors.New("you need to specify --batch or specify --help for usage instructions")
|
||||
}
|
||||
|
||||
errors.CheckError(err)
|
||||
|
||||
if len(sshKnownHostsLists) == 0 {
|
||||
errors.CheckError(stderrors.New("No valid SSH known hosts data found."))
|
||||
errors.Fatal(errors.ErrorGeneric, "No valid SSH known hosts data found.")
|
||||
}
|
||||
|
||||
for _, knownHostsEntry := range sshKnownHostsLists {
|
||||
|
|
@ -234,8 +234,7 @@ func NewCertRemoveCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command
|
|||
// remove all certificates, but it's less likely that it happens by
|
||||
// accident.
|
||||
if hostNamePattern == "*" {
|
||||
err := stderrors.New("A single wildcard is not allowed as REPOSERVER name.")
|
||||
errors.CheckError(err)
|
||||
errors.Fatal(errors.ErrorGeneric, "A single wildcard is not allowed as REPOSERVER name.")
|
||||
}
|
||||
|
||||
promptUtil := utils.NewPrompt(clientOpts.PromptsEnabled)
|
||||
|
|
@ -318,11 +317,12 @@ func printCertTable(certs []appsv1.RepositoryCertificate, sortOrder string) {
|
|||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
|
||||
fmt.Fprintf(w, "HOSTNAME\tTYPE\tSUBTYPE\tINFO\n")
|
||||
|
||||
if sortOrder == "hostname" || sortOrder == "" {
|
||||
switch sortOrder {
|
||||
case "hostname", "":
|
||||
sort.Slice(certs, func(i, j int) bool {
|
||||
return certs[i].ServerName < certs[j].ServerName
|
||||
})
|
||||
} else if sortOrder == "type" {
|
||||
case "type":
|
||||
sort.Slice(certs, func(i, j int) bool {
|
||||
return certs[i].CertType < certs[j].CertType
|
||||
})
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ func NewClusterAddCommand(clientOpts *argocdclient.ClientOptions, pathOpts *clie
|
|||
endpoint = clst.Server
|
||||
}
|
||||
clst.Server = endpoint
|
||||
clst.Config.TLSClientConfig.CAData = caData
|
||||
clst.Config.CAData = caData
|
||||
}
|
||||
|
||||
if clusterOpts.Shard >= 0 {
|
||||
|
|
@ -215,7 +215,7 @@ func getRestConfig(pathOpts *clientcmd.PathOptions, ctxName string) (*rest.Confi
|
|||
|
||||
clstContext := config.Contexts[ctxName]
|
||||
if clstContext == nil {
|
||||
return nil, fmt.Errorf("Context %s does not exist in kubeconfig", ctxName)
|
||||
return nil, fmt.Errorf("context %s does not exist in kubeconfig", ctxName)
|
||||
}
|
||||
|
||||
overrides := clientcmd.ConfigOverrides{
|
||||
|
|
@ -384,8 +384,8 @@ func printClusterDetails(clusters []argoappv1.Cluster) {
|
|||
fmt.Printf(" Server Version: %s\n", cluster.ServerVersion)
|
||||
fmt.Printf(" Namespaces: %s\n", formatNamespaces(cluster))
|
||||
fmt.Printf("\nTLS configuration\n\n")
|
||||
fmt.Printf(" Client cert: %v\n", string(cluster.Config.TLSClientConfig.CertData) != "")
|
||||
fmt.Printf(" Cert validation: %v\n", !cluster.Config.TLSClientConfig.Insecure)
|
||||
fmt.Printf(" Client cert: %v\n", string(cluster.Config.CertData) != "")
|
||||
fmt.Printf(" Cert validation: %v\n", !cluster.Config.Insecure)
|
||||
fmt.Printf("\nAuthentication\n\n")
|
||||
fmt.Printf(" Basic authentication: %v\n", cluster.Config.Username != "")
|
||||
fmt.Printf(" oAuth authentication: %v\n", cluster.Config.BearerToken != "")
|
||||
|
|
|
|||
|
|
@ -15,14 +15,14 @@ import (
|
|||
func Test_getQueryBySelector(t *testing.T) {
|
||||
query := getQueryBySelector("my-cluster")
|
||||
assert.Equal(t, "my-cluster", query.Name)
|
||||
assert.Equal(t, "", query.Server)
|
||||
assert.Empty(t, query.Server)
|
||||
|
||||
query = getQueryBySelector("http://my-server")
|
||||
assert.Equal(t, "", query.Name)
|
||||
assert.Empty(t, query.Name)
|
||||
assert.Equal(t, "http://my-server", query.Server)
|
||||
|
||||
query = getQueryBySelector("https://my-server")
|
||||
assert.Equal(t, "", query.Name)
|
||||
assert.Empty(t, query.Name)
|
||||
assert.Equal(t, "https://my-server", query.Server)
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ func Test_getRestConfig(t *testing.T) {
|
|||
},
|
||||
nil,
|
||||
true,
|
||||
"Context not-exist does not exist in kubeconfig",
|
||||
"context not-exist does not exist in kubeconfig",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
|
|
|||
|
|
@ -86,12 +86,12 @@ func deleteContext(context, configPath string) error {
|
|||
localCfg, err := localconfig.ReadLocalConfig(configPath)
|
||||
errors.CheckError(err)
|
||||
if localCfg == nil {
|
||||
return stderrors.New("Nothing to logout from")
|
||||
return stderrors.New("nothing to logout from")
|
||||
}
|
||||
|
||||
serverName, ok := localCfg.RemoveContext(context)
|
||||
if !ok {
|
||||
return fmt.Errorf("Context %s does not exist", context)
|
||||
return fmt.Errorf("context %s does not exist", context)
|
||||
}
|
||||
_ = localCfg.RemoveUser(context)
|
||||
_ = localCfg.RemoveServer(serverName)
|
||||
|
|
@ -105,7 +105,7 @@ func deleteContext(context, configPath string) error {
|
|||
}
|
||||
err = localconfig.ValidateLocalConfig(*localCfg)
|
||||
if err != nil {
|
||||
return stderrors.New("Error in logging out")
|
||||
return stderrors.New("error in logging out")
|
||||
}
|
||||
err = localconfig.WriteLocalConfig(*localCfg, configPath)
|
||||
errors.CheckError(err)
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ func TestContextDelete(t *testing.T) {
|
|||
|
||||
localConfig, err = localconfig.ReadLocalConfig(testConfigFilePath)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "", localConfig.CurrentContext)
|
||||
assert.Empty(t, localConfig.CurrentContext)
|
||||
assert.NotContains(t, localConfig.Contexts, localconfig.ContextRef{Name: "localhost:8080", Server: "localhost:8080", User: "localhost:8080"})
|
||||
assert.NotContains(t, localConfig.Servers, localconfig.Server{PlainText: true, Server: "localhost:8080"})
|
||||
assert.NotContains(t, localConfig.Users, localconfig.User{AuthToken: "vErrYS3c3tReFRe$hToken", Name: "localhost:8080"})
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ func NewGPGGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
|||
ctx := c.Context()
|
||||
|
||||
if len(args) != 1 {
|
||||
errors.CheckError(stderrors.New("Missing KEYID argument"))
|
||||
errors.Fatal(errors.ErrorGeneric, "Missing KEYID argument")
|
||||
}
|
||||
conn, gpgIf := headless.NewClientOrDie(clientOpts, c).NewGPGKeyClientOrDie()
|
||||
defer argoio.Close(conn)
|
||||
|
|
@ -167,7 +167,7 @@ func NewGPGDeleteCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command
|
|||
ctx := c.Context()
|
||||
|
||||
if len(args) != 1 {
|
||||
errors.CheckError(stderrors.New("Missing KEYID argument"))
|
||||
errors.Fatal(errors.ErrorGeneric, "Missing KEYID argument")
|
||||
}
|
||||
|
||||
keyId := args[0]
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ func Test_FlagContextNotChanged(t *testing.T) {
|
|||
Annotations: nil,
|
||||
})
|
||||
|
||||
assert.Equal(t, "", res)
|
||||
assert.Empty(t, res)
|
||||
}
|
||||
|
||||
func Test_FlagContextChanged(t *testing.T) {
|
||||
|
|
@ -76,5 +76,5 @@ func Test_FlagContextNil(t *testing.T) {
|
|||
Annotations: nil,
|
||||
})
|
||||
|
||||
assert.Equal(t, "", res)
|
||||
assert.Empty(t, res)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ func TestNewReloginCommand(t *testing.T) {
|
|||
// Assert command flags
|
||||
passwordFlag := cmd.Flags().Lookup("password")
|
||||
assert.NotNil(t, passwordFlag, "Expected flag --password to be defined")
|
||||
assert.Equal(t, "", passwordFlag.Value.String(), "Unexpected default value for --password flag")
|
||||
assert.Empty(t, passwordFlag.Value.String(), "Unexpected default value for --password flag")
|
||||
|
||||
ssoPortFlag := cmd.Flags().Lookup("sso-port")
|
||||
port, err := strconv.Atoi(ssoPortFlag.Value.String())
|
||||
|
|
@ -55,7 +55,7 @@ func TestNewReloginCommandWithGlobalClientOptions(t *testing.T) {
|
|||
// Assert command flags
|
||||
passwordFlag := cmd.Flags().Lookup("password")
|
||||
assert.NotNil(t, passwordFlag, "Expected flag --password to be defined")
|
||||
assert.Equal(t, "", passwordFlag.Value.String(), "Unexpected default value for --password flag")
|
||||
assert.Empty(t, passwordFlag.Value.String(), "Unexpected default value for --password flag")
|
||||
|
||||
ssoPortFlag := cmd.Flags().Lookup("sso-port")
|
||||
port, err := strconv.Atoi(ssoPortFlag.Value.String())
|
||||
|
|
|
|||
|
|
@ -119,8 +119,7 @@ func NewRepoAddCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
|||
}
|
||||
repoOpts.Repo.SSHPrivateKey = string(keyData)
|
||||
} else {
|
||||
err := stderrors.New("--ssh-private-key-path is only supported for SSH repositories.")
|
||||
errors.CheckError(err)
|
||||
errors.Fatal(errors.ErrorGeneric, "--ssh-private-key-path is only supported for SSH repositories.")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -185,7 +184,7 @@ func NewRepoAddCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
|||
repoOpts.Repo.UseAzureWorkloadIdentity = repoOpts.UseAzureWorkloadIdentity
|
||||
|
||||
if repoOpts.Repo.Type == "helm" && repoOpts.Repo.Name == "" {
|
||||
errors.CheckError(stderrors.New("Must specify --name for repos of type 'helm'"))
|
||||
errors.Fatal(errors.ErrorGeneric, "Must specify --name for repos of type 'helm'")
|
||||
}
|
||||
|
||||
conn, repoIf := headless.NewClientOrDie(clientOpts, c).NewRepoClientOrDie()
|
||||
|
|
|
|||
|
|
@ -109,16 +109,14 @@ func NewRepoCredsAddCommand(clientOpts *argocdclient.ClientOptions) *cobra.Comma
|
|||
}
|
||||
repo.SSHPrivateKey = string(keyData)
|
||||
} else {
|
||||
err := stderrors.New("--ssh-private-key-path is only supported for SSH repositories.")
|
||||
errors.CheckError(err)
|
||||
errors.Fatal(errors.ErrorGeneric, "--ssh-private-key-path is only supported for SSH repositories.")
|
||||
}
|
||||
}
|
||||
|
||||
// tls-client-cert-path and tls-client-cert-key-key-path must always be
|
||||
// specified together
|
||||
if (tlsClientCertPath != "" && tlsClientCertKeyPath == "") || (tlsClientCertPath == "" && tlsClientCertKeyPath != "") {
|
||||
err := stderrors.New("--tls-client-cert-path and --tls-client-cert-key-path must be specified together")
|
||||
errors.CheckError(err)
|
||||
errors.Fatal(errors.ErrorGeneric, "--tls-client-cert-path and --tls-client-cert-key-path must be specified together")
|
||||
}
|
||||
|
||||
// Specifying tls-client-cert-path is only valid for HTTPS repositories
|
||||
|
|
|
|||
|
|
@ -581,7 +581,7 @@ func readAppsFromStdin(apps *[]*argoappv1.Application) error {
|
|||
func readAppsFromURI(fileURL string, apps *[]*argoappv1.Application) error {
|
||||
readFilePayload := func() ([]byte, error) {
|
||||
parsedURL, err := url.ParseRequestURI(fileURL)
|
||||
if err != nil || !(parsedURL.Scheme == "http" || parsedURL.Scheme == "https") {
|
||||
if err != nil || (parsedURL.Scheme != "http" && parsedURL.Scheme != "https") {
|
||||
return os.ReadFile(fileURL)
|
||||
}
|
||||
return config.ReadRemoteFile(fileURL)
|
||||
|
|
@ -697,7 +697,7 @@ func ConstructSource(source *argoappv1.ApplicationSource, appOpts AppOptions, fl
|
|||
var data []byte
|
||||
// read uri
|
||||
parsedURL, err := url.ParseRequestURI(appOpts.values)
|
||||
if err != nil || !(parsedURL.Scheme == "http" || parsedURL.Scheme == "https") {
|
||||
if err != nil || (parsedURL.Scheme != "http" && parsedURL.Scheme != "https") {
|
||||
data, err = os.ReadFile(appOpts.values)
|
||||
} else {
|
||||
data, err = config.ReadRemoteFile(appOpts.values)
|
||||
|
|
@ -914,10 +914,10 @@ func FilterResources(groupChanged bool, resources []*argoappv1.ResourceDiff, gro
|
|||
filteredObjects = append(filteredObjects, deepCopy)
|
||||
}
|
||||
if len(filteredObjects) == 0 {
|
||||
return nil, stderrors.New("No matching resource found")
|
||||
return nil, stderrors.New("no matching resource found")
|
||||
}
|
||||
if len(filteredObjects) > 1 && !all {
|
||||
return nil, stderrors.New("Multiple resources match inputs. Use the --all flag to patch multiple resources")
|
||||
return nil, stderrors.New("multiple resources match inputs, use the --all flag to patch multiple resources")
|
||||
}
|
||||
return filteredObjects, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -554,7 +554,7 @@ func TestFilterResources(t *testing.T) {
|
|||
}
|
||||
|
||||
filteredResources, err := FilterResources(false, resources, "g", "Service", "argocd-unknown", "test-helm", true)
|
||||
require.ErrorContains(t, err, "No matching resource found")
|
||||
require.ErrorContains(t, err, "no matching resource found")
|
||||
assert.Nil(t, filteredResources)
|
||||
})
|
||||
|
||||
|
|
@ -569,7 +569,7 @@ func TestFilterResources(t *testing.T) {
|
|||
}
|
||||
|
||||
filteredResources, err := FilterResources(false, resources, "g", "Service", "argocd", "test-helm", false)
|
||||
require.ErrorContains(t, err, "Use the --all flag")
|
||||
require.ErrorContains(t, err, "use the --all flag")
|
||||
assert.Nil(t, filteredResources)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ func constructAppsetFromFileURL(fileURL string) ([]*argoprojiov1alpha1.Applicati
|
|||
func readAppsetFromURI(fileURL string, appset *[]*argoprojiov1alpha1.ApplicationSet) error {
|
||||
readFilePayload := func() ([]byte, error) {
|
||||
parsedURL, err := url.ParseRequestURI(fileURL)
|
||||
if err != nil || !(parsedURL.Scheme == "http" || parsedURL.Scheme == "https") {
|
||||
if err != nil || (parsedURL.Scheme != "http" && parsedURL.Scheme != "https") {
|
||||
return os.ReadFile(fileURL)
|
||||
}
|
||||
return config.ReadRemoteFile(fileURL)
|
||||
|
|
|
|||
|
|
@ -70,24 +70,24 @@ func PrintKubeContexts(ca clientcmd.ConfigAccess) {
|
|||
|
||||
func NewCluster(name string, namespaces []string, clusterResources bool, conf *rest.Config, managerBearerToken string, awsAuthConf *argoappv1.AWSAuthConfig, execProviderConf *argoappv1.ExecProviderConfig, labels, annotations map[string]string) *argoappv1.Cluster {
|
||||
tlsClientConfig := argoappv1.TLSClientConfig{
|
||||
Insecure: conf.TLSClientConfig.Insecure,
|
||||
ServerName: conf.TLSClientConfig.ServerName,
|
||||
CAData: conf.TLSClientConfig.CAData,
|
||||
CertData: conf.TLSClientConfig.CertData,
|
||||
KeyData: conf.TLSClientConfig.KeyData,
|
||||
Insecure: conf.Insecure,
|
||||
ServerName: conf.ServerName,
|
||||
CAData: conf.CAData,
|
||||
CertData: conf.CertData,
|
||||
KeyData: conf.KeyData,
|
||||
}
|
||||
if len(conf.TLSClientConfig.CAData) == 0 && conf.TLSClientConfig.CAFile != "" {
|
||||
data, err := os.ReadFile(conf.TLSClientConfig.CAFile)
|
||||
if len(conf.CAData) == 0 && conf.CAFile != "" {
|
||||
data, err := os.ReadFile(conf.CAFile)
|
||||
errors.CheckError(err)
|
||||
tlsClientConfig.CAData = data
|
||||
}
|
||||
if len(conf.TLSClientConfig.CertData) == 0 && conf.TLSClientConfig.CertFile != "" {
|
||||
data, err := os.ReadFile(conf.TLSClientConfig.CertFile)
|
||||
if len(conf.CertData) == 0 && conf.CertFile != "" {
|
||||
data, err := os.ReadFile(conf.CertFile)
|
||||
errors.CheckError(err)
|
||||
tlsClientConfig.CertData = data
|
||||
}
|
||||
if len(conf.TLSClientConfig.KeyData) == 0 && conf.TLSClientConfig.KeyFile != "" {
|
||||
data, err := os.ReadFile(conf.TLSClientConfig.KeyFile)
|
||||
if len(conf.KeyData) == 0 && conf.KeyFile != "" {
|
||||
data, err := os.ReadFile(conf.KeyFile)
|
||||
errors.CheckError(err)
|
||||
tlsClientConfig.KeyData = data
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ func Test_newCluster(t *testing.T) {
|
|||
|
||||
assert.Equal(t, "test-cert-data", string(clusterWithData.Config.CertData))
|
||||
assert.Equal(t, "test-key-data", string(clusterWithData.Config.KeyData))
|
||||
assert.Equal(t, "", clusterWithData.Config.BearerToken)
|
||||
assert.Empty(t, clusterWithData.Config.BearerToken)
|
||||
assert.Equal(t, labels, clusterWithData.Labels)
|
||||
assert.Equal(t, annotations, clusterWithData.Annotations)
|
||||
assert.False(t, clusterWithData.Config.DisableCompression)
|
||||
|
|
@ -56,7 +56,7 @@ func Test_newCluster(t *testing.T) {
|
|||
|
||||
assert.Contains(t, string(clusterWithFiles.Config.CertData), "test-cert-data")
|
||||
assert.Contains(t, string(clusterWithFiles.Config.KeyData), "test-key-data")
|
||||
assert.Equal(t, "", clusterWithFiles.Config.BearerToken)
|
||||
assert.Empty(t, clusterWithFiles.Config.BearerToken)
|
||||
assert.Equal(t, labels, clusterWithFiles.Labels)
|
||||
assert.Nil(t, clusterWithFiles.Annotations)
|
||||
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ func readProjFromStdin(proj *v1alpha1.AppProject) error {
|
|||
|
||||
func readProjFromURI(fileURL string, proj *v1alpha1.AppProject) error {
|
||||
parsedURL, err := url.ParseRequestURI(fileURL)
|
||||
if err != nil || !(parsedURL.Scheme == "http" || parsedURL.Scheme == "https") {
|
||||
if err != nil || (parsedURL.Scheme != "http" && parsedURL.Scheme != "https") {
|
||||
err = config.UnmarshalLocalFile(fileURL, &proj)
|
||||
} else {
|
||||
err = config.UnmarshalRemoteFile(fileURL, &proj)
|
||||
|
|
|
|||
|
|
@ -17,12 +17,10 @@ func TestProjectOpts_ResourceLists(t *testing.T) {
|
|||
deniedClusterResources: []string{"rbac.authorization.k8s.io/ClusterRole"},
|
||||
}
|
||||
|
||||
assert.ElementsMatch(t,
|
||||
[]metav1.GroupKind{{Kind: "ConfigMap"}}, opts.GetAllowedNamespacedResources(),
|
||||
[]metav1.GroupKind{{Group: "apps", Kind: "DaemonSet"}}, opts.GetDeniedNamespacedResources(),
|
||||
[]metav1.GroupKind{{Group: "apiextensions.k8s.io", Kind: "CustomResourceDefinition"}}, opts.GetAllowedClusterResources(),
|
||||
[]metav1.GroupKind{{Group: "rbac.authorization.k8s.io", Kind: "ClusterRole"}}, opts.GetDeniedClusterResources(),
|
||||
)
|
||||
assert.ElementsMatch(t, []metav1.GroupKind{{Kind: "ConfigMap"}}, opts.GetAllowedNamespacedResources())
|
||||
assert.ElementsMatch(t, []metav1.GroupKind{{Group: "apps", Kind: "DaemonSet"}}, opts.GetDeniedNamespacedResources())
|
||||
assert.ElementsMatch(t, []metav1.GroupKind{{Group: "apiextensions.k8s.io", Kind: "CustomResourceDefinition"}}, opts.GetAllowedClusterResources())
|
||||
assert.ElementsMatch(t, []metav1.GroupKind{{Group: "rbac.authorization.k8s.io", Kind: "ClusterRole"}}, opts.GetDeniedClusterResources())
|
||||
}
|
||||
|
||||
func TestProjectOpts_GetDestinationServiceAccounts(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -83,10 +83,10 @@ func ReadPluginConfig(filePath string) (*PluginConfig, error) {
|
|||
|
||||
func ValidatePluginConfig(config PluginConfig) error {
|
||||
if config.Metadata.Name == "" {
|
||||
return errors.New("invalid plugin configuration file. metadata.name should be non-empty.")
|
||||
return errors.New("invalid plugin configuration file. metadata.name should be non-empty")
|
||||
}
|
||||
if config.TypeMeta.Kind != ConfigManagementPluginKind {
|
||||
return fmt.Errorf("invalid plugin configuration file. kind should be %s, found %s", ConfigManagementPluginKind, config.TypeMeta.Kind)
|
||||
if config.Kind != ConfigManagementPluginKind {
|
||||
return fmt.Errorf("invalid plugin configuration file. kind should be %s, found %s", ConfigManagementPluginKind, config.Kind)
|
||||
}
|
||||
if len(config.Spec.Generate.Command) == 0 {
|
||||
return errors.New("invalid plugin configuration file. spec.generate command should be non-empty")
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ func Test_ReadPluginConfig(t *testing.T) {
|
|||
metadata:
|
||||
`,
|
||||
expected: nil,
|
||||
expectedErr: "invalid plugin configuration file. metadata.name should be non-empty.",
|
||||
expectedErr: "invalid plugin configuration file. metadata.name should be non-empty",
|
||||
},
|
||||
{
|
||||
name: "empty metadata name",
|
||||
|
|
@ -97,7 +97,7 @@ metadata:
|
|||
name: ""
|
||||
`,
|
||||
expected: nil,
|
||||
expectedErr: "invalid plugin configuration file. metadata.name should be non-empty.",
|
||||
expectedErr: "invalid plugin configuration file. metadata.name should be non-empty",
|
||||
},
|
||||
{
|
||||
name: "invalid kind",
|
||||
|
|
|
|||
|
|
@ -444,7 +444,7 @@ const (
|
|||
// TokenVerificationError is a generic error message for a failure to verify a JWT
|
||||
const TokenVerificationError = "failed to verify the token"
|
||||
|
||||
var TokenVerificationErr = errors.New(TokenVerificationError)
|
||||
var ErrTokenVerification = errors.New(TokenVerificationError)
|
||||
|
||||
var PermissionDeniedAPIError = status.Error(codes.PermissionDenied, "permission denied")
|
||||
|
||||
|
|
|
|||
|
|
@ -612,7 +612,7 @@ func (ctrl *ApplicationController) getResourceTree(destCluster *appv1.Cluster, a
|
|||
}
|
||||
}
|
||||
err = ctrl.stateCache.IterateHierarchyV2(destCluster, managedResourcesKeys, func(child appv1.ResourceNode, _ string) bool {
|
||||
permitted, _ := proj.IsResourcePermitted(schema.GroupKind{Group: child.ResourceRef.Group, Kind: child.ResourceRef.Kind}, child.Namespace, destCluster, func(project string) ([]*appv1.Cluster, error) {
|
||||
permitted, _ := proj.IsResourcePermitted(schema.GroupKind{Group: child.Group, Kind: child.Kind}, child.Namespace, destCluster, func(project string) ([]*appv1.Cluster, error) {
|
||||
clusters, err := ctrl.db.GetProjectClusters(context.TODO(), project)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get project clusters: %w", err)
|
||||
|
|
@ -649,7 +649,7 @@ func (ctrl *ApplicationController) getResourceTree(destCluster *appv1.Cluster, a
|
|||
return false
|
||||
}
|
||||
|
||||
permitted, _ := proj.IsResourcePermitted(schema.GroupKind{Group: child.ResourceRef.Group, Kind: child.ResourceRef.Kind}, child.Namespace, destCluster, func(project string) ([]*appv1.Cluster, error) {
|
||||
permitted, _ := proj.IsResourcePermitted(schema.GroupKind{Group: child.Group, Kind: child.Kind}, child.Namespace, destCluster, func(project string) ([]*appv1.Cluster, error) {
|
||||
return ctrl.db.GetProjectClusters(context.TODO(), project)
|
||||
})
|
||||
|
||||
|
|
@ -1030,7 +1030,7 @@ func (ctrl *ApplicationController) processAppOperationQueueItem() (processNext b
|
|||
// If we get here, we are about to process an operation, but we cannot rely on informer since it might have stale data.
|
||||
// So always retrieve the latest version to ensure it is not stale to avoid unnecessary syncing.
|
||||
// We cannot rely on informer since applications might be updated by both application controller and api server.
|
||||
freshApp, err := ctrl.applicationClientset.ArgoprojV1alpha1().Applications(app.ObjectMeta.Namespace).Get(context.Background(), app.ObjectMeta.Name, metav1.GetOptions{})
|
||||
freshApp, err := ctrl.applicationClientset.ArgoprojV1alpha1().Applications(app.ObjectMeta.Namespace).Get(context.Background(), app.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
logCtx.Errorf("Failed to retrieve latest application state: %v", err)
|
||||
return
|
||||
|
|
@ -1448,10 +1448,11 @@ func (ctrl *ApplicationController) processRequestedAppOperation(app *appv1.Appli
|
|||
state.Message = err.Error()
|
||||
}
|
||||
|
||||
if state.Phase == synccommon.OperationRunning {
|
||||
switch state.Phase {
|
||||
case synccommon.OperationRunning:
|
||||
// It's possible for an app to be terminated while we were operating on it. We do not want
|
||||
// to clobber the Terminated state with Running. Get the latest app state to check for this.
|
||||
freshApp, err := ctrl.applicationClientset.ArgoprojV1alpha1().Applications(app.Namespace).Get(context.Background(), app.ObjectMeta.Name, metav1.GetOptions{})
|
||||
freshApp, err := ctrl.applicationClientset.ArgoprojV1alpha1().Applications(app.Namespace).Get(context.Background(), app.Name, metav1.GetOptions{})
|
||||
if err == nil {
|
||||
// App may have lost permissions to use the project meanwhile.
|
||||
_, err = ctrl.getAppProj(freshApp)
|
||||
|
|
@ -1467,7 +1468,7 @@ func (ctrl *ApplicationController) processRequestedAppOperation(app *appv1.Appli
|
|||
// cleanup (e.g. delete jobs, workflows, etc...)
|
||||
}
|
||||
}
|
||||
} else if state.Phase == synccommon.OperationFailed || state.Phase == synccommon.OperationError {
|
||||
case synccommon.OperationFailed, synccommon.OperationError:
|
||||
if !terminating && (state.RetryCount < state.Operation.Retry.Limit || state.Operation.Retry.Limit < 0) {
|
||||
now := metav1.Now()
|
||||
state.FinishedAt = &now
|
||||
|
|
@ -1597,8 +1598,8 @@ func (ctrl *ApplicationController) PatchAppWithWriteBack(ctx context.Context, na
|
|||
}
|
||||
|
||||
func (ctrl *ApplicationController) processAppRefreshQueueItem() (processNext bool) {
|
||||
patchMs := time.Duration(0) // time spent in doing patch/update calls
|
||||
setOpMs := time.Duration(0) // time spent in doing Operation patch calls in autosync
|
||||
patchDuration := time.Duration(0) // time spent in doing patch/update calls
|
||||
setOpDuration := time.Duration(0) // time spent in doing Operation patch calls in autosync
|
||||
appKey, shutdown := ctrl.appRefreshQueue.Get()
|
||||
if shutdown {
|
||||
processNext = false
|
||||
|
|
@ -1652,8 +1653,8 @@ func (ctrl *ApplicationController) processAppRefreshQueueItem() (processNext boo
|
|||
}
|
||||
logCtx.WithFields(log.Fields{
|
||||
"time_ms": reconcileDuration.Milliseconds(),
|
||||
"patch_ms": patchMs.Milliseconds(),
|
||||
"setop_ms": setOpMs.Milliseconds(),
|
||||
"patch_ms": patchDuration.Milliseconds(),
|
||||
"setop_ms": setOpDuration.Milliseconds(),
|
||||
}).Info("Reconciliation completed")
|
||||
}()
|
||||
|
||||
|
|
@ -1671,7 +1672,7 @@ func (ctrl *ApplicationController) processAppRefreshQueueItem() (processNext boo
|
|||
}
|
||||
}
|
||||
|
||||
patchMs = ctrl.persistAppStatus(origApp, &app.Status)
|
||||
patchDuration = ctrl.persistAppStatus(origApp, &app.Status)
|
||||
return
|
||||
}
|
||||
logCtx.Warnf("Failed to get cached managed resources for tree reconciliation, fall back to full reconciliation")
|
||||
|
|
@ -1686,7 +1687,7 @@ func (ctrl *ApplicationController) processAppRefreshQueueItem() (processNext boo
|
|||
app.Status.Sync.Status = appv1.SyncStatusCodeUnknown
|
||||
app.Status.Health.Status = health.HealthStatusUnknown
|
||||
app.Status.Health.LastTransitionTime = &now
|
||||
patchMs = ctrl.persistAppStatus(origApp, &app.Status)
|
||||
patchDuration = ctrl.persistAppStatus(origApp, &app.Status)
|
||||
|
||||
if err := ctrl.cache.SetAppResourcesTree(app.InstanceName(ctrl.namespace), &appv1.ApplicationTree{}); err != nil {
|
||||
logCtx.Warnf("failed to set app resource tree: %v", err)
|
||||
|
|
@ -1741,7 +1742,7 @@ func (ctrl *ApplicationController) processAppRefreshQueueItem() (processNext boo
|
|||
|
||||
ts.AddCheckpoint("compare_app_state_ms")
|
||||
|
||||
if stderrors.Is(err, CompareStateRepoError) {
|
||||
if stderrors.Is(err, ErrCompareStateRepo) {
|
||||
logCtx.Warnf("Ignoring temporary failed attempt to compare app state against repo: %v", err)
|
||||
return // short circuit if git error is encountered
|
||||
}
|
||||
|
|
@ -1763,8 +1764,8 @@ func (ctrl *ApplicationController) processAppRefreshQueueItem() (processNext boo
|
|||
|
||||
canSync, _ := project.Spec.SyncWindows.Matches(app).CanSync(false)
|
||||
if canSync {
|
||||
syncErrCond, opMS := ctrl.autoSync(app, compareResult.syncStatus, compareResult.resources, compareResult.revisionUpdated)
|
||||
setOpMs = opMS
|
||||
syncErrCond, opDuration := ctrl.autoSync(app, compareResult.syncStatus, compareResult.resources, compareResult.revisionUpdated)
|
||||
setOpDuration = opDuration
|
||||
if syncErrCond != nil {
|
||||
app.Status.SetConditions(
|
||||
[]appv1.ApplicationCondition{*syncErrCond},
|
||||
|
|
@ -1794,7 +1795,7 @@ func (ctrl *ApplicationController) processAppRefreshQueueItem() (processNext boo
|
|||
app.Status.SourceTypes = compareResult.appSourceTypes
|
||||
app.Status.ControllerNamespace = ctrl.namespace
|
||||
ts.AddCheckpoint("app_status_update_ms")
|
||||
patchMs = ctrl.persistAppStatus(origApp, &app.Status)
|
||||
patchDuration = ctrl.persistAppStatus(origApp, &app.Status)
|
||||
// This is a partly a duplicate of patch_ms, but more descriptive and allows to have measurement for the next step.
|
||||
ts.AddCheckpoint("persist_app_status_ms")
|
||||
if (compareResult.hasPostDeleteHooks != app.HasPostDeleteFinalizer() || compareResult.hasPostDeleteHooks != app.HasPostDeleteFinalizer("cleanup")) &&
|
||||
|
|
@ -2005,7 +2006,7 @@ func createMergePatch(orig, new any) ([]byte, bool, error) {
|
|||
}
|
||||
|
||||
// persistAppStatus persists updates to application status. If no changes were made, it is a no-op
|
||||
func (ctrl *ApplicationController) persistAppStatus(orig *appv1.Application, newStatus *appv1.ApplicationStatus) (patchMs time.Duration) {
|
||||
func (ctrl *ApplicationController) persistAppStatus(orig *appv1.Application, newStatus *appv1.ApplicationStatus) (patchDuration time.Duration) {
|
||||
logCtx := getAppLog(orig)
|
||||
if orig.Status.Sync.Status != newStatus.Sync.Status {
|
||||
message := fmt.Sprintf("Updated sync status: %s -> %s", orig.Status.Sync.Status, newStatus.Sync.Status)
|
||||
|
|
@ -2038,7 +2039,7 @@ func (ctrl *ApplicationController) persistAppStatus(orig *appv1.Application, new
|
|||
// calculate time for path call
|
||||
start := time.Now()
|
||||
defer func() {
|
||||
patchMs = time.Since(start)
|
||||
patchDuration = time.Since(start)
|
||||
}()
|
||||
_, err = ctrl.PatchAppWithWriteBack(context.Background(), orig.Name, orig.Namespace, types.MergePatchType, patch, metav1.PatchOptions{})
|
||||
if err != nil {
|
||||
|
|
@ -2046,7 +2047,7 @@ func (ctrl *ApplicationController) persistAppStatus(orig *appv1.Application, new
|
|||
} else {
|
||||
logCtx.Infof("Update successful")
|
||||
}
|
||||
return patchMs
|
||||
return patchDuration
|
||||
}
|
||||
|
||||
// autoSync will initiate a sync operation for an application configured with automated sync
|
||||
|
|
|
|||
|
|
@ -2375,7 +2375,7 @@ func TestAddControllerNamespace(t *testing.T) {
|
|||
appNamespace := "app-namespace"
|
||||
|
||||
app := newFakeApp()
|
||||
app.ObjectMeta.Namespace = appNamespace
|
||||
app.Namespace = appNamespace
|
||||
proj := defaultProj
|
||||
proj.Spec.SourceNamespaces = []string{appNamespace}
|
||||
ctrl := newFakeController(&fakeData{
|
||||
|
|
@ -2709,7 +2709,7 @@ func TestSyncTimeout(t *testing.T) {
|
|||
}
|
||||
ctrl.processRequestedAppOperation(app)
|
||||
|
||||
app, err := ctrl.applicationClientset.ArgoprojV1alpha1().Applications(app.ObjectMeta.Namespace).Get(t.Context(), app.ObjectMeta.Name, metav1.GetOptions{})
|
||||
app, err := ctrl.applicationClientset.ArgoprojV1alpha1().Applications(app.ObjectMeta.Namespace).Get(t.Context(), app.Name, metav1.GetOptions{})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, tc.expectedPhase, app.Status.OperationState.Phase)
|
||||
require.Equal(t, tc.expectedMessage, app.Status.OperationState.Message)
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ func (m *MetricsServer) HasExpiration() bool {
|
|||
// SetExpiration reset Prometheus metrics based on time duration interval
|
||||
func (m *MetricsServer) SetExpiration(cacheExpiration time.Duration) error {
|
||||
if m.HasExpiration() {
|
||||
return errors.New("Expiration is already set")
|
||||
return errors.New("expiration is already set")
|
||||
}
|
||||
|
||||
_, err := m.cron.AddFunc(fmt.Sprintf("@every %s", cacheExpiration), func() {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ import (
|
|||
"github.com/argoproj/argo-cd/v3/util/stats"
|
||||
)
|
||||
|
||||
var CompareStateRepoError = errors.New("failed to get repo objects")
|
||||
var ErrCompareStateRepo = errors.New("failed to get repo objects")
|
||||
|
||||
type resourceInfoProviderStub struct{}
|
||||
|
||||
|
|
@ -531,10 +531,7 @@ func (m *appStateManager) CompareAppState(app *v1alpha1.Application, project *v1
|
|||
}
|
||||
|
||||
// When signature keys are defined in the project spec, we need to verify the signature on the Git revision
|
||||
verifySignature := false
|
||||
if len(project.Spec.SignatureKeys) > 0 && gpg.IsGPGEnabled() {
|
||||
verifySignature = true
|
||||
}
|
||||
verifySignature := len(project.Spec.SignatureKeys) > 0 && gpg.IsGPGEnabled()
|
||||
|
||||
// do best effort loading live and target state to present as much information about app state as possible
|
||||
failedToLoadObjs := false
|
||||
|
|
@ -576,12 +573,12 @@ func (m *appStateManager) CompareAppState(app *v1alpha1.Application, project *v1
|
|||
// if first seen is less than grace period and it's not a Level 3 comparison,
|
||||
// ignore error and short circuit
|
||||
logCtx.Debugf("Ignoring repo error %v, already encountered error in grace period", err.Error())
|
||||
return nil, CompareStateRepoError
|
||||
return nil, ErrCompareStateRepo
|
||||
}
|
||||
} else if !noRevisionCache {
|
||||
logCtx.Debugf("Ignoring repo error %v, new occurrence", err.Error())
|
||||
m.repoErrorCache.Store(app.Name, time.Now())
|
||||
return nil, CompareStateRepoError
|
||||
return nil, ErrCompareStateRepo
|
||||
}
|
||||
failedToLoadObjs = true
|
||||
} else {
|
||||
|
|
@ -871,7 +868,7 @@ func (m *appStateManager) CompareAppState(app *v1alpha1.Application, project *v1
|
|||
resState.Status = v1alpha1.SyncStatusCodeOutOfSync
|
||||
// we ignore the status if the obj needs pruning AND we have the annotation
|
||||
needsPruning := targetObj == nil && liveObj != nil
|
||||
if !(needsPruning && resourceutil.HasAnnotationOption(obj, common.AnnotationCompareOptions, "IgnoreExtraneous")) {
|
||||
if !needsPruning || !resourceutil.HasAnnotationOption(obj, common.AnnotationCompareOptions, "IgnoreExtraneous") {
|
||||
syncCode = v1alpha1.SyncStatusCodeOutOfSync
|
||||
}
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -73,12 +73,12 @@ func TestCompareAppStateRepoError(t *testing.T) {
|
|||
revisions = append(revisions, "")
|
||||
compRes, err := ctrl.appStateManager.CompareAppState(app, &defaultProj, revisions, sources, false, false, nil, false, false)
|
||||
assert.Nil(t, compRes)
|
||||
require.EqualError(t, err, CompareStateRepoError.Error())
|
||||
require.EqualError(t, err, ErrCompareStateRepo.Error())
|
||||
|
||||
// expect to still get compare state error to as inside grace period
|
||||
compRes, err = ctrl.appStateManager.CompareAppState(app, &defaultProj, revisions, sources, false, false, nil, false, false)
|
||||
assert.Nil(t, compRes)
|
||||
require.EqualError(t, err, CompareStateRepoError.Error())
|
||||
require.EqualError(t, err, ErrCompareStateRepo.Error())
|
||||
|
||||
time.Sleep(10 * time.Second)
|
||||
// expect to not get error as outside of grace period, but status should be unknown
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ func (m *appStateManager) SyncAppState(app *v1alpha1.Application, state *v1alpha
|
|||
|
||||
// ignore error if CompareStateRepoError, this shouldn't happen as noRevisionCache is true
|
||||
compareResult, err := m.CompareAppState(app, proj, revisions, sources, false, true, syncOp.Manifests, isMultiSourceRevision, rollback)
|
||||
if err != nil && !stderrors.Is(err, CompareStateRepoError) {
|
||||
if err != nil && !stderrors.Is(err, ErrCompareStateRepo) {
|
||||
state.Phase = common.OperationError
|
||||
state.Message = err.Error()
|
||||
return
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@
|
|||
set -eux -o pipefail
|
||||
|
||||
# renovate: datasource=go packageName=github.com/golangci/golangci-lint
|
||||
GOLANGCI_LINT_VERSION=1.64.8
|
||||
GOLANGCI_LINT_VERSION=2.0.1
|
||||
|
||||
GO111MODULE=on go install "github.com/golangci/golangci-lint/cmd/golangci-lint@v${GOLANGCI_LINT_VERSION}"
|
||||
GO111MODULE=on go install "github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v${GOLANGCI_LINT_VERSION}"
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ func (c *notificationController) Init(ctx context.Context) error {
|
|||
go c.configMapInformer.Run(ctx.Done())
|
||||
|
||||
if !cache.WaitForCacheSync(ctx.Done(), c.appInformer.HasSynced, c.appProjInformer.HasSynced, c.secretInformer.HasSynced, c.configMapInformer.HasSynced) {
|
||||
return errors.New("Timed out waiting for caches to sync")
|
||||
return errors.New("timed out waiting for caches to sync")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ func TestInitTimeout(t *testing.T) {
|
|||
err = nc.Init(ctx)
|
||||
|
||||
// Expect an error & add assertion for the error message
|
||||
assert.EqualError(t, err, "Timed out waiting for caches to sync")
|
||||
assert.EqualError(t, err, "timed out waiting for caches to sync")
|
||||
}
|
||||
|
||||
func TestCheckAppNotInAdditionalNamespaces(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -221,6 +221,7 @@ func NewClient(opts *ClientOptions) (Client, error) {
|
|||
}
|
||||
// Make sure we got the server address and auth token from somewhere
|
||||
if c.ServerAddr == "" {
|
||||
//nolint:staticcheck // First letter of error is intentionally capitalized.
|
||||
return nil, errors.New("Argo CD server address unspecified")
|
||||
}
|
||||
// Override auth-token if specified in env variable or CLI flag
|
||||
|
|
@ -337,11 +338,11 @@ func (c *client) OIDCConfig(ctx context.Context, set *settingspkg.Settings) (*oa
|
|||
}
|
||||
provider, err := oidc.NewProvider(ctx, issuerURL)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("Failed to query provider %q: %w", issuerURL, err)
|
||||
return nil, nil, fmt.Errorf("failed to query provider %q: %w", issuerURL, err)
|
||||
}
|
||||
oidcConf, err := oidcutil.ParseConfig(provider)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("Failed to parse provider config: %w", err)
|
||||
return nil, nil, fmt.Errorf("failed to parse provider config: %w", err)
|
||||
}
|
||||
if oidcutil.OfflineAccess(oidcConf.ScopesSupported) {
|
||||
scopes = append(scopes, oidc.ScopeOfflineAccess)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ func Test_parseHeaders(t *testing.T) {
|
|||
headerString := []string{"foo:", "foo1:bar1", "foo2:bar2:bar2"}
|
||||
headers, err := parseHeaders(headerString)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "", headers.Get("foo"))
|
||||
assert.Empty(t, headers.Get("foo"))
|
||||
assert.Equal(t, "bar1", headers.Get("foo1"))
|
||||
assert.Equal(t, "bar2:bar2", headers.Get("foo2"))
|
||||
})
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ func (c *client) startGRPCProxy() (*grpc.Server, net.Listener, error) {
|
|||
grpc.UnknownServiceHandler(func(_ any, stream grpc.ServerStream) error {
|
||||
fullMethodName, ok := grpc.MethodFromServerStream(stream)
|
||||
if !ok {
|
||||
return errors.New("Unable to get method name from stream context.")
|
||||
return errors.New("unable to get method name from stream context")
|
||||
}
|
||||
msg := make([]byte, 0)
|
||||
err := stream.RecvMsg(&msg)
|
||||
|
|
|
|||
|
|
@ -366,11 +366,11 @@ func (proj *AppProject) normalizePolicy(policy string) string {
|
|||
func (proj *AppProject) ProjectPoliciesString() string {
|
||||
var policies []string
|
||||
for _, role := range proj.Spec.Roles {
|
||||
projectPolicy := fmt.Sprintf("p, proj:%s:%s, projects, get, %s, allow", proj.ObjectMeta.Name, role.Name, proj.ObjectMeta.Name)
|
||||
projectPolicy := fmt.Sprintf("p, proj:%s:%s, projects, get, %s, allow", proj.Name, role.Name, proj.Name)
|
||||
policies = append(policies, projectPolicy)
|
||||
policies = append(policies, role.Policies...)
|
||||
for _, groupName := range role.Groups {
|
||||
policies = append(policies, fmt.Sprintf("g, %s, proj:%s:%s", groupName, proj.ObjectMeta.Name, role.Name))
|
||||
policies = append(policies, fmt.Sprintf("g, %s, proj:%s:%s", groupName, proj.Name, role.Name))
|
||||
}
|
||||
}
|
||||
return strings.Join(policies, "\n")
|
||||
|
|
|
|||
|
|
@ -123,8 +123,8 @@ func TestApplicationSetSetConditions(t *testing.T) {
|
|||
validate: func(t *testing.T, a *ApplicationSet) {
|
||||
t.Helper()
|
||||
// SetConditions should add timestamps for new conditions.
|
||||
assert.True(t, a.Status.Conditions[0].LastTransitionTime.Time.After(fiveMinsAgo.Time))
|
||||
assert.True(t, a.Status.Conditions[1].LastTransitionTime.Time.After(fiveMinsAgo.Time))
|
||||
assert.True(t, a.Status.Conditions[0].LastTransitionTime.After(fiveMinsAgo.Time))
|
||||
assert.True(t, a.Status.Conditions[1].LastTransitionTime.After(fiveMinsAgo.Time))
|
||||
},
|
||||
}, {
|
||||
name: "condition cleared",
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ func (a *EnvEntry) IsZero() bool {
|
|||
func NewEnvEntry(text string) (*EnvEntry, error) {
|
||||
parts := strings.SplitN(text, "=", 2)
|
||||
if len(parts) != 2 {
|
||||
return nil, fmt.Errorf("Expected env entry of the form: param=value. Received: %s", text)
|
||||
return nil, fmt.Errorf("expected env entry of the form: param=value but received: %s", text)
|
||||
}
|
||||
return &EnvEntry{
|
||||
Name: parts[0],
|
||||
|
|
@ -542,7 +542,7 @@ var helmParameterRx = regexp.MustCompile(`([^\\]),`)
|
|||
func NewHelmParameter(text string, forceString bool) (*HelmParameter, error) {
|
||||
parts := strings.SplitN(text, "=", 2)
|
||||
if len(parts) != 2 {
|
||||
return nil, fmt.Errorf("Expected helm parameter of the form: param=value. Received: %s", text)
|
||||
return nil, fmt.Errorf("expected helm parameter of the form param=value but received: %s", text)
|
||||
}
|
||||
return &HelmParameter{
|
||||
Name: parts[0],
|
||||
|
|
@ -555,7 +555,7 @@ func NewHelmParameter(text string, forceString bool) (*HelmParameter, error) {
|
|||
func NewHelmFileParameter(text string) (*HelmFileParameter, error) {
|
||||
parts := strings.SplitN(text, "=", 2)
|
||||
if len(parts) != 2 {
|
||||
return nil, fmt.Errorf("Expected helm file parameter of the form: param=path. Received: %s", text)
|
||||
return nil, fmt.Errorf("expected helm file parameter of the form param=path but received: %s", text)
|
||||
}
|
||||
return &HelmFileParameter{
|
||||
Name: parts[0],
|
||||
|
|
@ -968,21 +968,21 @@ func (p ApplicationSourcePluginParameter) MarshalJSON() ([]byte, error) {
|
|||
out["string"] = p.String_
|
||||
}
|
||||
if p.OptionalMap != nil {
|
||||
if p.OptionalMap.Map == nil {
|
||||
if p.Map == nil {
|
||||
// Nil is not the same as a nil map. Nil means the field was not set, while a nil map means the field was set to an empty map.
|
||||
// Either way, we want to marshal it as "{}".
|
||||
out["map"] = map[string]string{}
|
||||
} else {
|
||||
out["map"] = p.OptionalMap.Map
|
||||
out["map"] = p.Map
|
||||
}
|
||||
}
|
||||
if p.OptionalArray != nil {
|
||||
if p.OptionalArray.Array == nil {
|
||||
if p.Array == nil {
|
||||
// Nil is not the same as a nil array. Nil means the field was not set, while a nil array means the field was set to an empty array.
|
||||
// Either way, we want to marshal it as "[]".
|
||||
out["array"] = []string{}
|
||||
} else {
|
||||
out["array"] = p.OptionalArray.Array
|
||||
out["array"] = p.Array
|
||||
}
|
||||
}
|
||||
bytes, err := json.Marshal(out)
|
||||
|
|
@ -1029,12 +1029,12 @@ func (p ApplicationSourcePluginParameters) Environ() ([]string, error) {
|
|||
env = append(env, fmt.Sprintf("%s=%s", envBaseName, *param.String_))
|
||||
}
|
||||
if param.OptionalMap != nil {
|
||||
for key, value := range param.OptionalMap.Map {
|
||||
for key, value := range param.Map {
|
||||
env = append(env, fmt.Sprintf("%s_%s=%s", envBaseName, escaped(key), value))
|
||||
}
|
||||
}
|
||||
if param.OptionalArray != nil {
|
||||
for i, value := range param.OptionalArray.Array {
|
||||
for i, value := range param.Array {
|
||||
env = append(env, fmt.Sprintf("%s_%d=%s", envBaseName, i, value))
|
||||
}
|
||||
}
|
||||
|
|
@ -3106,7 +3106,7 @@ type ApplicationDestinationServiceAccount struct {
|
|||
|
||||
// CascadedDeletion indicates if the deletion finalizer is set and controller should delete the application and it's cascaded resources
|
||||
func (app *Application) CascadedDeletion() bool {
|
||||
for _, finalizer := range app.ObjectMeta.Finalizers {
|
||||
for _, finalizer := range app.Finalizers {
|
||||
if isPropagationPolicyFinalizer(finalizer) {
|
||||
return true
|
||||
}
|
||||
|
|
@ -3194,7 +3194,7 @@ func isPropagationPolicyFinalizer(finalizer string) bool {
|
|||
|
||||
// GetPropagationPolicy returns the value of propagation policy finalizer
|
||||
func (app *Application) GetPropagationPolicy() string {
|
||||
for _, finalizer := range app.ObjectMeta.Finalizers {
|
||||
for _, finalizer := range app.Finalizers {
|
||||
if isPropagationPolicyFinalizer(finalizer) {
|
||||
return finalizer
|
||||
}
|
||||
|
|
@ -3439,7 +3439,7 @@ func ParseProxyUrl(proxyUrl string) (*url.URL, error) { //nolint:revive //FIXME(
|
|||
switch u.Scheme {
|
||||
case "http", "https", "socks5":
|
||||
default:
|
||||
return nil, fmt.Errorf("Failed to parse proxy url, unsupported scheme %q, must be http, https, or socks5", u.Scheme)
|
||||
return nil, fmt.Errorf("failed to parse proxy url, unsupported scheme %q, must be http, https, or socks5", u.Scheme)
|
||||
}
|
||||
return u, nil
|
||||
}
|
||||
|
|
@ -3474,11 +3474,11 @@ func (c *Cluster) RawRestConfig() (*rest.Config, error) {
|
|||
}
|
||||
default:
|
||||
tlsClientConfig := rest.TLSClientConfig{
|
||||
Insecure: c.Config.TLSClientConfig.Insecure,
|
||||
ServerName: c.Config.TLSClientConfig.ServerName,
|
||||
CertData: c.Config.TLSClientConfig.CertData,
|
||||
KeyData: c.Config.TLSClientConfig.KeyData,
|
||||
CAData: c.Config.TLSClientConfig.CAData,
|
||||
Insecure: c.Config.Insecure,
|
||||
ServerName: c.Config.ServerName,
|
||||
CertData: c.Config.CertData,
|
||||
KeyData: c.Config.KeyData,
|
||||
CAData: c.Config.CAData,
|
||||
}
|
||||
switch {
|
||||
case c.Config.AWSAuthConfig != nil:
|
||||
|
|
@ -3532,12 +3532,12 @@ func (c *Cluster) RawRestConfig() (*rest.Config, error) {
|
|||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to create K8s REST config: %w", err)
|
||||
return nil, fmt.Errorf("unable to create K8s REST config: %w", err)
|
||||
}
|
||||
if c.Config.ProxyUrl != "" {
|
||||
u, err := ParseProxyUrl(c.Config.ProxyUrl)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to create K8s REST config, can`t parse proxy url: %w", err)
|
||||
return nil, fmt.Errorf("unable to create K8s REST config, can`t parse proxy url: %w", err)
|
||||
}
|
||||
config.Proxy = http.ProxyURL(u)
|
||||
}
|
||||
|
|
@ -3552,11 +3552,11 @@ func (c *Cluster) RawRestConfig() (*rest.Config, error) {
|
|||
func (c *Cluster) RESTConfig() (*rest.Config, error) {
|
||||
config, err := c.RawRestConfig()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to get K8s RAW REST config: %w", err)
|
||||
return nil, fmt.Errorf("unable to get K8s RAW REST config: %w", err)
|
||||
}
|
||||
err = SetK8SConfigDefaults(config)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to apply K8s REST config defaults: %w", err)
|
||||
return nil, fmt.Errorf("unable to apply K8s REST config defaults: %w", err)
|
||||
}
|
||||
return config, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1492,7 +1492,7 @@ func TestApplicationSourceHelm_AddFileParameter(t *testing.T) {
|
|||
func TestNewHelmParameter(t *testing.T) {
|
||||
t.Run("Invalid", func(t *testing.T) {
|
||||
_, err := NewHelmParameter("garbage", false)
|
||||
require.EqualError(t, err, "Expected helm parameter of the form: param=value. Received: garbage")
|
||||
require.EqualError(t, err, "expected helm parameter of the form param=value but received: garbage")
|
||||
})
|
||||
t.Run("NonString", func(t *testing.T) {
|
||||
p, err := NewHelmParameter("foo=bar", false)
|
||||
|
|
@ -1729,12 +1729,12 @@ func TestEnv_IsZero(t *testing.T) {
|
|||
|
||||
func TestEnv_Envsubst(t *testing.T) {
|
||||
env := Env{&EnvEntry{"FOO", "bar"}}
|
||||
assert.Equal(t, "", env.Envsubst(""))
|
||||
assert.Empty(t, env.Envsubst(""))
|
||||
assert.Equal(t, "bar", env.Envsubst("$FOO"))
|
||||
assert.Equal(t, "bar", env.Envsubst("${FOO}"))
|
||||
assert.Equal(t, "FOO", env.Envsubst("${FOO"))
|
||||
assert.Equal(t, "", env.Envsubst("$BAR"))
|
||||
assert.Equal(t, "", env.Envsubst("${BAR}"))
|
||||
assert.Empty(t, env.Envsubst("$BAR"))
|
||||
assert.Empty(t, env.Envsubst("${BAR}"))
|
||||
assert.Equal(t,
|
||||
"echo bar; echo ; echo bar; echo ; echo FOO",
|
||||
env.Envsubst("echo $FOO; echo $BAR; echo ${FOO}; echo ${BAR}; echo ${FOO"),
|
||||
|
|
@ -3045,7 +3045,7 @@ func TestApplicationStatus_GetConditions(t *testing.T) {
|
|||
conditions := status.GetConditions(map[ApplicationConditionType]bool{
|
||||
ApplicationConditionInvalidSpecError: true,
|
||||
})
|
||||
assert.EqualValues(t, []ApplicationCondition{{Type: ApplicationConditionInvalidSpecError}}, conditions)
|
||||
assert.Equal(t, []ApplicationCondition{{Type: ApplicationConditionInvalidSpecError}}, conditions)
|
||||
}
|
||||
|
||||
type projectBuilder struct {
|
||||
|
|
@ -3206,8 +3206,8 @@ func TestSetConditions(t *testing.T) {
|
|||
validate: func(t *testing.T, a *Application) {
|
||||
t.Helper()
|
||||
// SetConditions should add timestamps for new conditions.
|
||||
assert.True(t, a.Status.Conditions[0].LastTransitionTime.Time.After(fiveMinsAgo.Time))
|
||||
assert.True(t, a.Status.Conditions[1].LastTransitionTime.Time.After(fiveMinsAgo.Time))
|
||||
assert.True(t, a.Status.Conditions[0].LastTransitionTime.After(fiveMinsAgo.Time))
|
||||
assert.True(t, a.Status.Conditions[1].LastTransitionTime.After(fiveMinsAgo.Time))
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -4487,7 +4487,7 @@ func TestCluster_ParseProxyUrl(t *testing.T) {
|
|||
},
|
||||
{
|
||||
url: "test://!abc",
|
||||
expectedErrMsg: "Failed to parse proxy url, unsupported scheme \"test\", must be http, https, or socks5",
|
||||
expectedErrMsg: "failed to parse proxy url, unsupported scheme \"test\", must be http, https, or socks5",
|
||||
},
|
||||
{
|
||||
url: "http://192.168.99.100:8443",
|
||||
|
|
|
|||
6
reposerver/cache/cache.go
vendored
6
reposerver/cache/cache.go
vendored
|
|
@ -341,7 +341,7 @@ func (c *Cache) GetManifests(revision string, appSrc *appv1.ApplicationSource, s
|
|||
|
||||
hash, err := res.generateCacheEntryHash()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to generate hash value: %w", err)
|
||||
return fmt.Errorf("unable to generate hash value: %w", err)
|
||||
}
|
||||
|
||||
// If cached result does not have manifests or the expected hash of the cache entry does not match the actual hash value...
|
||||
|
|
@ -352,7 +352,7 @@ func (c *Cache) GetManifests(revision string, appSrc *appv1.ApplicationSource, s
|
|||
|
||||
err = c.DeleteManifests(revision, appSrc, srcRefs, clusterInfo, namespace, trackingMethod, appLabelKey, appName, refSourceCommitSHAs, installationID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to delete manifest after hash mismatch, %w", err)
|
||||
return fmt.Errorf("unable to delete manifest after hash mismatch: %w", err)
|
||||
}
|
||||
|
||||
// Treat hash mismatches as cache misses, so that the underlying resource is reacquired
|
||||
|
|
@ -376,7 +376,7 @@ func (c *Cache) SetManifests(revision string, appSrc *appv1.ApplicationSource, s
|
|||
res = res.shallowCopy()
|
||||
hash, err := res.generateCacheEntryHash()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to generate hash value: %w", err)
|
||||
return fmt.Errorf("unable to generate hash value: %w", err)
|
||||
}
|
||||
res.CacheEntryHash = hash
|
||||
}
|
||||
|
|
|
|||
22
reposerver/cache/cache_test.go
vendored
22
reposerver/cache/cache_test.go
vendored
|
|
@ -335,7 +335,7 @@ func TestGetGitReferences(t *testing.T) {
|
|||
var references []*plumbing.Reference
|
||||
lockOwner, err := cache.GetGitReferences("test-repo", &references)
|
||||
require.NoError(t, err, "Error is cache miss handled inside function")
|
||||
assert.Equal(t, "", lockOwner, "Lock owner should be empty")
|
||||
assert.Empty(t, lockOwner, "Lock owner should be empty")
|
||||
assert.Nil(t, references)
|
||||
fixtures.mockCache.AssertCacheCalledTimes(t, &mocks.CacheCallCounts{ExternalGets: 1})
|
||||
})
|
||||
|
|
@ -347,7 +347,7 @@ func TestGetGitReferences(t *testing.T) {
|
|||
var references []*plumbing.Reference
|
||||
lockOwner, err := cache.GetGitReferences("test-repo", &references)
|
||||
require.NoError(t, err, "Error is cache miss handled inside function")
|
||||
assert.Equal(t, "", lockOwner, "Lock owner should be empty")
|
||||
assert.Empty(t, lockOwner, "Lock owner should be empty")
|
||||
assert.Nil(t, references)
|
||||
fixtures.mockCache.AssertCacheCalledTimes(t, &mocks.CacheCallCounts{ExternalGets: 1})
|
||||
})
|
||||
|
|
@ -361,7 +361,7 @@ func TestGetGitReferences(t *testing.T) {
|
|||
var references []*plumbing.Reference
|
||||
lockOwner, err := cache.GetGitReferences("test-repo", &references)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "", lockOwner, "Lock owner should be empty")
|
||||
assert.Empty(t, lockOwner, "Lock owner should be empty")
|
||||
assert.Len(t, references, 1)
|
||||
assert.Equal(t, "test", (references)[0].Target().String())
|
||||
assert.Equal(t, "test-repo", (references)[0].Name().String())
|
||||
|
|
@ -377,7 +377,7 @@ func TestGetGitReferences(t *testing.T) {
|
|||
var references []*plumbing.Reference
|
||||
lockOwner, err := cache.GetGitReferences("test-repo", &references)
|
||||
require.ErrorContains(t, err, "test cache error", "Error should be propagated")
|
||||
assert.Equal(t, "", lockOwner, "Lock owner should be empty")
|
||||
assert.Empty(t, lockOwner, "Lock owner should be empty")
|
||||
assert.Nil(t, references)
|
||||
fixtures.mockCache.AssertCacheCalledTimes(t, &mocks.CacheCallCounts{ExternalGets: 1})
|
||||
})
|
||||
|
|
@ -455,7 +455,7 @@ func TestGetOrLockGitReferences(t *testing.T) {
|
|||
lockId, err := cache.GetOrLockGitReferences("test-repo", "test-lock-id", &references)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "test-lock-id", lockId)
|
||||
assert.NotEqual(t, "", lockId, "Lock id should be set")
|
||||
assert.NotEmpty(t, lockId, "Lock id should be set")
|
||||
fixtures.mockCache.AssertCacheCalledTimes(t, &mocks.CacheCallCounts{ExternalSets: 1, ExternalGets: 2})
|
||||
})
|
||||
|
||||
|
|
@ -469,7 +469,7 @@ func TestGetOrLockGitReferences(t *testing.T) {
|
|||
lockId, err := cache.GetOrLockGitReferences("test-repo", "test-lock-id", &references)
|
||||
require.NoError(t, err)
|
||||
assert.NotEqual(t, "test-lock-id", lockId)
|
||||
assert.Equal(t, "", lockId, "Lock id should not be set")
|
||||
assert.Empty(t, lockId, "Lock id should not be set")
|
||||
assert.Equal(t, "test-repo", references[0].Name().String())
|
||||
assert.Equal(t, "test", references[0].Target().String())
|
||||
fixtures.mockCache.AssertCacheCalledTimes(t, &mocks.CacheCallCounts{ExternalSets: 1, ExternalGets: 1})
|
||||
|
|
@ -490,7 +490,7 @@ func TestGetOrLockGitReferences(t *testing.T) {
|
|||
lockId, err := cache.GetOrLockGitReferences("test-repo", "test-lock-id", &references)
|
||||
require.NoError(t, err)
|
||||
assert.NotEqual(t, "test-lock-id", lockId)
|
||||
assert.Equal(t, "", lockId, "Lock id should not be set")
|
||||
assert.Empty(t, lockId, "Lock id should not be set")
|
||||
assert.Equal(t, "test-repo", references[0].Name().String())
|
||||
assert.Equal(t, "test", references[0].Target().String())
|
||||
fixtures.mockCache.AssertCacheCalledTimes(t, &mocks.CacheCallCounts{ExternalSets: 1, ExternalGets: 1})
|
||||
|
|
@ -511,7 +511,7 @@ func TestGetOrLockGitReferences(t *testing.T) {
|
|||
lockId, err := cache.GetOrLockGitReferences("test-repo", "test-lock-id", &references)
|
||||
require.NoError(t, err)
|
||||
assert.NotEqual(t, "test-lock-id", lockId)
|
||||
assert.Equal(t, "", lockId, "Lock id should not be set")
|
||||
assert.Empty(t, lockId, "Lock id should not be set")
|
||||
fixtures.mockCache.AssertCacheCalledTimes(t, &mocks.CacheCallCounts{ExternalSets: 2, ExternalGets: 2})
|
||||
})
|
||||
|
||||
|
|
@ -527,7 +527,7 @@ func TestGetOrLockGitReferences(t *testing.T) {
|
|||
lockId, err := cache.GetOrLockGitReferences("test-repo", "test-lock-id", &references)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "test-lock-id", lockId)
|
||||
assert.NotEqual(t, "", lockId, "Lock id should be set")
|
||||
assert.NotEmpty(t, lockId, "Lock id should be set")
|
||||
cache.revisionCacheLockTimeout = 10 * time.Second
|
||||
fixtures.mockCache.AssertCacheCalledTimes(t, &mocks.CacheCallCounts{ExternalSets: 1})
|
||||
})
|
||||
|
|
@ -544,7 +544,7 @@ func TestGetOrLockGitReferences(t *testing.T) {
|
|||
lockId, err := cache.GetOrLockGitReferences("test-repo", "test-lock-id", &references)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "test-lock-id", lockId)
|
||||
assert.NotEqual(t, "", lockId, "Lock id should be set")
|
||||
assert.NotEmpty(t, lockId, "Lock id should be set")
|
||||
fixtures.mockCache.RedisClient.AssertNumberOfCalls(t, "Set", 2)
|
||||
fixtures.mockCache.RedisClient.AssertNumberOfCalls(t, "Get", 4)
|
||||
})
|
||||
|
|
@ -566,7 +566,7 @@ func TestUnlockGitReferences(t *testing.T) {
|
|||
lockId, err := cache.GetOrLockGitReferences("test-repo", "test-lock-id", &references)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "test-lock-id", lockId)
|
||||
assert.NotEqual(t, "", lockId, "Lock id should be set")
|
||||
assert.NotEmpty(t, lockId, "Lock id should be set")
|
||||
// Release lock
|
||||
err = cache.UnlockGitReferences("test-repo", lockId)
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -86,5 +86,5 @@ func StartGPGWatcher(sourcePath string) error {
|
|||
return fmt.Errorf("failed to add a new source to the watcher: %w", err)
|
||||
}
|
||||
<-done
|
||||
return errors.New("Abnormal termination of GPG watcher, refusing to continue.")
|
||||
return errors.New("abnormal termination of GPG watcher, refusing to continue")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ version: 0.0.0`
|
|||
|
||||
cd, err := getChartDetails(chart1)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "", cd.Description)
|
||||
assert.Empty(t, cd.Description)
|
||||
assert.Equal(t, cd.Maintainers, []string(nil))
|
||||
assert.Equal(t, "", cd.Home)
|
||||
assert.Empty(t, cd.Home)
|
||||
}
|
||||
|
||||
func Test_getChartDetailsSet(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -920,6 +920,7 @@ func (s *Service) getManifestCacheEntry(cacheKey string, q *apiclient.ManifestRe
|
|||
// Otherwise, manifest generation is still paused
|
||||
log.Infof("manifest error cache hit: %s/%s", q.ApplicationSource.String(), cacheKey)
|
||||
|
||||
// nolint:staticcheck // Error message constant is very old, best not to lowercase the first letter.
|
||||
cachedErrorResponse := fmt.Errorf(cachedManifestGenerationPrefix+": %s", res.MostRecentError)
|
||||
|
||||
if firstInvocation {
|
||||
|
|
@ -2263,7 +2264,7 @@ func populatePluginAppDetails(ctx context.Context, res *apiclient.RepoAppDetails
|
|||
}
|
||||
|
||||
func (s *Service) GetRevisionMetadata(_ context.Context, q *apiclient.RepoServerRevisionMetadataRequest) (*v1alpha1.RevisionMetadata, error) {
|
||||
if !(git.IsCommitSHA(q.Revision) || git.IsTruncatedCommitSHA(q.Revision)) {
|
||||
if !git.IsCommitSHA(q.Revision) && !git.IsTruncatedCommitSHA(q.Revision) {
|
||||
return nil, fmt.Errorf("revision %s must be resolved", q.Revision)
|
||||
}
|
||||
metadata, err := s.cache.GetRevisionMetadata(q.Repo.Repo, q.Revision)
|
||||
|
|
|
|||
|
|
@ -1595,7 +1595,7 @@ func TestGetAppDetailsHelm(t *testing.T) {
|
|||
assert.NotNil(t, res.Helm)
|
||||
|
||||
assert.Equal(t, "Helm", res.Type)
|
||||
assert.EqualValues(t, []string{"values-production.yaml", "values.yaml"}, res.Helm.ValueFiles)
|
||||
assert.Equal(t, []string{"values-production.yaml", "values.yaml"}, res.Helm.ValueFiles)
|
||||
}
|
||||
|
||||
func TestGetAppDetailsHelmUsesCache(t *testing.T) {
|
||||
|
|
@ -1612,7 +1612,7 @@ func TestGetAppDetailsHelmUsesCache(t *testing.T) {
|
|||
assert.NotNil(t, res.Helm)
|
||||
|
||||
assert.Equal(t, "Helm", res.Type)
|
||||
assert.EqualValues(t, []string{"values-production.yaml", "values.yaml"}, res.Helm.ValueFiles)
|
||||
assert.Equal(t, []string{"values-production.yaml", "values.yaml"}, res.Helm.ValueFiles)
|
||||
}
|
||||
|
||||
func TestGetAppDetailsHelm_WithNoValuesFile(t *testing.T) {
|
||||
|
|
@ -1630,7 +1630,7 @@ func TestGetAppDetailsHelm_WithNoValuesFile(t *testing.T) {
|
|||
|
||||
assert.Equal(t, "Helm", res.Type)
|
||||
assert.Empty(t, res.Helm.ValueFiles)
|
||||
assert.Equal(t, "", res.Helm.Values)
|
||||
assert.Empty(t, res.Helm.Values)
|
||||
}
|
||||
|
||||
func TestGetAppDetailsKustomize(t *testing.T) {
|
||||
|
|
@ -1647,7 +1647,7 @@ func TestGetAppDetailsKustomize(t *testing.T) {
|
|||
|
||||
assert.Equal(t, "Kustomize", res.Type)
|
||||
assert.NotNil(t, res.Kustomize)
|
||||
assert.EqualValues(t, []string{"nginx:1.15.4", "registry.k8s.io/nginx-slim:0.8"}, res.Kustomize.Images)
|
||||
assert.Equal(t, []string{"nginx:1.15.4", "registry.k8s.io/nginx-slim:0.8"}, res.Kustomize.Images)
|
||||
}
|
||||
|
||||
func TestGetHelmCharts(t *testing.T) {
|
||||
|
|
@ -1664,11 +1664,11 @@ func TestGetHelmCharts(t *testing.T) {
|
|||
|
||||
item := res.Items[0]
|
||||
assert.Equal(t, "my-chart", item.Name)
|
||||
assert.EqualValues(t, []string{"1.0.0", "1.1.0"}, item.Versions)
|
||||
assert.Equal(t, []string{"1.0.0", "1.1.0"}, item.Versions)
|
||||
|
||||
item2 := res.Items[1]
|
||||
assert.Equal(t, "out-of-bounds-chart", item2.Name)
|
||||
assert.EqualValues(t, []string{"1.0.0", "1.1.0"}, item2.Versions)
|
||||
assert.Equal(t, []string{"1.0.0", "1.1.0"}, item2.Versions)
|
||||
}
|
||||
|
||||
func TestGetRevisionMetadata(t *testing.T) {
|
||||
|
|
@ -1692,7 +1692,7 @@ func TestGetRevisionMetadata(t *testing.T) {
|
|||
assert.Equal(t, "test", res.Message)
|
||||
assert.Equal(t, now, res.Date.Time)
|
||||
assert.Equal(t, "author", res.Author)
|
||||
assert.EqualValues(t, []string{"tag1", "tag2"}, res.Tags)
|
||||
assert.Equal(t, []string{"tag1", "tag2"}, res.Tags)
|
||||
assert.NotEmpty(t, res.SignatureInfo)
|
||||
|
||||
// Check for truncated revision value
|
||||
|
|
@ -1706,7 +1706,7 @@ func TestGetRevisionMetadata(t *testing.T) {
|
|||
assert.Equal(t, "test", res.Message)
|
||||
assert.Equal(t, now, res.Date.Time)
|
||||
assert.Equal(t, "author", res.Author)
|
||||
assert.EqualValues(t, []string{"tag1", "tag2"}, res.Tags)
|
||||
assert.Equal(t, []string{"tag1", "tag2"}, res.Tags)
|
||||
assert.NotEmpty(t, res.SignatureInfo)
|
||||
|
||||
// Cache hit - signature info should not be in result
|
||||
|
|
@ -1847,7 +1847,7 @@ func TestGetAppDetailsWithAppParameterFile(t *testing.T) {
|
|||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, []string{"gcr.io/heptio-images/ks-guestbook-demo:0.2"}, details.Kustomize.Images)
|
||||
assert.Equal(t, []string{"gcr.io/heptio-images/ks-guestbook-demo:0.2"}, details.Kustomize.Images)
|
||||
})
|
||||
})
|
||||
t.Run("No app specific override", func(t *testing.T) {
|
||||
|
|
@ -1862,7 +1862,7 @@ func TestGetAppDetailsWithAppParameterFile(t *testing.T) {
|
|||
AppName: "testapp",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, []string{"gcr.io/heptio-images/ks-guestbook-demo:0.2"}, details.Kustomize.Images)
|
||||
assert.Equal(t, []string{"gcr.io/heptio-images/ks-guestbook-demo:0.2"}, details.Kustomize.Images)
|
||||
})
|
||||
})
|
||||
t.Run("Only app specific override", func(t *testing.T) {
|
||||
|
|
@ -1877,7 +1877,7 @@ func TestGetAppDetailsWithAppParameterFile(t *testing.T) {
|
|||
AppName: "testapp",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, []string{"gcr.io/heptio-images/ks-guestbook-demo:0.3"}, details.Kustomize.Images)
|
||||
assert.Equal(t, []string{"gcr.io/heptio-images/ks-guestbook-demo:0.3"}, details.Kustomize.Images)
|
||||
})
|
||||
})
|
||||
t.Run("App specific override", func(t *testing.T) {
|
||||
|
|
@ -1892,7 +1892,7 @@ func TestGetAppDetailsWithAppParameterFile(t *testing.T) {
|
|||
AppName: "testapp",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, []string{"gcr.io/heptio-images/ks-guestbook-demo:0.3"}, details.Kustomize.Images)
|
||||
assert.Equal(t, []string{"gcr.io/heptio-images/ks-guestbook-demo:0.3"}, details.Kustomize.Images)
|
||||
})
|
||||
})
|
||||
t.Run("App specific overrides containing non-mergeable field", func(t *testing.T) {
|
||||
|
|
@ -1907,7 +1907,7 @@ func TestGetAppDetailsWithAppParameterFile(t *testing.T) {
|
|||
AppName: "unmergeable",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, []string{"gcr.io/heptio-images/ks-guestbook-demo:0.3"}, details.Kustomize.Images)
|
||||
assert.Equal(t, []string{"gcr.io/heptio-images/ks-guestbook-demo:0.3"}, details.Kustomize.Images)
|
||||
})
|
||||
})
|
||||
t.Run("Broken app-specific overrides", func(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ func (s *Server) UpdatePassword(ctx context.Context, q *account.UpdatePasswordRe
|
|||
return nil, fmt.Errorf("failed to get issue time: %w", err)
|
||||
}
|
||||
if time.Since(iat) > common.ChangePasswordSSOTokenMaxAge {
|
||||
return nil, errors.New("SSO token is too old. Please use 'argocd relogin' to get a new token.")
|
||||
return nil, errors.New("SSO token is too old. Please use 'argocd relogin' to get a new token")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ func (s *Server) UpdatePassword(ctx context.Context, q *account.UpdatePasswordRe
|
|||
}
|
||||
|
||||
if !validPasswordRegexp.Match([]byte(q.NewPassword)) {
|
||||
err := fmt.Errorf("New password does not match the following expression: %s.", passwordPattern)
|
||||
err := fmt.Errorf("new password does not match the following expression: %s", passwordPattern)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -316,7 +316,7 @@ func TestCanI_GetLogsAllow(t *testing.T) {
|
|||
ctx := projTokenContext(t.Context())
|
||||
resp, err := accountServer.CanI(ctx, &account.CanIRequest{Resource: "logs", Action: "get", Subresource: ""})
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, "yes", resp.Value)
|
||||
assert.Equal(t, "yes", resp.Value)
|
||||
}
|
||||
|
||||
func TestCanI_GetLogsDeny(t *testing.T) {
|
||||
|
|
@ -330,5 +330,5 @@ func TestCanI_GetLogsDeny(t *testing.T) {
|
|||
ctx := projTokenContext(t.Context())
|
||||
resp, err := accountServer.CanI(ctx, &account.CanIRequest{Resource: "logs", Action: "get", Subresource: "*/*"})
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, "no", resp.Value)
|
||||
assert.Equal(t, "no", resp.Value)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -851,7 +851,7 @@ func (s *Server) ListResourceEvents(ctx context.Context, q *application.Applicat
|
|||
}
|
||||
found := false
|
||||
for _, n := range append(tree.Nodes, tree.OrphanedNodes...) {
|
||||
if n.ResourceRef.UID == q.GetResourceUID() && n.ResourceRef.Name == q.GetResourceName() && n.ResourceRef.Namespace == q.GetResourceNamespace() {
|
||||
if n.UID == q.GetResourceUID() && n.Name == q.GetResourceName() && n.Namespace == q.GetResourceNamespace() {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
|
|
@ -1382,7 +1382,7 @@ func (s *Server) getAppLiveResource(ctx context.Context, action string, q *appli
|
|||
}
|
||||
|
||||
found := tree.FindNode(q.GetGroup(), q.GetKind(), q.GetNamespace(), q.GetResourceName())
|
||||
if found == nil || found.ResourceRef.UID == "" {
|
||||
if found == nil || found.UID == "" {
|
||||
return nil, nil, nil, status.Errorf(codes.InvalidArgument, "%s %s %s not found as part of application %s", q.GetKind(), q.GetGroup(), q.GetResourceName(), q.GetName())
|
||||
}
|
||||
config, err := s.getApplicationClusterConfig(ctx, a)
|
||||
|
|
@ -2671,7 +2671,7 @@ func (s *Server) inferResourcesStatusHealth(app *v1alpha1.Application) {
|
|||
for _, node := range tree.Nodes {
|
||||
if node.Health != nil {
|
||||
healthByKey[kube.NewResourceKey(node.Group, node.Kind, node.Namespace, node.Name)] = node.Health
|
||||
} else if node.ResourceVersion == "" && node.ResourceRef.UID == "" && node.CreatedAt == nil {
|
||||
} else if node.ResourceVersion == "" && node.UID == "" && node.CreatedAt == nil {
|
||||
healthByKey[kube.NewResourceKey(node.Group, node.Kind, node.Namespace, node.Name)] = &v1alpha1.HealthStatus{
|
||||
Status: health.HealthStatusMissing,
|
||||
Message: "Resource has not been created",
|
||||
|
|
|
|||
|
|
@ -1107,15 +1107,15 @@ func unsetSyncRunningOperationState(t *testing.T, appServer *Server) {
|
|||
func TestListAppsInNamespaceWithLabels(t *testing.T) {
|
||||
appServer := newTestAppServer(t, newTestApp(func(app *v1alpha1.Application) {
|
||||
app.Name = "App1"
|
||||
app.ObjectMeta.Namespace = "test-namespace"
|
||||
app.Namespace = "test-namespace"
|
||||
app.SetLabels(map[string]string{"key1": "value1", "key2": "value1"})
|
||||
}), newTestApp(func(app *v1alpha1.Application) {
|
||||
app.Name = "App2"
|
||||
app.ObjectMeta.Namespace = "test-namespace"
|
||||
app.Namespace = "test-namespace"
|
||||
app.SetLabels(map[string]string{"key1": "value2"})
|
||||
}), newTestApp(func(app *v1alpha1.Application) {
|
||||
app.Name = "App3"
|
||||
app.ObjectMeta.Namespace = "test-namespace"
|
||||
app.Namespace = "test-namespace"
|
||||
app.SetLabels(map[string]string{"key1": "value3"})
|
||||
}))
|
||||
appServer.ns = "test-namespace"
|
||||
|
|
@ -2062,7 +2062,7 @@ func TestServer_GetApplicationSyncWindowsState(t *testing.T) {
|
|||
|
||||
func TestGetCachedAppState(t *testing.T) {
|
||||
testApp := newTestApp()
|
||||
testApp.ObjectMeta.ResourceVersion = "1"
|
||||
testApp.ResourceVersion = "1"
|
||||
testApp.Spec.Project = "test-proj"
|
||||
testProj := &v1alpha1.AppProject{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
@ -2349,7 +2349,7 @@ func TestGetAppRefresh_NormalRefresh(t *testing.T) {
|
|||
ctx, cancel := context.WithCancel(t.Context())
|
||||
defer cancel()
|
||||
testApp := newTestApp()
|
||||
testApp.ObjectMeta.ResourceVersion = "1"
|
||||
testApp.ResourceVersion = "1"
|
||||
appServer := newTestAppServer(t, testApp)
|
||||
|
||||
var patched int32
|
||||
|
|
@ -2376,7 +2376,7 @@ func TestGetAppRefresh_HardRefresh(t *testing.T) {
|
|||
ctx, cancel := context.WithCancel(t.Context())
|
||||
defer cancel()
|
||||
testApp := newTestApp()
|
||||
testApp.ObjectMeta.ResourceVersion = "1"
|
||||
testApp.ResourceVersion = "1"
|
||||
appServer := newTestAppServer(t, testApp)
|
||||
|
||||
var getAppDetailsQuery *apiclient.RepoServerAppDetailsQuery
|
||||
|
|
@ -3055,8 +3055,8 @@ func TestServer_ResolveSourceRevisions_MultiSource(t *testing.T) {
|
|||
revision, displayRevision, sourceRevisions, displayRevisions, err := s.resolveSourceRevisions(ctx, a, syncReq)
|
||||
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "", revision)
|
||||
assert.Equal(t, "", displayRevision)
|
||||
assert.Empty(t, revision)
|
||||
assert.Empty(t, displayRevision)
|
||||
assert.Equal(t, []string{fakeResolveRevisionResponse().Revision}, sourceRevisions)
|
||||
assert.Equal(t, []string{fakeResolveRevisionResponse().AmbiguousRevision}, displayRevisions)
|
||||
}
|
||||
|
|
@ -3359,17 +3359,17 @@ func Test_DeepCopyInformers(t *testing.T) {
|
|||
var ro []runtime.Object
|
||||
appOne := newTestApp(func(app *v1alpha1.Application) {
|
||||
app.Name = "appOne"
|
||||
app.ObjectMeta.Namespace = namespace
|
||||
app.Namespace = namespace
|
||||
app.Spec = v1alpha1.ApplicationSpec{}
|
||||
})
|
||||
appTwo := newTestApp(func(app *v1alpha1.Application) {
|
||||
app.Name = "appTwo"
|
||||
app.ObjectMeta.Namespace = namespace
|
||||
app.Namespace = namespace
|
||||
app.Spec = v1alpha1.ApplicationSpec{}
|
||||
})
|
||||
appThree := newTestApp(func(app *v1alpha1.Application) {
|
||||
app.Name = "appThree"
|
||||
app.ObjectMeta.Namespace = namespace
|
||||
app.Namespace = namespace
|
||||
app.Spec = v1alpha1.ApplicationSpec{}
|
||||
})
|
||||
ro = append(ro, appOne, appTwo, appThree)
|
||||
|
|
|
|||
|
|
@ -277,15 +277,15 @@ func TestListAppSetsInNamespaceWithLabels(t *testing.T) {
|
|||
testNamespace := "test-namespace"
|
||||
appSetServer := newTestAppSetServer(t, newTestAppSet(func(appset *appsv1.ApplicationSet) {
|
||||
appset.Name = "AppSet1"
|
||||
appset.ObjectMeta.Namespace = testNamespace
|
||||
appset.Namespace = testNamespace
|
||||
appset.SetLabels(map[string]string{"key1": "value1", "key2": "value1"})
|
||||
}), newTestAppSet(func(appset *appsv1.ApplicationSet) {
|
||||
appset.Name = "AppSet2"
|
||||
appset.ObjectMeta.Namespace = testNamespace
|
||||
appset.Namespace = testNamespace
|
||||
appset.SetLabels(map[string]string{"key1": "value2"})
|
||||
}), newTestAppSet(func(appset *appsv1.ApplicationSet) {
|
||||
appset.Name = "AppSet3"
|
||||
appset.ObjectMeta.Namespace = testNamespace
|
||||
appset.Namespace = testNamespace
|
||||
appset.SetLabels(map[string]string{"key1": "value3"})
|
||||
}))
|
||||
appSetServer.enabledNamespaces = []string{testNamespace}
|
||||
|
|
@ -317,15 +317,15 @@ func TestListAppSetsWithoutNamespace(t *testing.T) {
|
|||
testNamespace := "test-namespace"
|
||||
appSetServer := newTestNamespacedAppSetServer(t, newTestAppSet(func(appset *appsv1.ApplicationSet) {
|
||||
appset.Name = "AppSet1"
|
||||
appset.ObjectMeta.Namespace = testNamespace
|
||||
appset.Namespace = testNamespace
|
||||
appset.SetLabels(map[string]string{"key1": "value1", "key2": "value1"})
|
||||
}), newTestAppSet(func(appset *appsv1.ApplicationSet) {
|
||||
appset.Name = "AppSet2"
|
||||
appset.ObjectMeta.Namespace = testNamespace
|
||||
appset.Namespace = testNamespace
|
||||
appset.SetLabels(map[string]string{"key1": "value2"})
|
||||
}), newTestAppSet(func(appset *appsv1.ApplicationSet) {
|
||||
appset.Name = "AppSet3"
|
||||
appset.ObjectMeta.Namespace = testNamespace
|
||||
appset.Namespace = testNamespace
|
||||
appset.SetLabels(map[string]string{"key1": "value3"})
|
||||
}))
|
||||
appSetServer.enabledNamespaces = []string{testNamespace}
|
||||
|
|
@ -365,7 +365,7 @@ func TestCreateAppSetTemplatedProject(t *testing.T) {
|
|||
func TestCreateAppSetWrongNamespace(t *testing.T) {
|
||||
testAppSet := newTestAppSet()
|
||||
appServer := newTestAppSetServer(t)
|
||||
testAppSet.ObjectMeta.Namespace = "NOT-ALLOWED"
|
||||
testAppSet.Namespace = "NOT-ALLOWED"
|
||||
createReq := applicationset.ApplicationSetCreateRequest{
|
||||
Applicationset: testAppSet,
|
||||
}
|
||||
|
|
@ -507,21 +507,21 @@ func TestDeleteAppSet(t *testing.T) {
|
|||
|
||||
func TestUpdateAppSet(t *testing.T) {
|
||||
appSet := newTestAppSet(func(appset *appsv1.ApplicationSet) {
|
||||
appset.ObjectMeta.Annotations = map[string]string{
|
||||
appset.Annotations = map[string]string{
|
||||
"annotation-key1": "annotation-value1",
|
||||
"annotation-key2": "annotation-value2",
|
||||
}
|
||||
appset.ObjectMeta.Labels = map[string]string{
|
||||
appset.Labels = map[string]string{
|
||||
"label-key1": "label-value1",
|
||||
"label-key2": "label-value2",
|
||||
}
|
||||
})
|
||||
|
||||
newAppSet := newTestAppSet(func(appset *appsv1.ApplicationSet) {
|
||||
appset.ObjectMeta.Annotations = map[string]string{
|
||||
appset.Annotations = map[string]string{
|
||||
"annotation-key1": "annotation-value1-updated",
|
||||
}
|
||||
appset.ObjectMeta.Labels = map[string]string{
|
||||
appset.Labels = map[string]string{
|
||||
"label-key1": "label-value1-updated",
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
adjustWidth = true
|
||||
displayedRevision = revision
|
||||
if keepFullRevisionParam, ok := r.URL.Query()["keepFullRevision"]; !(ok && strings.EqualFold(keepFullRevisionParam[0], "true")) && len(revision) > 7 {
|
||||
if keepFullRevisionParam, ok := r.URL.Query()["keepFullRevision"]; (!ok || !strings.EqualFold(keepFullRevisionParam[0], "true")) && len(revision) > 7 {
|
||||
displayedRevision = revision[:7]
|
||||
svgWidth = svgWidthWithRevision
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -194,8 +194,8 @@ func TestHandlerFeatureProjectIsEnabled(t *testing.T) {
|
|||
for _, tt := range projectTests {
|
||||
argoCDCm := argoCDCm()
|
||||
argoCDSecret := argoCDSecret()
|
||||
argoCDCm.ObjectMeta.Namespace = tt.namespace
|
||||
argoCDSecret.ObjectMeta.Namespace = tt.namespace
|
||||
argoCDCm.Namespace = tt.namespace
|
||||
argoCDSecret.Namespace = tt.namespace
|
||||
|
||||
settingsMgr := settings.NewSettingsManager(t.Context(), fake.NewClientset(argoCDCm, argoCDSecret), tt.namespace)
|
||||
objects := []runtime.Object{testProject()}
|
||||
|
|
@ -258,7 +258,7 @@ func TestHandlerNamespacesIsEnabled(t *testing.T) {
|
|||
assert.Equal(t, toRGBString(Purple), leftRectColorPattern.FindStringSubmatch(response)[1])
|
||||
assert.Equal(t, toRGBString(Purple), rightRectColorPattern.FindStringSubmatch(response)[1])
|
||||
assert.Equal(t, "Not Found", leftTextPattern.FindStringSubmatch(response)[1])
|
||||
assert.Equal(t, "", rightTextPattern.FindStringSubmatch(response)[1])
|
||||
assert.Empty(t, rightTextPattern.FindStringSubmatch(response)[1])
|
||||
})
|
||||
|
||||
t.Run("Request with illegal namespace", func(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -475,7 +475,7 @@ func (s *Server) toAPIResponse(clust *appv1.Cluster) *appv1.Cluster {
|
|||
|
||||
clust.Config.Password = ""
|
||||
clust.Config.BearerToken = ""
|
||||
clust.Config.TLSClientConfig.KeyData = nil
|
||||
clust.Config.KeyData = nil
|
||||
if clust.Config.ExecProviderConfig != nil {
|
||||
// We can't know what the user has put into args or
|
||||
// env vars on the exec provider that might be sensitive
|
||||
|
|
|
|||
|
|
@ -326,10 +326,10 @@ func TestGetCluster_CannotSetCADataAndInsecureTrue(t *testing.T) {
|
|||
Cluster: localCluster,
|
||||
})
|
||||
|
||||
assert.EqualError(t, err, `error getting REST config: Unable to apply K8s REST config defaults: specifying a root certificates file with the insecure flag is not allowed`)
|
||||
assert.EqualError(t, err, `error getting REST config: unable to apply K8s REST config defaults: specifying a root certificates file with the insecure flag is not allowed`)
|
||||
})
|
||||
|
||||
localCluster.Config.TLSClientConfig.CAData = nil
|
||||
localCluster.Config.CAData = nil
|
||||
t.Run("Create Succeeds When CAData is nil and Insecure is True", func(t *testing.T) {
|
||||
_, err := server.Create(t.Context(), &cluster.ClusterCreateRequest{
|
||||
Cluster: localCluster,
|
||||
|
|
|
|||
|
|
@ -72,10 +72,10 @@ func (s *Server) Get(ctx context.Context, q *gpgkeypkg.GnuPGPublicKeyQuery) (*ap
|
|||
return key, nil
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("No such key: %s", keyID)
|
||||
return nil, fmt.Errorf("no such key: %s", keyID)
|
||||
}
|
||||
|
||||
// CreateGnuPGPublicKey adds one or more GPG public keys to the server's configuration
|
||||
// Create adds one or more GPG public keys to the server's configuration
|
||||
func (s *Server) Create(ctx context.Context, q *gpgkeypkg.GnuPGPublicKeyCreateRequest) (*gpgkeypkg.GnuPGPublicKeyCreateResponse, error) {
|
||||
if err := s.enf.EnforceErr(ctx.Value("claims"), rbac.ResourceGPGKeys, rbac.ActionCreate, ""); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -83,7 +83,7 @@ func (s *Server) Create(ctx context.Context, q *gpgkeypkg.GnuPGPublicKeyCreateRe
|
|||
|
||||
keyData := strings.TrimSpace(q.Publickey.KeyData)
|
||||
if keyData == "" {
|
||||
return nil, errors.New("Submitted key data is empty")
|
||||
return nil, errors.New("submitted key data is empty")
|
||||
}
|
||||
|
||||
added, skipped, err := s.db.AddGPGPublicKey(ctx, q.Publickey.KeyData)
|
||||
|
|
|
|||
|
|
@ -396,10 +396,10 @@ const (
|
|||
|
||||
func (server *ArgoCDServer) healthCheck(r *http.Request) error {
|
||||
if server.terminateRequested.Load() {
|
||||
return errors.New("API Server is terminating and unable to serve requests.")
|
||||
return errors.New("API Server is terminating and unable to serve requests")
|
||||
}
|
||||
if !server.available.Load() {
|
||||
return errors.New("API Server is not available. It either hasn't started or is restarting.")
|
||||
return errors.New("API Server is not available: it either hasn't started or is restarting")
|
||||
}
|
||||
if val, ok := r.URL.Query()["full"]; ok && len(val) > 0 && val[0] == "true" {
|
||||
argoDB := db.NewDB(server.Namespace, server.settingsMgr, server.KubeClientset)
|
||||
|
|
@ -790,7 +790,7 @@ func (server *ArgoCDServer) watchSettings() {
|
|||
prevGogsSecret := server.settings.WebhookGogsSecret
|
||||
prevExtConfig := server.settings.ExtensionConfig
|
||||
var prevCert, prevCertKey string
|
||||
if server.settings.Certificate != nil && !server.ArgoCDServerOpts.Insecure {
|
||||
if server.settings.Certificate != nil && !server.Insecure {
|
||||
prevCert, prevCertKey = tlsutil.EncodeX509KeyPairString(*server.settings.Certificate)
|
||||
}
|
||||
|
||||
|
|
@ -845,7 +845,7 @@ func (server *ArgoCDServer) watchSettings() {
|
|||
log.Info("extensions configs updated successfully")
|
||||
}
|
||||
}
|
||||
if !server.ArgoCDServerOpts.Insecure {
|
||||
if !server.Insecure {
|
||||
var newCert, newCertKey string
|
||||
if server.settings.Certificate != nil {
|
||||
newCert, newCertKey = tlsutil.EncodeX509KeyPairString(*server.settings.Certificate)
|
||||
|
|
@ -1054,7 +1054,7 @@ func newArgoCDServiceSet(a *ArgoCDServer) *ArgoCDServiceSet {
|
|||
)
|
||||
|
||||
projectService := project.NewServer(a.Namespace, a.KubeClientset, a.AppClientset, a.enf, projectLock, a.sessionMgr, a.policyEnforcer, a.projInformer, a.settingsMgr, a.db, a.EnableK8sEvent)
|
||||
appsInAnyNamespaceEnabled := len(a.ArgoCDServerOpts.ApplicationNamespaces) > 0
|
||||
appsInAnyNamespaceEnabled := len(a.ApplicationNamespaces) > 0
|
||||
settingsService := settings.NewServer(a.settingsMgr, a.RepoClientset, a, a.DisableAuth, appsInAnyNamespaceEnabled, a.HydratorEnabled)
|
||||
accountService := account.NewServer(a.sessionMgr, a.settingsMgr, a.enf)
|
||||
|
||||
|
|
@ -1109,7 +1109,7 @@ func (server *ArgoCDServer) translateGrpcCookieHeader(ctx context.Context, w htt
|
|||
}
|
||||
|
||||
func (server *ArgoCDServer) setTokenCookie(token string, w http.ResponseWriter) error {
|
||||
cookiePath := "path=/" + strings.TrimRight(strings.TrimLeft(server.ArgoCDServerOpts.BaseHRef, "/"), "/")
|
||||
cookiePath := "path=/" + strings.TrimRight(strings.TrimLeft(server.BaseHRef, "/"), "/")
|
||||
flags := []string{cookiePath, "SameSite=lax", "httpOnly"}
|
||||
if !server.Insecure {
|
||||
flags = append(flags, "Secure")
|
||||
|
|
@ -1158,7 +1158,7 @@ func (server *ArgoCDServer) newHTTPServer(ctx context.Context, port int, grpcWeb
|
|||
handler: mux,
|
||||
urlToHandler: map[string]http.Handler{
|
||||
"/api/badge": badge.NewHandler(server.AppClientset, server.settingsMgr, server.Namespace, server.ApplicationNamespaces),
|
||||
common.LogoutEndpoint: logout.NewHandler(server.AppClientset, server.settingsMgr, server.sessionMgr, server.ArgoCDServerOpts.RootPath, server.ArgoCDServerOpts.BaseHRef, server.Namespace),
|
||||
common.LogoutEndpoint: logout.NewHandler(server.AppClientset, server.settingsMgr, server.sessionMgr, server.RootPath, server.BaseHRef, server.Namespace),
|
||||
},
|
||||
contentTypeToHandler: map[string]http.Handler{
|
||||
"application/grpc-web+proto": grpcWebHandler,
|
||||
|
|
@ -1187,7 +1187,7 @@ func (server *ArgoCDServer) newHTTPServer(ctx context.Context, port int, grpcWeb
|
|||
}
|
||||
mux.Handle("/api/", handler)
|
||||
|
||||
terminalOpts := application.TerminalOptions{DisableAuth: server.ArgoCDServerOpts.DisableAuth, Enf: server.enf}
|
||||
terminalOpts := application.TerminalOptions{DisableAuth: server.DisableAuth, Enf: server.enf}
|
||||
|
||||
terminal := application.NewHandler(server.appLister, server.Namespace, server.ApplicationNamespaces, server.db, server.Cache, appResourceTreeFn, server.settings.ExecShells, server.sessionMgr, &terminalOpts).
|
||||
WithFeatureFlagMiddleware(server.settingsMgr.GetSettings)
|
||||
|
|
@ -1226,7 +1226,7 @@ func (server *ArgoCDServer) newHTTPServer(ctx context.Context, port int, grpcWeb
|
|||
|
||||
// Webhook handler for git events (Note: cache timeouts are hardcoded because API server does not write to cache and not really using them)
|
||||
argoDB := db.NewDB(server.Namespace, server.settingsMgr, server.KubeClientset)
|
||||
acdWebhookHandler := webhook.NewHandler(server.Namespace, server.ArgoCDServerOpts.ApplicationNamespaces, server.ArgoCDServerOpts.WebhookParallelism, server.AppClientset, server.settings, server.settingsMgr, server.RepoServerCache, server.Cache, argoDB, server.settingsMgr.GetMaxWebhookPayloadSize())
|
||||
acdWebhookHandler := webhook.NewHandler(server.Namespace, server.ApplicationNamespaces, server.WebhookParallelism, server.AppClientset, server.settings, server.settingsMgr, server.RepoServerCache, server.Cache, argoDB, server.settingsMgr.GetMaxWebhookPayloadSize())
|
||||
|
||||
mux.HandleFunc("/api/webhook", acdWebhookHandler.Handler)
|
||||
|
||||
|
|
@ -1239,14 +1239,14 @@ func (server *ArgoCDServer) newHTTPServer(ctx context.Context, port int, grpcWeb
|
|||
var extensionsHandler http.Handler = http.HandlerFunc(func(writer http.ResponseWriter, _ *http.Request) {
|
||||
server.serveExtensions(extensionsSharedPath, writer)
|
||||
})
|
||||
if server.ArgoCDServerOpts.EnableGZip {
|
||||
if server.EnableGZip {
|
||||
extensionsHandler = compressHandler(extensionsHandler)
|
||||
}
|
||||
mux.Handle("/extensions.js", extensionsHandler)
|
||||
|
||||
// Serve UI static assets
|
||||
var assetsHandler http.Handler = http.HandlerFunc(server.newStaticAssetsHandler())
|
||||
if server.ArgoCDServerOpts.EnableGZip {
|
||||
if server.EnableGZip {
|
||||
assetsHandler = compressHandler(assetsHandler)
|
||||
}
|
||||
mux.Handle("/", assetsHandler)
|
||||
|
|
@ -1296,7 +1296,7 @@ func (server *ArgoCDServer) serveExtensions(extensionsSharedPath string, w http.
|
|||
}
|
||||
if !files.IsSymlink(info) && !info.IsDir() && extensionsPattern.MatchString(info.Name()) {
|
||||
processFile := func() error {
|
||||
if _, err = w.Write([]byte(fmt.Sprintf("// source: %s/%s \n", filePath, info.Name()))); err != nil {
|
||||
if _, err = fmt.Fprintf(w, "// source: %s/%s \n", filePath, info.Name()); err != nil {
|
||||
return fmt.Errorf("failed to write to response: %w", err)
|
||||
}
|
||||
|
||||
|
|
@ -1697,9 +1697,9 @@ func bug21955WorkaroundInterceptor(ctx context.Context, req any, _ *grpc.UnarySe
|
|||
// of allowed application namespaces
|
||||
func (server *ArgoCDServer) allowedApplicationNamespacesAsString() string {
|
||||
ns := server.Namespace
|
||||
if len(server.ArgoCDServerOpts.ApplicationNamespaces) > 0 {
|
||||
if len(server.ApplicationNamespaces) > 0 {
|
||||
ns += ", "
|
||||
ns += strings.Join(server.ArgoCDServerOpts.ApplicationNamespaces, ", ")
|
||||
ns += strings.Join(server.ApplicationNamespaces, ", ")
|
||||
}
|
||||
return ns
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ func TestEnforceProjectToken(t *testing.T) {
|
|||
cancel := test.StartInformer(s.projInformer)
|
||||
defer cancel()
|
||||
claims := jwt.MapClaims{"sub": defaultSub, "iat": defaultIssuedAt}
|
||||
assert.True(t, s.enf.Enforce(claims, "projects", "get", existingProj.ObjectMeta.Name))
|
||||
assert.True(t, s.enf.Enforce(claims, "projects", "get", existingProj.Name))
|
||||
assert.True(t, s.enf.Enforce(claims, "applications", "get", defaultTestObject))
|
||||
})
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ func TestEnforceProjectToken(t *testing.T) {
|
|||
cancel := test.StartInformer(s.projInformer)
|
||||
defer cancel()
|
||||
claims := jwt.MapClaims{"sub": defaultSub, "jti": defaultId}
|
||||
assert.True(t, s.enf.Enforce(claims, "projects", "get", existingProj.ObjectMeta.Name))
|
||||
assert.True(t, s.enf.Enforce(claims, "projects", "get", existingProj.Name))
|
||||
assert.True(t, s.enf.Enforce(claims, "applications", "get", defaultTestObject))
|
||||
})
|
||||
|
||||
|
|
@ -350,7 +350,7 @@ func TestEnforceProjectGroups(t *testing.T) {
|
|||
"iat": defaultIssuedAt,
|
||||
"groups": []string{groupName},
|
||||
}
|
||||
assert.True(t, s.enf.Enforce(claims, "projects", "get", existingProj.ObjectMeta.Name))
|
||||
assert.True(t, s.enf.Enforce(claims, "projects", "get", existingProj.Name))
|
||||
assert.True(t, s.enf.Enforce(claims, "applications", "get", defaultTestObject))
|
||||
assert.False(t, s.enf.Enforce(claims, "clusters", "get", "test"))
|
||||
|
||||
|
|
@ -360,7 +360,7 @@ func TestEnforceProjectGroups(t *testing.T) {
|
|||
log.Println(existingProj.ProjectPoliciesString())
|
||||
_, _ = s.AppClientset.ArgoprojV1alpha1().AppProjects(test.FakeArgoCDNamespace).Update(t.Context(), &existingProj, metav1.UpdateOptions{})
|
||||
time.Sleep(100 * time.Millisecond) // this lets the informer get synced
|
||||
assert.False(t, s.enf.Enforce(claims, "projects", "get", existingProj.ObjectMeta.Name))
|
||||
assert.False(t, s.enf.Enforce(claims, "projects", "get", existingProj.Name))
|
||||
assert.False(t, s.enf.Enforce(claims, "applications", "get", defaultTestObject))
|
||||
assert.False(t, s.enf.Enforce(claims, "clusters", "get", "test"))
|
||||
}
|
||||
|
|
@ -409,7 +409,7 @@ func TestRevokedToken(t *testing.T) {
|
|||
cancel := test.StartInformer(s.projInformer)
|
||||
defer cancel()
|
||||
claims := jwt.MapClaims{"sub": defaultSub, "iat": defaultIssuedAt}
|
||||
assert.True(t, s.enf.Enforce(claims, "projects", "get", existingProj.ObjectMeta.Name))
|
||||
assert.True(t, s.enf.Enforce(claims, "projects", "get", existingProj.Name))
|
||||
assert.True(t, s.enf.Enforce(claims, "applications", "get", defaultTestObject))
|
||||
}
|
||||
|
||||
|
|
@ -1177,7 +1177,7 @@ func TestTranslateGrpcCookieHeader(t *testing.T) {
|
|||
Token: "",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "", recorder.Result().Header.Get("Set-Cookie"))
|
||||
assert.Empty(t, recorder.Result().Header.Get("Set-Cookie"))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2129,9 +2129,9 @@ spec:
|
|||
Expect(SyncStatusIs(SyncStatusCodeSynced)).
|
||||
Expect(NoConditions()).
|
||||
And(func(app *Application) {
|
||||
assert.Equal(t, map[string]string{"labels.local/from-file": "file", "labels.local/from-args": "args"}, app.ObjectMeta.Labels)
|
||||
assert.Equal(t, map[string]string{"annotations.local/from-file": "file"}, app.ObjectMeta.Annotations)
|
||||
assert.Equal(t, []string{"resources-finalizer.argocd.argoproj.io"}, app.ObjectMeta.Finalizers)
|
||||
assert.Equal(t, map[string]string{"labels.local/from-file": "file", "labels.local/from-args": "args"}, app.Labels)
|
||||
assert.Equal(t, map[string]string{"annotations.local/from-file": "file"}, app.Annotations)
|
||||
assert.Equal(t, []string{"resources-finalizer.argocd.argoproj.io"}, app.Finalizers)
|
||||
assert.Equal(t, path, app.Spec.GetSource().Path)
|
||||
assert.Equal(t, []HelmParameter{{Name: "foo", Value: "foo"}}, app.Spec.GetSource().Helm.Parameters)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -2348,9 +2348,9 @@ spec:
|
|||
Expect(SyncStatusIs(SyncStatusCodeSynced)).
|
||||
Expect(NoConditions()).
|
||||
And(func(app *Application) {
|
||||
assert.Equal(t, map[string]string{"labels.local/from-file": "file", "labels.local/from-args": "args"}, app.ObjectMeta.Labels)
|
||||
assert.Equal(t, map[string]string{"annotations.local/from-file": "file"}, app.ObjectMeta.Annotations)
|
||||
assert.Equal(t, []string{"resources-finalizer.argocd.argoproj.io"}, app.ObjectMeta.Finalizers)
|
||||
assert.Equal(t, map[string]string{"labels.local/from-file": "file", "labels.local/from-args": "args"}, app.Labels)
|
||||
assert.Equal(t, map[string]string{"annotations.local/from-file": "file"}, app.Annotations)
|
||||
assert.Equal(t, []string{"resources-finalizer.argocd.argoproj.io"}, app.Finalizers)
|
||||
assert.Equal(t, path, app.Spec.GetSource().Path)
|
||||
assert.Equal(t, []HelmParameter{{Name: "foo", Value: "foo"}}, app.Spec.GetSource().Helm.Parameters)
|
||||
})
|
||||
|
|
@ -2846,7 +2846,7 @@ func TestAnnotationTrackingExtraResources(t *testing.T) {
|
|||
// The extra configmap must be pruned now, because it's tracked
|
||||
cm, err := fixture.KubeClientset.CoreV1().ConfigMaps(fixture.DeploymentNamespace()).Get(t.Context(), "other-configmap", metav1.GetOptions{})
|
||||
require.Error(t, err)
|
||||
require.Equal(t, "", cm.Name)
|
||||
require.Empty(t, cm.Name)
|
||||
}).
|
||||
Then().
|
||||
Expect(OperationPhaseIs(OperationSucceeded)).
|
||||
|
|
@ -2898,7 +2898,7 @@ func TestAnnotationTrackingExtraResources(t *testing.T) {
|
|||
// The extra configmap must be pruned now, because it's tracked and does not exist in git
|
||||
cr, err := fixture.KubeClientset.RbacV1().ClusterRoles().Get(t.Context(), "e2e-other-clusterrole", metav1.GetOptions{})
|
||||
require.Error(t, err)
|
||||
require.Equal(t, "", cr.Name)
|
||||
require.Empty(t, cr.Name)
|
||||
}).
|
||||
Then().
|
||||
Expect(OperationPhaseIs(OperationSucceeded)).
|
||||
|
|
|
|||
|
|
@ -353,11 +353,11 @@ func TestSimpleClusterGeneratorAddingCluster(t *testing.T) {
|
|||
|
||||
expectedAppCluster1 := *expectedAppTemplate.DeepCopy()
|
||||
expectedAppCluster1.Spec.Destination.Name = "cluster1"
|
||||
expectedAppCluster1.ObjectMeta.Name = "cluster1-guestbook"
|
||||
expectedAppCluster1.Name = "cluster1-guestbook"
|
||||
|
||||
expectedAppCluster2 := *expectedAppTemplate.DeepCopy()
|
||||
expectedAppCluster2.Spec.Destination.Name = "cluster2"
|
||||
expectedAppCluster2.ObjectMeta.Name = "cluster2-guestbook"
|
||||
expectedAppCluster2.Name = "cluster2-guestbook"
|
||||
|
||||
Given(t).
|
||||
// Create a ClusterGenerator-based ApplicationSet
|
||||
|
|
@ -435,11 +435,11 @@ func TestSimpleClusterGeneratorDeletingCluster(t *testing.T) {
|
|||
|
||||
expectedAppCluster1 := *expectedAppTemplate.DeepCopy()
|
||||
expectedAppCluster1.Spec.Destination.Name = "cluster1"
|
||||
expectedAppCluster1.ObjectMeta.Name = "cluster1-guestbook"
|
||||
expectedAppCluster1.Name = "cluster1-guestbook"
|
||||
|
||||
expectedAppCluster2 := *expectedAppTemplate.DeepCopy()
|
||||
expectedAppCluster2.Spec.Destination.Name = "cluster2"
|
||||
expectedAppCluster2.ObjectMeta.Name = "cluster2-guestbook"
|
||||
expectedAppCluster2.Name = "cluster2-guestbook"
|
||||
|
||||
Given(t).
|
||||
// Create a ClusterGenerator-based ApplicationSet
|
||||
|
|
|
|||
|
|
@ -255,11 +255,11 @@ func TestSimpleClusterDecisionResourceGeneratorAddingCluster(t *testing.T) {
|
|||
|
||||
expectedAppCluster1 := *expectedAppTemplate.DeepCopy()
|
||||
expectedAppCluster1.Spec.Destination.Name = "cluster1"
|
||||
expectedAppCluster1.ObjectMeta.Name = "cluster1-guestbook"
|
||||
expectedAppCluster1.Name = "cluster1-guestbook"
|
||||
|
||||
expectedAppCluster2 := *expectedAppTemplate.DeepCopy()
|
||||
expectedAppCluster2.Spec.Destination.Name = "cluster2"
|
||||
expectedAppCluster2.ObjectMeta.Name = "cluster2-guestbook"
|
||||
expectedAppCluster2.Name = "cluster2-guestbook"
|
||||
|
||||
clusterList := []any{
|
||||
map[string]any{
|
||||
|
|
@ -350,11 +350,11 @@ func TestSimpleClusterDecisionResourceGeneratorDeletingClusterSecret(t *testing.
|
|||
|
||||
expectedAppCluster1 := *expectedAppTemplate.DeepCopy()
|
||||
expectedAppCluster1.Spec.Destination.Name = "cluster1"
|
||||
expectedAppCluster1.ObjectMeta.Name = "cluster1-guestbook"
|
||||
expectedAppCluster1.Name = "cluster1-guestbook"
|
||||
|
||||
expectedAppCluster2 := *expectedAppTemplate.DeepCopy()
|
||||
expectedAppCluster2.Spec.Destination.Name = "cluster2"
|
||||
expectedAppCluster2.ObjectMeta.Name = "cluster2-guestbook"
|
||||
expectedAppCluster2.Name = "cluster2-guestbook"
|
||||
|
||||
clusterList := []any{
|
||||
map[string]any{
|
||||
|
|
@ -447,11 +447,11 @@ func TestSimpleClusterDecisionResourceGeneratorDeletingClusterFromResource(t *te
|
|||
|
||||
expectedAppCluster1 := *expectedAppTemplate.DeepCopy()
|
||||
expectedAppCluster1.Spec.Destination.Name = "cluster1"
|
||||
expectedAppCluster1.ObjectMeta.Name = "cluster1-guestbook"
|
||||
expectedAppCluster1.Name = "cluster1-guestbook"
|
||||
|
||||
expectedAppCluster2 := *expectedAppTemplate.DeepCopy()
|
||||
expectedAppCluster2.Spec.Destination.Name = "cluster2"
|
||||
expectedAppCluster2.ObjectMeta.Name = "cluster2-guestbook"
|
||||
expectedAppCluster2.Name = "cluster2-guestbook"
|
||||
|
||||
clusterList := []any{
|
||||
map[string]any{
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ func TestCustomToolWithEnv(t *testing.T) {
|
|||
outputSlice := strings.Split(output, ",")
|
||||
sort.Strings(outputSlice)
|
||||
|
||||
assert.EqualValues(t, expectedAPIVersionSlice, outputSlice)
|
||||
assert.Equal(t, expectedAPIVersionSlice, outputSlice)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -344,7 +344,7 @@ func TestCMPDiscoverWithFindCommandWithEnv(t *testing.T) {
|
|||
outputSlice := strings.Split(output, ",")
|
||||
sort.Strings(outputSlice)
|
||||
|
||||
assert.EqualValues(t, expectedAPIVersionSlice, outputSlice)
|
||||
assert.Equal(t, expectedAPIVersionSlice, outputSlice)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/test/e2e/fixture"
|
||||
. "github.com/argoproj/argo-cd/v3/test/e2e/fixture/admin/utils"
|
||||
"github.com/argoproj/argo-cd/v3/test/e2e/fixture/admin/utils"
|
||||
)
|
||||
|
||||
// this implements the "then" part of given/when/then
|
||||
|
|
@ -26,8 +26,8 @@ func (c *Consequences) AndCLIOutput(block func(output string, err error)) *Conse
|
|||
}
|
||||
|
||||
// For use after running export with the exported resources desirialized
|
||||
func (c *Consequences) AndExportedResources(block func(resources *ExportedResources, err error)) {
|
||||
result, err := GetExportedResourcesFromOutput(c.actions.lastOutput)
|
||||
func (c *Consequences) AndExportedResources(block func(resources *utils.ExportedResources, err error)) {
|
||||
result, err := utils.GetExportedResourcesFromOutput(c.actions.lastOutput)
|
||||
block(&result, err)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import (
|
|||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
client "github.com/argoproj/argo-cd/v3/pkg/apiclient/application"
|
||||
. "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
"github.com/argoproj/argo-cd/v3/test/e2e/fixture"
|
||||
"github.com/argoproj/argo-cd/v3/util/grpc"
|
||||
)
|
||||
|
|
@ -123,20 +123,20 @@ func (a *Actions) CreateFromPartialFile(data string, flags ...string) *Actions {
|
|||
return a
|
||||
}
|
||||
|
||||
func (a *Actions) CreateFromFile(handler func(app *Application), flags ...string) *Actions {
|
||||
func (a *Actions) CreateFromFile(handler func(app *v1alpha1.Application), flags ...string) *Actions {
|
||||
a.context.t.Helper()
|
||||
app := &Application{
|
||||
app := &v1alpha1.Application{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: a.context.AppName(),
|
||||
Namespace: a.context.AppNamespace(),
|
||||
},
|
||||
Spec: ApplicationSpec{
|
||||
Spec: v1alpha1.ApplicationSpec{
|
||||
Project: a.context.project,
|
||||
Source: &ApplicationSource{
|
||||
Source: &v1alpha1.ApplicationSource{
|
||||
RepoURL: fixture.RepoURL(a.context.repoURLType),
|
||||
Path: a.context.path,
|
||||
},
|
||||
Destination: ApplicationDestination{
|
||||
Destination: v1alpha1.ApplicationDestination{
|
||||
Server: a.context.destServer,
|
||||
Namespace: fixture.DeploymentNamespace(),
|
||||
},
|
||||
|
|
@ -144,23 +144,23 @@ func (a *Actions) CreateFromFile(handler func(app *Application), flags ...string
|
|||
}
|
||||
source := app.Spec.GetSource()
|
||||
if a.context.namePrefix != "" || a.context.nameSuffix != "" {
|
||||
source.Kustomize = &ApplicationSourceKustomize{
|
||||
source.Kustomize = &v1alpha1.ApplicationSourceKustomize{
|
||||
NamePrefix: a.context.namePrefix,
|
||||
NameSuffix: a.context.nameSuffix,
|
||||
}
|
||||
}
|
||||
if a.context.configManagementPlugin != "" {
|
||||
source.Plugin = &ApplicationSourcePlugin{
|
||||
source.Plugin = &v1alpha1.ApplicationSourcePlugin{
|
||||
Name: a.context.configManagementPlugin,
|
||||
}
|
||||
}
|
||||
|
||||
if len(a.context.parameters) > 0 {
|
||||
log.Fatal("Application parameters or json tlas are not supported")
|
||||
log.Fatal("v1alpha1.Application parameters or json tlas are not supported")
|
||||
}
|
||||
|
||||
if a.context.directoryRecurse {
|
||||
source.Directory = &ApplicationSourceDirectory{Recurse: true}
|
||||
source.Directory = &v1alpha1.ApplicationSourceDirectory{Recurse: true}
|
||||
}
|
||||
app.Spec.Source = &source
|
||||
|
||||
|
|
@ -182,20 +182,20 @@ func (a *Actions) CreateFromFile(handler func(app *Application), flags ...string
|
|||
|
||||
func (a *Actions) CreateMultiSourceAppFromFile(flags ...string) *Actions {
|
||||
a.context.t.Helper()
|
||||
app := &Application{
|
||||
app := &v1alpha1.Application{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: a.context.AppName(),
|
||||
Namespace: a.context.AppNamespace(),
|
||||
},
|
||||
Spec: ApplicationSpec{
|
||||
Spec: v1alpha1.ApplicationSpec{
|
||||
Project: a.context.project,
|
||||
Sources: a.context.sources,
|
||||
Destination: ApplicationDestination{
|
||||
Destination: v1alpha1.ApplicationDestination{
|
||||
Server: a.context.destServer,
|
||||
Namespace: fixture.DeploymentNamespace(),
|
||||
},
|
||||
SyncPolicy: &SyncPolicy{
|
||||
Automated: &SyncPolicyAutomated{
|
||||
SyncPolicy: &v1alpha1.SyncPolicy{
|
||||
Automated: &v1alpha1.SyncPolicyAutomated{
|
||||
SelfHeal: true,
|
||||
},
|
||||
},
|
||||
|
|
@ -347,7 +347,7 @@ func (a *Actions) PatchApp(patch string) *Actions {
|
|||
|
||||
func (a *Actions) PatchAppHttp(patch string) *Actions { //nolint:revive //FIXME(var-naming)
|
||||
a.context.t.Helper()
|
||||
var application Application
|
||||
var application v1alpha1.Application
|
||||
patchType := "merge"
|
||||
appName := a.context.AppQualifiedName()
|
||||
appNamespace := a.context.AppNamespace()
|
||||
|
|
@ -443,11 +443,11 @@ func (a *Actions) TerminateOp() *Actions {
|
|||
return a
|
||||
}
|
||||
|
||||
func (a *Actions) Refresh(refreshType RefreshType) *Actions {
|
||||
func (a *Actions) Refresh(refreshType v1alpha1.RefreshType) *Actions {
|
||||
a.context.t.Helper()
|
||||
flag := map[RefreshType]string{
|
||||
RefreshTypeNormal: "--refresh",
|
||||
RefreshTypeHard: "--hard-refresh",
|
||||
flag := map[v1alpha1.RefreshType]string{
|
||||
v1alpha1.RefreshTypeNormal: "--refresh",
|
||||
v1alpha1.RefreshTypeHard: "--hard-refresh",
|
||||
}[refreshType]
|
||||
|
||||
a.runCli("app", "get", a.context.AppQualifiedName(), flag)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import (
|
|||
"k8s.io/utils/ptr"
|
||||
|
||||
applicationpkg "github.com/argoproj/argo-cd/v3/pkg/apiclient/application"
|
||||
. "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
"github.com/argoproj/argo-cd/v3/test/e2e/fixture"
|
||||
util "github.com/argoproj/argo-cd/v3/util/io"
|
||||
)
|
||||
|
|
@ -84,7 +84,7 @@ func (c *Consequences) ExpectConsistently(e Expectation, waitDuration time.Durat
|
|||
return c
|
||||
}
|
||||
|
||||
func (c *Consequences) And(block func(app *Application)) *Consequences {
|
||||
func (c *Consequences) And(block func(app *v1alpha1.Application)) *Consequences {
|
||||
c.context.t.Helper()
|
||||
block(c.app())
|
||||
return c
|
||||
|
|
@ -105,18 +105,18 @@ func (c *Consequences) When() *Actions {
|
|||
return c.actions
|
||||
}
|
||||
|
||||
func (c *Consequences) app() *Application {
|
||||
func (c *Consequences) app() *v1alpha1.Application {
|
||||
c.context.t.Helper()
|
||||
app, err := c.get()
|
||||
require.NoError(c.context.t, err)
|
||||
return app
|
||||
}
|
||||
|
||||
func (c *Consequences) get() (*Application, error) {
|
||||
func (c *Consequences) get() (*v1alpha1.Application, error) {
|
||||
return fixture.AppClientset.ArgoprojV1alpha1().Applications(c.context.AppNamespace()).Get(context.Background(), c.context.AppName(), metav1.GetOptions{})
|
||||
}
|
||||
|
||||
func (c *Consequences) resource(kind, name, namespace string) ResourceStatus {
|
||||
func (c *Consequences) resource(kind, name, namespace string) v1alpha1.ResourceStatus {
|
||||
c.context.t.Helper()
|
||||
closer, client, err := fixture.ArgoCDClientset.NewApplicationClient()
|
||||
require.NoError(c.context.t, err)
|
||||
|
|
@ -132,8 +132,8 @@ func (c *Consequences) resource(kind, name, namespace string) ResourceStatus {
|
|||
return r
|
||||
}
|
||||
}
|
||||
return ResourceStatus{
|
||||
Health: &HealthStatus{
|
||||
return v1alpha1.ResourceStatus{
|
||||
Health: &v1alpha1.HealthStatus{
|
||||
Status: health.HealthStatusMissing,
|
||||
Message: "not found",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/argoproj/gitops-engine/pkg/health"
|
||||
. "github.com/argoproj/gitops-engine/pkg/sync/common"
|
||||
"github.com/argoproj/gitops-engine/pkg/sync/common"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/fields"
|
||||
|
||||
. "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
"github.com/argoproj/argo-cd/v3/test/e2e/fixture"
|
||||
)
|
||||
|
||||
|
|
@ -28,10 +28,10 @@ const (
|
|||
|
||||
type Expectation func(c *Consequences) (state state, message string)
|
||||
|
||||
func OperationPhaseIs(expected OperationPhase) Expectation {
|
||||
func OperationPhaseIs(expected common.OperationPhase) Expectation {
|
||||
return func(c *Consequences) (state, string) {
|
||||
operationState := c.app().Status.OperationState
|
||||
actual := OperationRunning
|
||||
actual := common.OperationRunning
|
||||
if operationState != nil {
|
||||
actual = operationState.Phase
|
||||
}
|
||||
|
|
@ -57,14 +57,14 @@ func simple(success bool, message string) (state, string) {
|
|||
return pending, message
|
||||
}
|
||||
|
||||
func SyncStatusIs(expected SyncStatusCode) Expectation {
|
||||
func SyncStatusIs(expected v1alpha1.SyncStatusCode) Expectation {
|
||||
return func(c *Consequences) (state, string) {
|
||||
actual := c.app().Status.Sync.Status
|
||||
return simple(actual == expected, fmt.Sprintf("sync status to be %s, is %s", expected, actual))
|
||||
}
|
||||
}
|
||||
|
||||
func Condition(conditionType ApplicationConditionType, conditionMessage string) Expectation {
|
||||
func Condition(conditionType v1alpha1.ApplicationConditionType, conditionMessage string) Expectation {
|
||||
return func(c *Consequences) (state, string) {
|
||||
got := c.app().Status.Conditions
|
||||
message := fmt.Sprintf("condition {%s %s} in %v", conditionType, conditionMessage, got)
|
||||
|
|
@ -107,7 +107,7 @@ func StatusExists() Expectation {
|
|||
}
|
||||
}
|
||||
|
||||
func Namespace(name string, block func(app *Application, ns *corev1.Namespace)) Expectation {
|
||||
func Namespace(name string, block func(app *v1alpha1.Application, ns *corev1.Namespace)) Expectation {
|
||||
return func(c *Consequences) (state, string) {
|
||||
ns, err := namespace(name)
|
||||
if err != nil {
|
||||
|
|
@ -126,14 +126,14 @@ func HealthIs(expected health.HealthStatusCode) Expectation {
|
|||
}
|
||||
}
|
||||
|
||||
func ResourceSyncStatusIs(kind, resource string, expected SyncStatusCode) Expectation {
|
||||
func ResourceSyncStatusIs(kind, resource string, expected v1alpha1.SyncStatusCode) Expectation {
|
||||
return func(c *Consequences) (state, string) {
|
||||
actual := c.resource(kind, resource, "").Status
|
||||
return simple(actual == expected, fmt.Sprintf("resource '%s/%s' sync status should be %s, is %s", kind, resource, expected, actual))
|
||||
}
|
||||
}
|
||||
|
||||
func ResourceSyncStatusWithNamespaceIs(kind, resource, namespace string, expected SyncStatusCode) Expectation {
|
||||
func ResourceSyncStatusWithNamespaceIs(kind, resource, namespace string, expected v1alpha1.SyncStatusCode) Expectation {
|
||||
return func(c *Consequences) (state, string) {
|
||||
actual := c.resource(kind, resource, namespace).Status
|
||||
return simple(actual == expected, fmt.Sprintf("resource '%s/%s' sync status should be %s, is %s", kind, resource, expected, actual))
|
||||
|
|
@ -180,7 +180,7 @@ func ResourceResultNumbering(num int) Expectation {
|
|||
}
|
||||
}
|
||||
|
||||
func ResourceResultIs(result ResourceResult) Expectation {
|
||||
func ResourceResultIs(result v1alpha1.ResourceResult) Expectation {
|
||||
return func(c *Consequences) (state, string) {
|
||||
results := c.app().Status.OperationState.SyncResult.Resources
|
||||
for _, res := range results {
|
||||
|
|
@ -192,7 +192,7 @@ func ResourceResultIs(result ResourceResult) Expectation {
|
|||
}
|
||||
}
|
||||
|
||||
func sameResourceResult(res1, res2 ResourceResult) bool {
|
||||
func sameResourceResult(res1, res2 v1alpha1.ResourceResult) bool {
|
||||
return res1.Kind == res2.Kind &&
|
||||
res1.Group == res2.Group &&
|
||||
res1.Namespace == res2.Namespace &&
|
||||
|
|
@ -202,7 +202,7 @@ func sameResourceResult(res1, res2 ResourceResult) bool {
|
|||
res1.HookPhase == res2.HookPhase
|
||||
}
|
||||
|
||||
func ResourceResultMatches(result ResourceResult) Expectation {
|
||||
func ResourceResultMatches(result v1alpha1.ResourceResult) Expectation {
|
||||
return func(c *Consequences) (state, string) {
|
||||
results := c.app().Status.OperationState.SyncResult.Resources
|
||||
for _, res := range results {
|
||||
|
|
|
|||
|
|
@ -217,9 +217,9 @@ func (a *Actions) Create(appSet v1alpha1.ApplicationSet) *Actions {
|
|||
var appSetClientSet dynamic.ResourceInterface
|
||||
|
||||
if a.context.switchToNamespace != "" {
|
||||
externalAppSetClientset, found := fixtureClient.ExternalAppSetClientsets[utils.ExternalNamespace(a.context.switchToNamespace)]
|
||||
externalAppSetClientset, found := fixtureClient.ExternalAppSetClientsets[a.context.switchToNamespace]
|
||||
if !found {
|
||||
a.lastOutput, a.lastError = "", fmt.Errorf("No external clientset found for %s", a.context.switchToNamespace)
|
||||
a.lastOutput, a.lastError = "", fmt.Errorf("no external clientset found for %s", a.context.switchToNamespace)
|
||||
return a
|
||||
}
|
||||
appSetClientSet = externalAppSetClientset
|
||||
|
|
@ -397,9 +397,9 @@ func (a *Actions) Delete() *Actions {
|
|||
var appSetClientSet dynamic.ResourceInterface
|
||||
|
||||
if a.context.switchToNamespace != "" {
|
||||
externalAppSetClientset, found := fixtureClient.ExternalAppSetClientsets[utils.ExternalNamespace(a.context.switchToNamespace)]
|
||||
externalAppSetClientset, found := fixtureClient.ExternalAppSetClientsets[a.context.switchToNamespace]
|
||||
if !found {
|
||||
a.lastOutput, a.lastError = "", fmt.Errorf("No external clientset found for %s", a.context.switchToNamespace)
|
||||
a.lastOutput, a.lastError = "", fmt.Errorf("no external clientset found for %s", a.context.switchToNamespace)
|
||||
return a
|
||||
}
|
||||
appSetClientSet = externalAppSetClientset
|
||||
|
|
@ -425,9 +425,9 @@ func (a *Actions) get() (*v1alpha1.ApplicationSet, error) {
|
|||
var appSetClientSet dynamic.ResourceInterface
|
||||
|
||||
if a.context.switchToNamespace != "" {
|
||||
externalAppSetClientset, found := fixtureClient.ExternalAppSetClientsets[utils.ExternalNamespace(a.context.switchToNamespace)]
|
||||
externalAppSetClientset, found := fixtureClient.ExternalAppSetClientsets[a.context.switchToNamespace]
|
||||
if !found {
|
||||
return nil, fmt.Errorf("No external clientset found for %s", a.context.switchToNamespace)
|
||||
return nil, fmt.Errorf("no external clientset found for %s", a.context.switchToNamespace)
|
||||
}
|
||||
appSetClientSet = externalAppSetClientset
|
||||
} else {
|
||||
|
|
@ -488,9 +488,9 @@ func (a *Actions) Update(toUpdate func(*v1alpha1.ApplicationSet)) *Actions {
|
|||
var appSetClientSet dynamic.ResourceInterface
|
||||
|
||||
if a.context.switchToNamespace != "" {
|
||||
externalAppSetClientset, found := fixtureClient.ExternalAppSetClientsets[utils.ExternalNamespace(a.context.switchToNamespace)]
|
||||
externalAppSetClientset, found := fixtureClient.ExternalAppSetClientsets[a.context.switchToNamespace]
|
||||
if !found {
|
||||
a.lastOutput, a.lastError = "", fmt.Errorf("No external clientset found for %s", a.context.switchToNamespace)
|
||||
a.lastOutput, a.lastError = "", fmt.Errorf("no external clientset found for %s", a.context.switchToNamespace)
|
||||
return a
|
||||
}
|
||||
appSetClientSet = externalAppSetClientset
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ func EnsureCleanState(t *testing.T) {
|
|||
}
|
||||
if list != nil && len(list.Items) > 0 {
|
||||
// Fail
|
||||
return fmt.Errorf("Waiting for list of ApplicationSets to be size zero: %d", len(list.Items))
|
||||
return fmt.Errorf("waiting for list of ApplicationSets to be size zero: %d", len(list.Items))
|
||||
}
|
||||
|
||||
return nil // Pass
|
||||
|
|
@ -241,7 +241,7 @@ func waitForExpectedClusterState(t *testing.T) error {
|
|||
}
|
||||
if list != nil && len(list.Items) > 0 {
|
||||
// Fail
|
||||
return fmt.Errorf("Waiting for list of ApplicationSets to be size zero: %d", len(list.Items))
|
||||
return fmt.Errorf("waiting for list of ApplicationSets to be size zero: %d", len(list.Items))
|
||||
}
|
||||
|
||||
return nil // Pass
|
||||
|
|
@ -257,7 +257,7 @@ func waitForExpectedClusterState(t *testing.T) error {
|
|||
}
|
||||
if appList != nil && len(appList.Items) > 0 {
|
||||
// Fail
|
||||
return fmt.Errorf("Waiting for list of Applications to be size zero: %d", len(appList.Items))
|
||||
return fmt.Errorf("waiting for list of Applications to be size zero: %d", len(appList.Items))
|
||||
}
|
||||
return nil // Pass
|
||||
}, time.Now().Add(60*time.Second)); err != nil {
|
||||
|
|
@ -325,11 +325,7 @@ func waitForSuccess(condition func() error, expireTime time.Time) error {
|
|||
}
|
||||
sleepIntervalsIdx := -1
|
||||
|
||||
for {
|
||||
if time.Now().After(expireTime) {
|
||||
break
|
||||
}
|
||||
|
||||
for !time.Now().After(expireTime) {
|
||||
conditionErr := condition()
|
||||
if conditionErr == nil {
|
||||
// Pass!
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue