From cca88c74898373822656c3cc3cf98eff05684050 Mon Sep 17 00:00:00 2001 From: Saranya-jena Date: Wed, 19 Jul 2023 09:54:45 +0530 Subject: [PATCH 1/4] fix: updated infra scope from 'infra' to 'cluster' Signed-off-by: Saranya-jena --- .../pkg/chaos_infrastructure/service.go | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go b/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go index 775e6340b69..4ed35340ec1 100644 --- a/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go +++ b/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go @@ -779,11 +779,11 @@ func (in *infraService) GetInfraStats(ctx context.Context, projectID string) (*m groupByInfraStatusStage := bson.D{ { "$group", bson.D{ - {"_id", "$is_active"}, - {"count", bson.D{ - {"$sum", 1}, - }}, - }, + {"_id", "$is_active"}, + {"count", bson.D{ + {"$sum", 1}, + }}, + }, }, } @@ -791,11 +791,11 @@ func (in *infraService) GetInfraStats(ctx context.Context, projectID string) (*m groupByInfraConfirmedStage := bson.D{ { "$group", bson.D{ - {"_id", "$is_infra_confirmed"}, - {"count", bson.D{ - {"$sum", 1}, - }}, - }, + {"_id", "$is_infra_confirmed"}, + {"count", bson.D{ + {"$sum", 1}, + }}, + }, }, } @@ -1075,7 +1075,7 @@ func (in *infraService) GetManifest(token string) ([]byte, int, error) { if !reqinfra.IsRegistered { var respData []byte - if reqinfra.InfraScope == "infra" { + if reqinfra.InfraScope == "cluster" { respData, err = ManifestParser(reqinfra, "manifests/infra", &configurations) } else if reqinfra.InfraScope == "namespace" { From 3baffad8ab66cfc2c2bc502776127cc0267265ef Mon Sep 17 00:00:00 2001 From: Saranya-jena Date: Wed, 19 Jul 2023 10:04:40 +0530 Subject: [PATCH 2/4] fix: updated file path from 'infra' to 'cluster' Signed-off-by: Saranya-jena --- .../pkg/chaos_infrastructure/service.go | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go b/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go index 4ed35340ec1..c1c846a5d58 100644 --- a/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go +++ b/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go @@ -779,11 +779,11 @@ func (in *infraService) GetInfraStats(ctx context.Context, projectID string) (*m groupByInfraStatusStage := bson.D{ { "$group", bson.D{ - {"_id", "$is_active"}, - {"count", bson.D{ - {"$sum", 1}, - }}, - }, + {"_id", "$is_active"}, + {"count", bson.D{ + {"$sum", 1}, + }}, + }, }, } @@ -791,11 +791,11 @@ func (in *infraService) GetInfraStats(ctx context.Context, projectID string) (*m groupByInfraConfirmedStage := bson.D{ { "$group", bson.D{ - {"_id", "$is_infra_confirmed"}, - {"count", bson.D{ - {"$sum", 1}, - }}, - }, + {"_id", "$is_infra_confirmed"}, + {"count", bson.D{ + {"$sum", 1}, + }}, + }, }, } @@ -1077,7 +1077,7 @@ func (in *infraService) GetManifest(token string) ([]byte, int, error) { var respData []byte if reqinfra.InfraScope == "cluster" { - respData, err = ManifestParser(reqinfra, "manifests/infra", &configurations) + respData, err = ManifestParser(reqinfra, "manifests/cluster", &configurations) } else if reqinfra.InfraScope == "namespace" { respData, err = ManifestParser(reqinfra, "manifests/namespace", &configurations) } else { @@ -1125,7 +1125,7 @@ func (in *infraService) GetManifestWithInfraID(infraID string, accessKey string) var respData []byte if reqinfra.InfraScope == clusterScope { - respData, err = ManifestParser(reqinfra, "manifests/infra", &configurations) + respData, err = ManifestParser(reqinfra, "manifests/cluster", &configurations) } else if reqinfra.InfraScope == namespaceScope { respData, err = ManifestParser(reqinfra, "manifests/namespace", &configurations) } else { From 8d426004daccfcacc2f7b48b6b9bf54465617008 Mon Sep 17 00:00:00 2001 From: Saranya-jena Date: Wed, 19 Jul 2023 12:16:05 +0530 Subject: [PATCH 3/4] updated mongo query field Signed-off-by: Saranya-jena --- chaoscenter/authentication/pkg/project/repository.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chaoscenter/authentication/pkg/project/repository.go b/chaoscenter/authentication/pkg/project/repository.go index 001aa16b936..298f6a97943 100644 --- a/chaoscenter/authentication/pkg/project/repository.go +++ b/chaoscenter/authentication/pkg/project/repository.go @@ -81,7 +81,7 @@ func (r repository) GetProjectsByUserID(userID string, isOwner bool) ([]*entitie }}} } else { query = bson.D{ - {"removed_at", ""}, + {"is_removed", false}, {"members", bson.D{ {"$elemMatch", bson.D{ {"user_id", userID}, From fe167d663857e2120e3fa8ac3f1e2045e0f3ecab Mon Sep 17 00:00:00 2001 From: Saranya-jena Date: Wed, 19 Jul 2023 12:24:13 +0530 Subject: [PATCH 4/4] added constants for infra scope Signed-off-by: Saranya-jena --- .../pkg/chaos_infrastructure/infra_utils.go | 8 ++++---- .../server/pkg/chaos_infrastructure/service.go | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/chaoscenter/graphql/server/pkg/chaos_infrastructure/infra_utils.go b/chaoscenter/graphql/server/pkg/chaos_infrastructure/infra_utils.go index e2b435b47dd..d457ab57e7a 100644 --- a/chaoscenter/graphql/server/pkg/chaos_infrastructure/infra_utils.go +++ b/chaoscenter/graphql/server/pkg/chaos_infrastructure/infra_utils.go @@ -48,22 +48,22 @@ func GetK8sInfraYaml(infra dbChaosInfra.ChaosInfra) ([]byte, error) { config.ServerEndpoint = endpoint var scope = utils.Config.ChaosCenterScope - if scope == clusterScope && utils.Config.TlsSecretName != "" { + if scope == ClusterScope && utils.Config.TlsSecretName != "" { config.TLSCert, err = k8s.GetTLSCert(utils.Config.TlsSecretName) if err != nil { return nil, err } } - if scope == namespaceScope { + if scope == NamespaceScope { config.TLSCert = utils.Config.TlsCertB64 } if !infra.IsRegistered { var respData []byte - if infra.InfraScope == "cluster" { + if infra.InfraScope == ClusterScope { respData, err = ManifestParser(infra, "manifests/cluster", &config) - } else if infra.InfraScope == "namespace" { + } else if infra.InfraScope == NamespaceScope { respData, err = ManifestParser(infra, "manifests/namespace", &config) } else { logrus.Error("INFRA_SCOPE env is empty!") diff --git a/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go b/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go index c1c846a5d58..4c9039d2046 100644 --- a/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go +++ b/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go @@ -32,8 +32,8 @@ import ( const ( // CIVersion specifies the version tag used for ci builds CIVersion = "ci" - clusterScope string = "cluster" - namespaceScope string = "namespace" + ClusterScope string = "cluster" + NamespaceScope string = "namespace" ) type Service interface { @@ -1062,14 +1062,14 @@ func (in *infraService) GetManifest(token string) ([]byte, int, error) { } var scope = utils.Config.ChaosCenterScope - if scope == clusterScope && utils.Config.TlsSecretName != "" { + if scope == ClusterScope && utils.Config.TlsSecretName != "" { configurations.TLSCert, err = k8s.GetTLSCert(utils.Config.TlsSecretName) if err != nil { return nil, http.StatusInternalServerError, err } } - if scope == namespaceScope { + if scope == NamespaceScope { configurations.TLSCert = utils.Config.TlsCertB64 } @@ -1112,21 +1112,21 @@ func (in *infraService) GetManifestWithInfraID(infraID string, accessKey string) } var scope = utils.Config.ChaosCenterScope - if scope == clusterScope && utils.Config.TlsSecretName != "" { + if scope == ClusterScope && utils.Config.TlsSecretName != "" { configurations.TLSCert, err = k8s.GetTLSCert(utils.Config.TlsSecretName) if err != nil { return nil, fmt.Errorf("failed to retrieve the tls cert %v", err) } } - if scope == namespaceScope { + if scope == NamespaceScope { configurations.TLSCert = utils.Config.TlsCertB64 } var respData []byte - if reqinfra.InfraScope == clusterScope { + if reqinfra.InfraScope == ClusterScope { respData, err = ManifestParser(reqinfra, "manifests/cluster", &configurations) - } else if reqinfra.InfraScope == namespaceScope { + } else if reqinfra.InfraScope == NamespaceScope { respData, err = ManifestParser(reqinfra, "manifests/namespace", &configurations) } else { logrus.Error("INFRA_SCOPE env is empty")