Skip to content

Conversation

crenshaw-dev
Copy link
Member

@crenshaw-dev crenshaw-dev commented Dec 16, 2024

The clusterUtils function is almost identical to the DB function. Green in the diff below is the DB function.

Since the DB function populates Labels and Annotations, I'm dropping those just to be safe. I'm leaving the logic that populates the Project and ClusterResources fields, because I can't think of a reason why populating those could be problematic.

1,2c1,2
< // secretToCluster converts a secret into a Cluster object
< func secretToCluster(s *corev1.Secret) (*appv1.Cluster, error) {
---
> // SecretToCluster converts a secret into a Cluster object
> func SecretToCluster(s *apiv1.Secret) (*appv1.Cluster, error) {
5,7c5,7
< 		if err := json.Unmarshal(s.Data["config"], &config); err != nil {
< 			// This line has changed from the original Argo CD: now returns an error rather than panicing.
< 			return nil, err
---
> 		err := json.Unmarshal(s.Data["config"], &config)
> 		if err != nil {
> 			return nil, fmt.Errorf("failed to unmarshal cluster config: %w", err)
33a34,48
> 
> 	// copy labels and annotations excluding system ones
> 	labels := map[string]string{}
> 	if s.Labels != nil {
> 		labels = maps.Clone(s.Labels)
> 		delete(labels, common.LabelKeySecretType)
> 	}
> 	annotations := map[string]string{}
> 	if s.Annotations != nil {
> 		annotations = maps.Clone(s.Annotations)
> 		// delete system annotations
> 		delete(annotations, apiv1.LastAppliedConfigAnnotation)
> 		delete(annotations, common.AnnotationKeyManagedBy)
> 	}
> 
38a54
> 		ClusterResources:   string(s.Data["clusterResources"]) == "true",
41a58,60
> 		Project:            string(s.Data["project"]),
> 		Labels:             labels,
> 		Annotations:        annotations,

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Copy link

bunnyshell bot commented Dec 16, 2024

❌ Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Copy link

codecov bot commented Dec 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (master@030a7be). Learn more about missing BASE report.
Report is 436 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master   #21192   +/-   ##
=========================================
  Coverage          ?   55.21%           
=========================================
  Files             ?      324           
  Lines             ?    55625           
  Branches          ?        0           
=========================================
  Hits              ?    30714           
  Misses            ?    22285           
  Partials          ?     2626           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@crenshaw-dev crenshaw-dev marked this pull request as ready for review December 16, 2024 15:40
@crenshaw-dev crenshaw-dev requested a review from a team as a code owner December 16, 2024 15:40
Copy link
Member

@ishitasequeira ishitasequeira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense!! LGTM!!

@ishitasequeira ishitasequeira merged commit 0de5f60 into argoproj:master Dec 17, 2024
29 checks passed
dudo pushed a commit to dudo/argo-cd that referenced this pull request Jan 18, 2025
* chore(appset): reduce dupe code w/ DB

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

* fix imports

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

---------

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Signed-off-by: Brett C. Dudo <brett@dudo.io>
revitalbarletz pushed a commit to revitalbarletz/argo-cd that referenced this pull request Jan 20, 2025
* chore(appset): reduce dupe code w/ DB

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

* fix imports

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

---------

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
vasilegroza pushed a commit to vasilegroza/argo-cd that referenced this pull request Feb 27, 2025
* chore(appset): reduce dupe code w/ DB

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

* fix imports

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

---------

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants