Compare commits

...

6 Commits

Author SHA1 Message Date
github-actions[bot]
bf0fa07aed Bump version to 2.8.21 (#19628)
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: jessesuen <12677113+jessesuen@users.noreply.github.com>
2024-08-21 16:37:45 -07:00
Alexander Matyushentsev
e19aaaa73a fix: ArgoCD 2.11 - Loop of PATCH calls to Application objects (#19340) (#19570)
Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
2024-08-21 08:33:44 -06:00
gcp-cherry-pick-bot[bot]
6ebbc75e2a fix: Update braces package to 3.0.3 (#18459) (#18666)
Signed-off-by: Keith Chong <kykchong@redhat.com>
Co-authored-by: Keith Chong <kykchong@redhat.com>
2024-06-14 09:19:32 -04:00
gcp-cherry-pick-bot[bot]
dbb7f0363e test: fix e2e tests after GHSA-3cqf-953p-h5cp (#18543) (#18555)
Co-authored-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
2024-06-07 11:50:03 -04:00
github-actions[bot]
aa77055fd4 Bump version to 2.8.20 (#18386)
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: pasha-codefresh <39732895+pasha-codefresh@users.noreply.github.com>
2024-05-23 16:35:12 +03:00
pasha-codefresh
5aa0bb9124 fix: remove Egress NetworkPolicy for argocd-redis and argocd-redis-ha-haproxy (#18367) - 2.8 (#18383) 2024-05-23 09:05:41 -04:00
19 changed files with 137 additions and 225 deletions

View File

@@ -1 +1 @@
2.8.19
2.8.21

View File

@@ -1605,6 +1605,22 @@ func (ctrl *ApplicationController) normalizeApplication(orig, app *appv1.Applica
}
}
func createMergePatch(orig, new interface{}) ([]byte, bool, error) {
origBytes, err := json.Marshal(orig)
if err != nil {
return nil, false, err
}
newBytes, err := json.Marshal(new)
if err != nil {
return nil, false, err
}
patch, err := jsonpatch.CreateMergePatch(origBytes, newBytes)
if err != nil {
return nil, false, err
}
return patch, string(patch) != "{}", nil
}
// 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) {
logCtx := log.WithFields(log.Fields{"application": orig.QualifiedName()})
@@ -1624,9 +1640,9 @@ func (ctrl *ApplicationController) persistAppStatus(orig *appv1.Application, new
}
delete(newAnnotations, appv1.AnnotationKeyRefresh)
}
patch, modified, err := diff.CreateTwoWayMergePatch(
patch, modified, err := createMergePatch(
&appv1.Application{ObjectMeta: metav1.ObjectMeta{Annotations: orig.GetAnnotations()}, Status: orig.Status},
&appv1.Application{ObjectMeta: metav1.ObjectMeta{Annotations: newAnnotations}, Status: *newStatus}, appv1.Application{})
&appv1.Application{ObjectMeta: metav1.ObjectMeta{Annotations: newAnnotations}, Status: *newStatus})
if err != nil {
logCtx.Errorf("Error constructing app status patch: %v", err)
return

View File

@@ -21,6 +21,7 @@ import (
"github.com/argoproj/gitops-engine/pkg/utils/kube/kubetest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
apierr "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -801,7 +802,7 @@ func TestNormalizeApplication(t *testing.T) {
normalized := false
fakeAppCs.AddReactor("patch", "*", func(action kubetesting.Action) (handled bool, ret runtime.Object, err error) {
if patchAction, ok := action.(kubetesting.PatchAction); ok {
if string(patchAction.GetPatch()) == `{"spec":{"project":"default"},"status":{"sync":{"comparedTo":{"destination":{},"source":{"repoURL":""}}}}}` {
if string(patchAction.GetPatch()) == `{"spec":{"project":"default"}}` {
normalized = true
}
}
@@ -1728,3 +1729,65 @@ func TestAddControllerNamespace(t *testing.T) {
assert.Equal(t, test.FakeArgoCDNamespace, updatedApp.Status.ControllerNamespace)
})
}
func TestHelmValuesObjectHasReplaceStrategy(t *testing.T) {
app := v1alpha1.Application{
Status: v1alpha1.ApplicationStatus{Sync: v1alpha1.SyncStatus{ComparedTo: v1alpha1.ComparedTo{
Source: v1alpha1.ApplicationSource{
Helm: &v1alpha1.ApplicationSourceHelm{
ValuesObject: &runtime.RawExtension{
Object: &unstructured.Unstructured{Object: map[string]interface{}{"key": []string{"value"}}},
},
},
},
}}},
}
appModified := v1alpha1.Application{
Status: v1alpha1.ApplicationStatus{Sync: v1alpha1.SyncStatus{ComparedTo: v1alpha1.ComparedTo{
Source: v1alpha1.ApplicationSource{
Helm: &v1alpha1.ApplicationSourceHelm{
ValuesObject: &runtime.RawExtension{
Object: &unstructured.Unstructured{Object: map[string]interface{}{"key": []string{"value-modified1"}}},
},
},
},
}}},
}
patch, _, err := createMergePatch(
app,
appModified)
require.NoError(t, err)
assert.Equal(t, `{"status":{"sync":{"comparedTo":{"source":{"helm":{"valuesObject":{"key":["value-modified1"]}}}}}}}`, string(patch))
}
func TestAppStatusIsReplaced(t *testing.T) {
original := &v1alpha1.ApplicationStatus{Sync: v1alpha1.SyncStatus{
ComparedTo: v1alpha1.ComparedTo{
Destination: v1alpha1.ApplicationDestination{
Server: "https://mycluster",
},
},
}}
updated := &v1alpha1.ApplicationStatus{Sync: v1alpha1.SyncStatus{
ComparedTo: v1alpha1.ComparedTo{
Destination: v1alpha1.ApplicationDestination{
Name: "mycluster",
},
},
}}
patchData, ok, err := createMergePatch(original, updated)
require.NoError(t, err)
require.True(t, ok)
patchObj := map[string]interface{}{}
require.NoError(t, json.Unmarshal(patchData, &patchObj))
val, has, err := unstructured.NestedFieldNoCopy(patchObj, "sync", "comparedTo", "destination", "server")
require.NoError(t, err)
require.True(t, has)
require.Nil(t, val)
}

View File

@@ -5,7 +5,7 @@ kind: Kustomization
images:
- name: quay.io/argoproj/argocd
newName: quay.io/argoproj/argocd
newTag: v2.8.19
newTag: v2.8.21
resources:
- ./application-controller
- ./dex

View File

@@ -8,7 +8,6 @@ spec:
app.kubernetes.io/name: argocd-redis
policyTypes:
- Ingress
- Egress
ingress:
- from:
- podSelector:
@@ -23,9 +22,3 @@ spec:
ports:
- protocol: TCP
port: 6379
egress:
- ports:
- port: 53
protocol: UDP
- port: 53
protocol: TCP

View File

@@ -18914,7 +18914,7 @@ spec:
key: applicationsetcontroller.allowed.scm.providers
name: argocd-cmd-params-cm
optional: true
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
name: argocd-applicationset-controller
ports:
@@ -19032,7 +19032,7 @@ spec:
- argocd
- admin
- redis-initial-password
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: IfNotPresent
name: secret-init
securityContext:
@@ -19243,7 +19243,7 @@ spec:
value: /helm-working-dir
- name: HELM_DATA_HOME
value: /helm-working-dir
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
@@ -19295,7 +19295,7 @@ spec:
- -n
- /usr/local/bin/argocd
- /var/run/argocd/argocd-cmp-server
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
name: copyutil
securityContext:
allowPrivilegeEscalation: false
@@ -19525,7 +19525,7 @@ spec:
key: controller.ignore.normalizer.jq.timeout
name: argocd-cmd-params-cm
optional: true
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
name: argocd-application-controller
ports:
@@ -19607,12 +19607,6 @@ kind: NetworkPolicy
metadata:
name: argocd-redis-network-policy
spec:
egress:
- ports:
- port: 53
protocol: UDP
- port: 53
protocol: TCP
ingress:
- from:
- podSelector:
@@ -19632,7 +19626,6 @@ spec:
app.kubernetes.io/name: argocd-redis
policyTypes:
- Ingress
- Egress
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy

View File

@@ -12,4 +12,4 @@ resources:
images:
- name: quay.io/argoproj/argocd
newName: quay.io/argoproj/argocd
newTag: v2.8.19
newTag: v2.8.21

View File

@@ -12,7 +12,7 @@ patches:
images:
- name: quay.io/argoproj/argocd
newName: quay.io/argoproj/argocd
newTag: v2.8.19
newTag: v2.8.21
resources:
- ../../base/application-controller
- ../../base/applicationset-controller

View File

@@ -8,7 +8,6 @@ spec:
app.kubernetes.io/name: argocd-redis-ha-haproxy
policyTypes:
- Ingress
- Egress
ingress:
- from:
- podSelector:
@@ -25,18 +24,4 @@ spec:
protocol: TCP
- port: 26379
protocol: TCP
egress:
- to:
- podSelector:
matchLabels:
app.kubernetes.io/name: argocd-redis-ha
ports:
- port: 6379
protocol: TCP
- port: 26379
protocol: TCP
- ports:
- port: 53
protocol: UDP
- port: 53
protocol: TCP

View File

@@ -20141,7 +20141,7 @@ spec:
key: applicationsetcontroller.allowed.scm.providers
name: argocd-cmd-params-cm
optional: true
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
name: argocd-applicationset-controller
ports:
@@ -20264,7 +20264,7 @@ spec:
- -n
- /usr/local/bin/argocd
- /shared/argocd-dex
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
name: copyutil
securityContext:
@@ -20340,7 +20340,7 @@ spec:
key: application.namespaces
name: argocd-cmd-params-cm
optional: true
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
livenessProbe:
tcpSocket:
@@ -20454,7 +20454,7 @@ spec:
- argocd
- admin
- redis-initial-password
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: IfNotPresent
name: secret-init
securityContext:
@@ -20693,7 +20693,7 @@ spec:
value: /helm-working-dir
- name: HELM_DATA_HOME
value: /helm-working-dir
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
@@ -20745,7 +20745,7 @@ spec:
- -n
- /usr/local/bin/argocd
- /var/run/argocd/argocd-cmp-server
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
name: copyutil
securityContext:
allowPrivilegeEscalation: false
@@ -21045,7 +21045,7 @@ spec:
key: server.api.content.types
name: argocd-cmd-params-cm
optional: true
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
livenessProbe:
httpGet:
@@ -21302,7 +21302,7 @@ spec:
key: controller.ignore.normalizer.jq.timeout
name: argocd-cmd-params-cm
optional: true
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
name: argocd-application-controller
ports:
@@ -21661,21 +21661,6 @@ kind: NetworkPolicy
metadata:
name: argocd-redis-ha-proxy-network-policy
spec:
egress:
- ports:
- port: 6379
protocol: TCP
- port: 26379
protocol: TCP
to:
- podSelector:
matchLabels:
app.kubernetes.io/name: argocd-redis-ha
- ports:
- port: 53
protocol: UDP
- port: 53
protocol: TCP
ingress:
- from:
- podSelector:
@@ -21697,7 +21682,6 @@ spec:
app.kubernetes.io/name: argocd-redis-ha-haproxy
policyTypes:
- Ingress
- Egress
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy

View File

@@ -1653,7 +1653,7 @@ spec:
key: applicationsetcontroller.allowed.scm.providers
name: argocd-cmd-params-cm
optional: true
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
name: argocd-applicationset-controller
ports:
@@ -1776,7 +1776,7 @@ spec:
- -n
- /usr/local/bin/argocd
- /shared/argocd-dex
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
name: copyutil
securityContext:
@@ -1852,7 +1852,7 @@ spec:
key: application.namespaces
name: argocd-cmd-params-cm
optional: true
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
livenessProbe:
tcpSocket:
@@ -1966,7 +1966,7 @@ spec:
- argocd
- admin
- redis-initial-password
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: IfNotPresent
name: secret-init
securityContext:
@@ -2205,7 +2205,7 @@ spec:
value: /helm-working-dir
- name: HELM_DATA_HOME
value: /helm-working-dir
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
@@ -2257,7 +2257,7 @@ spec:
- -n
- /usr/local/bin/argocd
- /var/run/argocd/argocd-cmp-server
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
name: copyutil
securityContext:
allowPrivilegeEscalation: false
@@ -2557,7 +2557,7 @@ spec:
key: server.api.content.types
name: argocd-cmd-params-cm
optional: true
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
livenessProbe:
httpGet:
@@ -2814,7 +2814,7 @@ spec:
key: controller.ignore.normalizer.jq.timeout
name: argocd-cmd-params-cm
optional: true
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
name: argocd-application-controller
ports:
@@ -3173,21 +3173,6 @@ kind: NetworkPolicy
metadata:
name: argocd-redis-ha-proxy-network-policy
spec:
egress:
- ports:
- port: 6379
protocol: TCP
- port: 26379
protocol: TCP
to:
- podSelector:
matchLabels:
app.kubernetes.io/name: argocd-redis-ha
- ports:
- port: 53
protocol: UDP
- port: 53
protocol: TCP
ingress:
- from:
- podSelector:
@@ -3209,7 +3194,6 @@ spec:
app.kubernetes.io/name: argocd-redis-ha-haproxy
policyTypes:
- Ingress
- Egress
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy

View File

@@ -19264,7 +19264,7 @@ spec:
key: applicationsetcontroller.allowed.scm.providers
name: argocd-cmd-params-cm
optional: true
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
name: argocd-applicationset-controller
ports:
@@ -19387,7 +19387,7 @@ spec:
- -n
- /usr/local/bin/argocd
- /shared/argocd-dex
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
name: copyutil
securityContext:
@@ -19463,7 +19463,7 @@ spec:
key: application.namespaces
name: argocd-cmd-params-cm
optional: true
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
livenessProbe:
tcpSocket:
@@ -19563,7 +19563,7 @@ spec:
- argocd
- admin
- redis-initial-password
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: IfNotPresent
name: secret-init
securityContext:
@@ -19774,7 +19774,7 @@ spec:
value: /helm-working-dir
- name: HELM_DATA_HOME
value: /helm-working-dir
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
@@ -19826,7 +19826,7 @@ spec:
- -n
- /usr/local/bin/argocd
- /var/run/argocd/argocd-cmp-server
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
name: copyutil
securityContext:
allowPrivilegeEscalation: false
@@ -20124,7 +20124,7 @@ spec:
key: server.api.content.types
name: argocd-cmd-params-cm
optional: true
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
livenessProbe:
httpGet:
@@ -20381,7 +20381,7 @@ spec:
key: controller.ignore.normalizer.jq.timeout
name: argocd-cmd-params-cm
optional: true
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
name: argocd-application-controller
ports:
@@ -20510,12 +20510,6 @@ kind: NetworkPolicy
metadata:
name: argocd-redis-network-policy
spec:
egress:
- ports:
- port: 53
protocol: UDP
- port: 53
protocol: TCP
ingress:
- from:
- podSelector:
@@ -20535,7 +20529,6 @@ spec:
app.kubernetes.io/name: argocd-redis
policyTypes:
- Ingress
- Egress
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy

View File

@@ -776,7 +776,7 @@ spec:
key: applicationsetcontroller.allowed.scm.providers
name: argocd-cmd-params-cm
optional: true
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
name: argocd-applicationset-controller
ports:
@@ -899,7 +899,7 @@ spec:
- -n
- /usr/local/bin/argocd
- /shared/argocd-dex
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
name: copyutil
securityContext:
@@ -975,7 +975,7 @@ spec:
key: application.namespaces
name: argocd-cmd-params-cm
optional: true
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
livenessProbe:
tcpSocket:
@@ -1075,7 +1075,7 @@ spec:
- argocd
- admin
- redis-initial-password
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: IfNotPresent
name: secret-init
securityContext:
@@ -1286,7 +1286,7 @@ spec:
value: /helm-working-dir
- name: HELM_DATA_HOME
value: /helm-working-dir
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
@@ -1338,7 +1338,7 @@ spec:
- -n
- /usr/local/bin/argocd
- /var/run/argocd/argocd-cmp-server
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
name: copyutil
securityContext:
allowPrivilegeEscalation: false
@@ -1636,7 +1636,7 @@ spec:
key: server.api.content.types
name: argocd-cmd-params-cm
optional: true
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
livenessProbe:
httpGet:
@@ -1893,7 +1893,7 @@ spec:
key: controller.ignore.normalizer.jq.timeout
name: argocd-cmd-params-cm
optional: true
image: quay.io/argoproj/argocd:v2.8.19
image: quay.io/argoproj/argocd:v2.8.21
imagePullPolicy: Always
name: argocd-application-controller
ports:
@@ -2022,12 +2022,6 @@ kind: NetworkPolicy
metadata:
name: argocd-redis-network-policy
spec:
egress:
- ports:
- port: 53
protocol: UDP
- port: 53
protocol: TCP
ingress:
- from:
- podSelector:
@@ -2047,7 +2041,6 @@ spec:
app.kubernetes.io/name: argocd-redis
policyTypes:
- Ingress
- Egress
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy

View File

@@ -2153,7 +2153,6 @@ message SyncStatus {
optional string status = 1;
// ComparedTo contains information about what has been compared
// +patchStrategy=replace
optional ComparedTo comparedTo = 2;
// Revision contains information about the revision the comparison has been performed to

View File

@@ -7381,11 +7381,6 @@ func schema_pkg_apis_application_v1alpha1_SyncStatus(ref common.ReferenceCallbac
},
},
"comparedTo": {
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
"x-kubernetes-patch-strategy": "replace",
},
},
SchemaProps: spec.SchemaProps{
Description: "ComparedTo contains information about what has been compared",
Default: map[string]interface{}{},

View File

@@ -1422,8 +1422,7 @@ type SyncStatus struct {
// Status is the sync state of the comparison
Status SyncStatusCode `json:"status" protobuf:"bytes,1,opt,name=status,casttype=SyncStatusCode"`
// ComparedTo contains information about what has been compared
// +patchStrategy=replace
ComparedTo ComparedTo `json:"comparedTo,omitempty" protobuf:"bytes,2,opt,name=comparedTo" patchStrategy:"replace"`
ComparedTo ComparedTo `json:"comparedTo,omitempty" protobuf:"bytes,2,opt,name=comparedTo"`
// Revision contains information about the revision the comparison has been performed to
Revision string `json:"revision,omitempty" protobuf:"bytes,3,opt,name=revision"`
// Revisions contains information about the revisions of multiple sources the comparison has been performed to

View File

@@ -11,13 +11,10 @@ import (
"testing"
"time"
"github.com/argoproj/gitops-engine/pkg/diff"
"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/pointer"
argocdcommon "github.com/argoproj/argo-cd/v2/common"
"k8s.io/utils/pointer"
"github.com/argoproj/gitops-engine/pkg/sync/common"
"github.com/stretchr/testify/assert"
@@ -3613,85 +3610,3 @@ func TestOptionalMapEquality(t *testing.T) {
})
}
}
<<<<<<< HEAD
=======
func TestApplicationSpec_GetSourcePtrByIndex(t *testing.T) {
testCases := []struct {
name string
application ApplicationSpec
sourceIndex int
expected *ApplicationSource
}{
{
name: "HasMultipleSources_ReturnsFirstSource",
application: ApplicationSpec{
Sources: []ApplicationSource{
{RepoURL: "https://github.com/argoproj/test1.git"},
{RepoURL: "https://github.com/argoproj/test2.git"},
},
},
sourceIndex: 0,
expected: &ApplicationSource{RepoURL: "https://github.com/argoproj/test1.git"},
},
{
name: "HasMultipleSources_ReturnsSourceAtIndex",
application: ApplicationSpec{
Sources: []ApplicationSource{
{RepoURL: "https://github.com/argoproj/test1.git"},
{RepoURL: "https://github.com/argoproj/test2.git"},
},
},
sourceIndex: 1,
expected: &ApplicationSource{RepoURL: "https://github.com/argoproj/test2.git"},
},
{
name: "HasSingleSource_ReturnsSource",
application: ApplicationSpec{
Source: &ApplicationSource{RepoURL: "https://github.com/argoproj/test.git"},
},
sourceIndex: 0,
expected: &ApplicationSource{RepoURL: "https://github.com/argoproj/test.git"},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
actual := tc.application.GetSourcePtrByIndex(tc.sourceIndex)
assert.Equal(t, tc.expected, actual)
})
}
}
func TestHelmValuesObjectHasReplaceStrategy(t *testing.T) {
app := Application{
Status: ApplicationStatus{Sync: SyncStatus{ComparedTo: ComparedTo{
Source: ApplicationSource{
Helm: &ApplicationSourceHelm{
ValuesObject: &runtime.RawExtension{
Object: &unstructured.Unstructured{Object: map[string]interface{}{"key": []string{"value"}}},
},
},
},
}}},
}
appModified := Application{
Status: ApplicationStatus{Sync: SyncStatus{ComparedTo: ComparedTo{
Source: ApplicationSource{
Helm: &ApplicationSourceHelm{
ValuesObject: &runtime.RawExtension{
Object: &unstructured.Unstructured{Object: map[string]interface{}{"key": []string{"value-modified1"}}},
},
},
},
}}},
}
patch, _, err := diff.CreateTwoWayMergePatch(
app,
appModified, Application{})
require.NoError(t, err)
assert.Equal(t, `{"status":{"sync":{"comparedTo":{"destination":{},"source":{"helm":{"valuesObject":{"key":["value-modified1"]}},"repoURL":""}}}}}`, string(patch))
}
>>>>>>> ec09937fe (fix: status.sync.comparedTo should use replace patch strategy (#18061))

View File

@@ -67,7 +67,7 @@ func TestClusterAddPermissionDenied(t *testing.T) {
Create().
Then().
AndCLIOutput(func(output string, err error) {
assert.True(t, strings.Contains(err.Error(), "PermissionDenied desc = permission denied: clusters, create"))
assert.Contains(t, err.Error(), "PermissionDenied desc = permission denied")
})
}
@@ -232,7 +232,7 @@ func TestClusterDeleteDenied(t *testing.T) {
DeleteByName().
Then().
AndCLIOutput(func(output string, err error) {
assert.True(t, strings.Contains(err.Error(), "PermissionDenied desc = permission denied: clusters, delete"))
assert.Contains(t, err.Error(), "PermissionDenied desc = permission denied")
})
// Attempt to remove cluster creds by server
@@ -246,7 +246,7 @@ func TestClusterDeleteDenied(t *testing.T) {
DeleteByServer().
Then().
AndCLIOutput(func(output string, err error) {
assert.True(t, strings.Contains(err.Error(), "PermissionDenied desc = permission denied: clusters, delete"))
assert.Contains(t, err.Error(), "PermissionDenied desc = permission denied")
})
}

View File

@@ -2849,11 +2849,11 @@ braces@^2.3.1:
to-regex "^3.0.1"
braces@^3.0.1, braces@^3.0.2, braces@~3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
version "3.0.3"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
dependencies:
fill-range "^7.0.1"
fill-range "^7.1.1"
browser-process-hrtime@^1.0.0:
version "1.0.0"
@@ -4479,10 +4479,10 @@ fill-range@^4.0.0:
repeat-string "^1.6.1"
to-regex-range "^2.1.0"
fill-range@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==
fill-range@^7.1.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292"
integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==
dependencies:
to-regex-range "^5.0.1"