Skip to content

Commit

Permalink
fix: updated infra scope from 'infra' to 'cluster' (#4093)
Browse files Browse the repository at this point in the history
* fix: updated infra scope from 'infra' to 'cluster'

Signed-off-by: Saranya-jena <[email protected]>

* fix: updated file path from 'infra' to 'cluster'

Signed-off-by: Saranya-jena <[email protected]>

* updated mongo query field

Signed-off-by: Saranya-jena <[email protected]>

* added constants for infra scope

Signed-off-by: Saranya-jena <[email protected]>

---------

Signed-off-by: Saranya-jena <[email protected]>
  • Loading branch information
Saranya-jena authored Jul 19, 2023
1 parent 20f1ba2 commit da2ab7e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion chaoscenter/authentication/pkg/project/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down
22 changes: 11 additions & 11 deletions chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -1062,22 +1062,22 @@ 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
}

if !reqinfra.IsRegistered {
var respData []byte
if reqinfra.InfraScope == "infra" {
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 {
Expand Down Expand Up @@ -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 {
respData, err = ManifestParser(reqinfra, "manifests/infra", &configurations)
} else if reqinfra.InfraScope == namespaceScope {
if reqinfra.InfraScope == ClusterScope {
respData, err = ManifestParser(reqinfra, "manifests/cluster", &configurations)
} else if reqinfra.InfraScope == NamespaceScope {
respData, err = ManifestParser(reqinfra, "manifests/namespace", &configurations)
} else {
logrus.Error("INFRA_SCOPE env is empty")
Expand Down

0 comments on commit da2ab7e

Please sign in to comment.