Skip to content

Commit 069b95f

Browse files
author
Andrew Suderman
authored
Add the ability to ignoreDifferences in an argoCD application manifest (#655)
1 parent cb48954 commit 069b95f

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

pkg/course/argocd.go

+18-4
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ type ArgoApplicationSpecDestination struct {
4747
}
4848

4949
type ArgoApplicationSpec struct {
50-
Source ArgoApplicationSpecSource `yaml:"source"`
51-
Destination ArgoApplicationSpecDestination `yaml:"destination"`
52-
Project string `yaml:"project"`
53-
SyncPolicy ArgoApplicationSpecSyncPolicy `yaml:"syncPolicy,omitempty"`
50+
Source ArgoApplicationSpecSource `yaml:"source"`
51+
Destination ArgoApplicationSpecDestination `yaml:"destination"`
52+
Project string `yaml:"project"`
53+
SyncPolicy ArgoApplicationSpecSyncPolicy `yaml:"syncPolicy,omitempty"`
54+
IgnoreDifferences []ArgoResourceIgnoreDifferences `yaml:"ignoreDifferences,omitempty"`
5455
}
5556

5657
// ArgoApplicationMetadata contains the k8s metadata for the gitops agent CustomResource.
@@ -68,3 +69,16 @@ type ArgoApplication struct {
6869
Metadata ArgoApplicationMetadata `yaml:"metadata"`
6970
Spec ArgoApplicationSpec `yaml:"spec"`
7071
}
72+
73+
// ResourceIgnoreDifferences contains resource filter and list of json paths which should be ignored during comparison with live state.
74+
type ArgoResourceIgnoreDifferences struct {
75+
Group string `yaml:"group,omitempty"`
76+
Kind string `yaml:"kind"`
77+
Name string `yaml:"name,omitempty"`
78+
Namespace string `yaml:"namespace,omitempty"`
79+
JSONPointers []string `yaml:"jsonPointers,omitempty"`
80+
JQPathExpressions []string `yaml:"jqPathExpressions,omitempty"`
81+
// ManagedFieldsManagers is a list of trusted managers. Fields mutated by those managers will take precedence over the
82+
// desired state defined in the SCM and won't be displayed in diffs
83+
ManagedFieldsManagers []string `yaml:"managedFieldsManagers,omitempty"`
84+
}

pkg/course/course.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"encoding/json"
1717
"errors"
1818
"fmt"
19-
"io/ioutil"
2019
"os"
2120
"strconv"
2221
"strings"
@@ -348,7 +347,7 @@ func OpenCourseFile(fileName string, schema []byte) (*FileV2, error) {
348347
// OpenCourseV2 opens a v2 schema course file
349348
func OpenCourseV2(fileName string) (*FileV2, error) {
350349
courseFile := &FileV2{}
351-
data, err := ioutil.ReadFile(fileName)
350+
data, err := os.ReadFile(fileName)
352351
if err != nil {
353352
return nil, err
354353
}
@@ -367,7 +366,7 @@ func OpenCourseV2(fileName string) (*FileV2, error) {
367366
// OpenCourseV1 opens a v1 schema course file
368367
func OpenCourseV1(fileName string) (*FileV1, error) {
369368
courseFile := &FileV1{}
370-
data, err := ioutil.ReadFile(fileName)
369+
data, err := os.ReadFile(fileName)
371370
if err != nil {
372371
return nil, err
373372
}

pkg/reckoner/plot.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ package reckoner
1414

1515
import (
1616
"fmt"
17-
"io/ioutil"
1817
"os"
1918
"strings"
2019

@@ -235,7 +234,7 @@ func filesArgs(files []string, baseDir string) []string {
235234

236235
// makeTempValuesFile puts the values section into a temporary values file
237236
func makeTempValuesFile(values map[string]interface{}) (*os.File, error) {
238-
tmpFile, err := ioutil.TempFile(os.TempDir(), "reckoner-")
237+
tmpFile, err := os.CreateTemp(os.TempDir(), "reckoner-")
239238
if err != nil {
240239
return nil, fmt.Errorf("cannot create temporary file: %s", err)
241240
}

0 commit comments

Comments
 (0)