Skip to content

Commit

Permalink
Just moving stuff around
Browse files Browse the repository at this point in the history
  • Loading branch information
Oded-B committed Apr 19, 2024
1 parent aef665c commit 94e309f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
18 changes: 9 additions & 9 deletions internal/pkg/argocd/argocd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)

// DiffElement struct to store diff element details, this represents a single k8s object
type DiffElement struct {
ObjectGroup string
ObjectName string
ObjectKind string
ObjectNamespace string
Diff string
}

// DiffResult struct to store diff result
type DiffResult struct {
ComponentPath string
Expand Down Expand Up @@ -144,15 +153,6 @@ func diffLiveVsTargetObject(live, target *unstructured.Unstructured) (string, er
return patch, nil
}

// DiffElement struct to store diff element details, this represents a single k8s object
type DiffElement struct {
ObjectGroup string
ObjectName string
ObjectKind string
ObjectNamespace string
Diff string
}

func getEnv(key, fallback string) string {
if value, ok := os.LookupEnv(key); ok {
return value
Expand Down
12 changes: 6 additions & 6 deletions internal/pkg/argocd/argocd_copied_from_upsteam.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ type resourceInfoProvider struct {
namespacedByGk map[schema.GroupKind]bool
}

// Infer if obj is namespaced or not from corresponding live objects list. If corresponding live object has namespace then target object is also namespaced.
// If live object is missing then it does not matter if target is namespaced or not.
func (p *resourceInfoProvider) IsNamespaced(gk schema.GroupKind) (bool, error) {
return p.namespacedByGk[gk], nil
}

type objKeyLiveTarget struct {
key kube.ResourceKey
live *unstructured.Unstructured
target *unstructured.Unstructured
}

// Infer if obj is namespaced or not from corresponding live objects list. If corresponding live object has namespace then target object is also namespaced.
// If live object is missing then it does not matter if target is namespaced or not.
func (p *resourceInfoProvider) IsNamespaced(gk schema.GroupKind) (bool, error) {
return p.namespacedByGk[gk], nil
}

// copied from https://github.com/argoproj/argo-cd/blob/4f6a8dce80f0accef7ed3b5510e178a6b398b331/cmd/argocd/commands/app.go#L1091-L1109
func groupObjsByKey(localObs []*unstructured.Unstructured, liveObjs []*unstructured.Unstructured, appNamespace string) map[kube.ResourceKey]*unstructured.Unstructured {
namespacedByGk := make(map[schema.GroupKind]bool)
Expand Down

0 comments on commit 94e309f

Please sign in to comment.