diff --git a/chaoscenter/authentication/pkg/project/repository.go b/chaoscenter/authentication/pkg/project/repository.go index 8037eb24374..461f1ecf299 100644 --- a/chaoscenter/authentication/pkg/project/repository.go +++ b/chaoscenter/authentication/pkg/project/repository.go @@ -70,7 +70,7 @@ func (r repository) GetProjectsByUserID(userID string, isOwner bool) ([]*entitie var projects []*entities.Project query := bson.D{} - if isOwner == true { + if isOwner { query = bson.D{ {"members", bson.D{ {"$elemMatch", bson.D{ diff --git a/chaoscenter/authentication/pkg/session/revoked_token_repository.go b/chaoscenter/authentication/pkg/session/revoked_token_repository.go index c69a07225d5..999882561d2 100644 --- a/chaoscenter/authentication/pkg/session/revoked_token_repository.go +++ b/chaoscenter/authentication/pkg/session/revoked_token_repository.go @@ -31,10 +31,8 @@ func (r repository) IsTokenRevoked(encodedToken string) bool { err := r.Collection.FindOne(context.TODO(), bson.M{ "token": encodedToken, }).Decode(&result) - if err != nil { - return false - } - return true + + return err == nil } // NewRevokedTokenRepo creates a new instance of this repository diff --git a/chaoscenter/graphql/server/pkg/chaos_infrastructure/infra_utils.go b/chaoscenter/graphql/server/pkg/chaos_infrastructure/infra_utils.go index 59d5aa59bce..71a6802c5b7 100644 --- a/chaoscenter/graphql/server/pkg/chaos_infrastructure/infra_utils.go +++ b/chaoscenter/graphql/server/pkg/chaos_infrastructure/infra_utils.go @@ -115,11 +115,11 @@ func ManifestParser(infra dbChaosInfra.ChaosInfra, rootPath string, config *Subs ) // Checking if the agent namespace does not exist and its scope of installation is not namespaced - if *infra.InfraNsExists == false && infra.InfraScope != "namespace" { + if !*infra.InfraNsExists && infra.InfraScope != "namespace" { generatedYAML = append(generatedYAML, fmt.Sprintf(namespaceConfig)) } - if *infra.InfraSaExists == false { + if !*infra.InfraSaExists { generatedYAML = append(generatedYAML, fmt.Sprintf(serviceAccountStr)) } @@ -202,7 +202,7 @@ func ManifestParser(infra dbChaosInfra.ChaosInfra, rootPath string, config *Subs newContent = strings.Replace(newContent, "#{CUSTOM_TLS_CERT}", config.TLSCert, -1) newContent = strings.Replace(newContent, "#{START_TIME}", "\""+infra.StartTime+"\"", -1) - if infra.IsInfraConfirmed == true { + if infra.IsInfraConfirmed { newContent = strings.Replace(newContent, "#{IS_INFRA_CONFIRMED}", "\""+"true"+"\"", -1) } else { newContent = strings.Replace(newContent, "#{IS_INFRA_CONFIRMED}", "\""+"false"+"\"", -1) diff --git a/chaoscenter/graphql/server/pkg/chaoshub/service.go b/chaoscenter/graphql/server/pkg/chaoshub/service.go index d2dcc2b994e..a43e09974a3 100644 --- a/chaoscenter/graphql/server/pkg/chaoshub/service.go +++ b/chaoscenter/graphql/server/pkg/chaoshub/service.go @@ -67,7 +67,7 @@ func NewService(chaosHubOperator *dbSchemaChaosHub.Operator) Service { func (c *chaosHubService) AddChaosHub(ctx context.Context, chaosHub model.CreateChaosHubRequest, projectID string) (*model.ChaosHub, error) { if IsExist, err := c.IsChaosHubAvailable(ctx, chaosHub.Name, projectID); err != nil { return nil, err - } else if IsExist == true { + } else if IsExist { return nil, errors.New("Name Already exists") } currentTime := time.Now() @@ -136,7 +136,7 @@ func (c *chaosHubService) AddRemoteChaosHub(ctx context.Context, chaosHub model. if err != nil { return nil, err } - if IsExist == true { + if IsExist { return nil, errors.New("Name Already exists") } description := "" @@ -205,7 +205,7 @@ func (c *chaosHubService) SaveChaosHub(ctx context.Context, chaosHub model.Creat if err != nil { return nil, err } - if IsExist == true { + if IsExist { return nil, errors.New("Name Already exists") }