Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refectoring: simplify code #4580

Merged
merged 4 commits into from May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion chaoscenter/authentication/pkg/project/repository.go
Expand Up @@ -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{
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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))
}

Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions chaoscenter/graphql/server/pkg/chaoshub/service.go
Expand Up @@ -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()
Expand Down Expand Up @@ -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 := ""
Expand Down Expand Up @@ -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")
}

Expand Down