Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to ignoreDifferences in an argoCD application manifest #655

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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