Skip to content

Commit

Permalink
Add the ability to ignoreDifferences in an argoCD application manifest (
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Suderman authored Dec 5, 2022
1 parent cb48954 commit 069b95f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
22 changes: 18 additions & 4 deletions pkg/course/argocd.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ type ArgoApplicationSpecDestination struct {
}

type ArgoApplicationSpec struct {
Source ArgoApplicationSpecSource `yaml:"source"`
Destination ArgoApplicationSpecDestination `yaml:"destination"`
Project string `yaml:"project"`
SyncPolicy ArgoApplicationSpecSyncPolicy `yaml:"syncPolicy,omitempty"`
Source ArgoApplicationSpecSource `yaml:"source"`
Destination ArgoApplicationSpecDestination `yaml:"destination"`
Project string `yaml:"project"`
SyncPolicy ArgoApplicationSpecSyncPolicy `yaml:"syncPolicy,omitempty"`
IgnoreDifferences []ArgoResourceIgnoreDifferences `yaml:"ignoreDifferences,omitempty"`
}

// ArgoApplicationMetadata contains the k8s metadata for the gitops agent CustomResource.
Expand All @@ -68,3 +69,16 @@ type ArgoApplication struct {
Metadata ArgoApplicationMetadata `yaml:"metadata"`
Spec ArgoApplicationSpec `yaml:"spec"`
}

// ResourceIgnoreDifferences contains resource filter and list of json paths which should be ignored during comparison with live state.
type ArgoResourceIgnoreDifferences struct {
Group string `yaml:"group,omitempty"`
Kind string `yaml:"kind"`
Name string `yaml:"name,omitempty"`
Namespace string `yaml:"namespace,omitempty"`
JSONPointers []string `yaml:"jsonPointers,omitempty"`
JQPathExpressions []string `yaml:"jqPathExpressions,omitempty"`
// ManagedFieldsManagers is a list of trusted managers. Fields mutated by those managers will take precedence over the
// desired state defined in the SCM and won't be displayed in diffs
ManagedFieldsManagers []string `yaml:"managedFieldsManagers,omitempty"`
}
5 changes: 2 additions & 3 deletions pkg/course/course.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"strconv"
"strings"
Expand Down Expand Up @@ -348,7 +347,7 @@ func OpenCourseFile(fileName string, schema []byte) (*FileV2, error) {
// OpenCourseV2 opens a v2 schema course file
func OpenCourseV2(fileName string) (*FileV2, error) {
courseFile := &FileV2{}
data, err := ioutil.ReadFile(fileName)
data, err := os.ReadFile(fileName)
if err != nil {
return nil, err
}
Expand All @@ -367,7 +366,7 @@ func OpenCourseV2(fileName string) (*FileV2, error) {
// OpenCourseV1 opens a v1 schema course file
func OpenCourseV1(fileName string) (*FileV1, error) {
courseFile := &FileV1{}
data, err := ioutil.ReadFile(fileName)
data, err := os.ReadFile(fileName)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/reckoner/plot.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ package reckoner

import (
"fmt"
"io/ioutil"
"os"
"strings"

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

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

0 comments on commit 069b95f

Please sign in to comment.