Skip to content

Commit

Permalink
Imports Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andoriyaprashant committed Jan 18, 2025
1 parent 21a3c8d commit 9efca1b
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 77 deletions.
24 changes: 12 additions & 12 deletions chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (in *infraService) RegisterInfra(c context.Context, projectID string, input

var mongodbOperator mongodb.MongoOperator

operator := NewChaosInfrastructureOperator(mongodbOperator)
operator := NewChaosInfrastructureOperator(mongodbOperator)

token, err := operator.InfraCreateJWT(infraID)
if err != nil {
Expand Down Expand Up @@ -957,17 +957,17 @@ func updateVersionFormat(str string) (int, error) {
// QueryServerVersion is used to fetch the version of the server
func (in *infraService) QueryServerVersion(ctx context.Context) (*model.ServerVersionResponse, error) {
var mongodbOperator mongodb.MongoOperator
configOperator := config.NewConfigOperator(mongodbOperator)

dbVersion, err := configOperator.GetConfig(ctx, "version")
if err != nil {
return nil, err
}
return &model.ServerVersionResponse{
Key: dbVersion.Key,
Value: dbVersion.Value.(string),
}, nil

configOperator := config.NewConfigOperator(mongodbOperator)

dbVersion, err := configOperator.GetConfig(ctx, "version")
if err != nil {
return nil, err
}
return &model.ServerVersionResponse{
Key: dbVersion.Key,
Value: dbVersion.Value.(string),
}, nil
}

// PodLog receives logs from the workflow-agent and publishes to frontend clients
Expand Down
130 changes: 65 additions & 65 deletions chaoscenter/graphql/server/pkg/chaoshub/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,71 +132,71 @@ func (c *chaosHubService) AddChaosHub(ctx context.Context, chaosHub model.Create
}

func (c *chaosHubService) AddRemoteChaosHub(ctx context.Context, chaosHub model.CreateRemoteChaosHub, projectID string) (*model.ChaosHub, error) {
IsExist, err := c.IsChaosHubAvailable(ctx, chaosHub.Name, projectID)
if err != nil {
return nil, err
}
if IsExist == true {
return nil, errors.New("name already exists")
}
description := ""
if chaosHub.Description != nil {
description = *chaosHub.Description
}
currentTime := time.Now()

tkn := ctx.Value(authorization.AuthKey).(string)
username, err := c.authConfigOperator.GetUsername(tkn)

if err != nil {
log.Error("error getting userID: ", err)
return nil, err
}

newHub := &dbSchemaChaosHub.ChaosHub{
ID: uuid.New().String(),
ProjectID: projectID,
RepoURL: chaosHub.RepoURL,
RepoBranch: "",
RemoteHub: chaosHub.RemoteHub,
ResourceDetails: mongodb.ResourceDetails{
Name: chaosHub.Name,
Description: description,
Tags: chaosHub.Tags,
},
IsPrivate: false,
HubType: string(model.HubTypeRemote),
AuthType: string(model.AuthTypeNone),
Audit: mongodb.Audit{
CreatedAt: currentTime.UnixMilli(),
UpdatedAt: currentTime.UnixMilli(),
IsRemoved: false,
CreatedBy: mongodb.UserDetailResponse{
Username: username,
},
UpdatedBy: mongodb.UserDetailResponse{
Username: username,
},
},
LastSyncedAt: time.Now().UnixMilli(),
IsDefault: false,
}

// Adding the new hub into database with the given name.
err = c.chaosHubOperator.CreateChaosHub(ctx, newHub)
if err != nil {
log.Error(err)
return nil, err
}

err = handler.DownloadRemoteHub(chaosHub, projectID)
if err != nil {
err = fmt.Errorf("Hub configurations saved successfully. Failed to connect the remote repo: " + err.Error())
log.Error(err)
return nil, err
}

return newHub.GetOutputChaosHub(), nil
IsExist, err := c.IsChaosHubAvailable(ctx, chaosHub.Name, projectID)
if err != nil {
return nil, err
}
if IsExist == true {
return nil, errors.New("name already exists")
}
description := ""
if chaosHub.Description != nil {
description = *chaosHub.Description
}
currentTime := time.Now()

tkn := ctx.Value(authorization.AuthKey).(string)
username, err := c.authConfigOperator.GetUsername(tkn)

if err != nil {
log.Error("error getting userID: ", err)
return nil, err
}

newHub := &dbSchemaChaosHub.ChaosHub{
ID: uuid.New().String(),
ProjectID: projectID,
RepoURL: chaosHub.RepoURL,
RepoBranch: "",
RemoteHub: chaosHub.RemoteHub,
ResourceDetails: mongodb.ResourceDetails{
Name: chaosHub.Name,
Description: description,
Tags: chaosHub.Tags,
},
IsPrivate: false,
HubType: string(model.HubTypeRemote),
AuthType: string(model.AuthTypeNone),
Audit: mongodb.Audit{
CreatedAt: currentTime.UnixMilli(),
UpdatedAt: currentTime.UnixMilli(),
IsRemoved: false,
CreatedBy: mongodb.UserDetailResponse{
Username: username,
},
UpdatedBy: mongodb.UserDetailResponse{
Username: username,
},
},
LastSyncedAt: time.Now().UnixMilli(),
IsDefault: false,
}

// Adding the new hub into database with the given name.
err = c.chaosHubOperator.CreateChaosHub(ctx, newHub)
if err != nil {
log.Error(err)
return nil, err
}

err = handler.DownloadRemoteHub(chaosHub, projectID)
if err != nil {
err = fmt.Errorf("Hub configurations saved successfully. Failed to connect the remote repo: " + err.Error())
log.Error(err)
return nil, err
}

return newHub.GetOutputChaosHub(), nil
}

// SaveChaosHub is used for Adding a new ChaosHub
Expand Down

0 comments on commit 9efca1b

Please sign in to comment.