diff --git a/USERS.md b/USERS.md index 280cb1f40d..70a53c5d22 100644 --- a/USERS.md +++ b/USERS.md @@ -47,6 +47,7 @@ Currently, the following organizations are **officially** using Argo CD: 1. [Optoro](https://www.optoro.com/) 1. [Peloton Interactive](https://www.onepeloton.com/) 1. [Pipefy](https://www.pipefy.com/) +1. [Preferred Networks](https://preferred.jp/en/) 1. [Prudential](https://prudential.com.sg) 1. [PUBG](https://www.pubg.com) 1. [QuintoAndar](https://quintoandar.com.br) diff --git a/util/db/cluster.go b/util/db/cluster.go index df88c2cd56..d0acb94151 100644 --- a/util/db/cluster.go +++ b/util/db/cluster.go @@ -314,10 +314,13 @@ func clusterToSecret(c *appv1.Cluster, secret *apiv1.Secret) error { // secretToCluster converts a secret into a Cluster object func secretToCluster(s *apiv1.Secret) *appv1.Cluster { var config appv1.ClusterConfig - err := json.Unmarshal(s.Data["config"], &config) - if err != nil { - panic(err) + if len(s.Data["config"]) > 0 { + err := json.Unmarshal(s.Data["config"], &config) + if err != nil { + panic(err) + } } + var namespaces []string for _, ns := range strings.Split(string(s.Data["namespaces"]), ",") { if ns = strings.TrimSpace(ns); ns != "" { diff --git a/util/db/cluster_test.go b/util/db/cluster_test.go index 1f461b840e..1f6d4435e3 100644 --- a/util/db/cluster_test.go +++ b/util/db/cluster_test.go @@ -25,6 +25,46 @@ func Test_serverToSecretName(t *testing.T) { assert.Equal(t, "cluster-foo-752281925", name) } +func Test_secretToCluster(t *testing.T) { + secret := &v1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: "mycluster", + Namespace: fakeNamespace, + }, + Data: map[string][]byte{ + "name": []byte("test"), + "server": []byte("http://mycluster"), + "config": []byte("{\"username\":\"foo\"}"), + }, + } + cluster := secretToCluster(secret) + assert.Equal(t, *cluster, v1alpha1.Cluster{ + Name: "test", + Server: "http://mycluster", + Config: v1alpha1.ClusterConfig{ + Username: "foo", + }, + }) +} + +func Test_secretToCluster_NoConfig(t *testing.T) { + secret := &v1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: "mycluster", + Namespace: fakeNamespace, + }, + Data: map[string][]byte{ + "name": []byte("test"), + "server": []byte("http://mycluster"), + }, + } + cluster := secretToCluster(secret) + assert.Equal(t, *cluster, v1alpha1.Cluster{ + Name: "test", + Server: "http://mycluster", + }) +} + func TestUpdateCluster(t *testing.T) { kubeclientset := fake.NewSimpleClientset(&v1.Secret{ ObjectMeta: metav1.ObjectMeta{