Skip to content

Commit 0b4bc78

Browse files
CalvinaudS-ayanidePriteshKiriJonsy13
authored
Update chaoscenter server to allow further customization of default ChaosHub (#5066)
* Update chaoscenter server to allow further customization of default chaoshub - Update Configuration to read new environment variables - Update listDefaultHubs function to include new parameters for the default chaoshub - Update SyncDefaultChaosHubs to retrieve the new parameters from listDefaultHubs Signed-off-by: Calvin Audier <[email protected]> * Update to use environment variable for the name of the default chaoshub Signed-off-by: Calvin Audier <[email protected]> * Run goimports on chaoshub/service.go Signed-off-by: Calvin Audier <[email protected]> --------- Signed-off-by: Calvin Audier <[email protected]> Co-authored-by: Sayan Mondal <[email protected]> Co-authored-by: Pritesh Kiri <[email protected]> Co-authored-by: Vedant Shrotria <[email protected]>
1 parent 07b6a2c commit 0b4bc78

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

chaoscenter/graphql/server/pkg/chaoshub/service.go

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -963,11 +963,17 @@ func (c *chaosHubService) GetChaosHubStats(ctx context.Context, projectID string
963963

964964
func (c *chaosHubService) listDefaultHubs() *model.ChaosHub {
965965
defaultHubs := &model.ChaosHub{
966-
ID: DefaultHubID,
967-
Name: "Litmus ChaosHub",
968-
RepoURL: utils.Config.DefaultHubGitURL,
969-
RepoBranch: utils.Config.DefaultHubBranchName,
970-
IsDefault: true,
966+
ID: DefaultHubID,
967+
Name: utils.Config.DefaultHubName,
968+
RepoURL: utils.Config.DefaultHubGitURL,
969+
RepoBranch: utils.Config.DefaultHubBranchName,
970+
IsPrivate: utils.Config.DefaultHubIsPrivate,
971+
AuthType: model.AuthType(utils.Config.DefaultHubAuthType),
972+
Token: &utils.Config.DefaultHubToken,
973+
UserName: &utils.Config.DefaultHubUserName,
974+
Password: &utils.Config.DefaultHubPassword,
975+
SSHPrivateKey: &utils.Config.DefaultHubSshPrivateKey,
976+
IsDefault: true,
971977
}
972978
return defaultHubs
973979
}
@@ -978,17 +984,25 @@ func (c *chaosHubService) SyncDefaultChaosHubs() {
978984
defaultHub := c.listDefaultHubs()
979985

980986
chartsInput := model.CloningInput{
981-
Name: defaultHub.Name,
982-
RepoURL: defaultHub.RepoURL,
983-
RepoBranch: defaultHub.RepoBranch,
984-
IsDefault: true,
987+
Name: defaultHub.Name,
988+
RepoURL: defaultHub.RepoURL,
989+
RepoBranch: defaultHub.RepoBranch,
990+
IsPrivate: defaultHub.IsPrivate,
991+
AuthType: defaultHub.AuthType,
992+
Token: defaultHub.Token,
993+
UserName: defaultHub.UserName,
994+
Password: defaultHub.Password,
995+
SSHPrivateKey: defaultHub.SSHPrivateKey,
996+
IsDefault: true,
985997
}
986998
err := chaosHubOps.GitSyncDefaultHub(chartsInput)
987999
if err != nil {
9881000
log.WithFields(log.Fields{
9891001
"repoUrl": defaultHub.RepoURL,
9901002
"repoBranch": defaultHub.RepoBranch,
9911003
"hubName": defaultHub.Name,
1004+
"isPrivate": defaultHub.IsPrivate,
1005+
"AuthType": defaultHub.AuthType,
9921006
}).WithError(err).Error("failed to sync default chaos hubs")
9931007
}
9941008
// Syncing Completed

chaoscenter/graphql/server/utils/variables.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,16 @@ type Configuration struct {
2929
RestPort string `split_words:"true" default:"8080"`
3030
GrpcPort string `split_words:"true" default:"8000"`
3131
InfraCompatibleVersions string `required:"true" split_words:"true"`
32-
DefaultHubGitURL string `required:"true" default:"https://github.com/litmuschaos/chaos-charts"`
3332
GitUsername string `required:"true" split_words:"true" default:"litmus"`
33+
DefaultHubName string `required:"true" split_words:"true" default:"Litmus ChaosHub"`
34+
DefaultHubGitURL string `required:"true" default:"https://github.com/litmuschaos/chaos-charts"`
3435
DefaultHubBranchName string `required:"true" split_words:"true"`
36+
DefaultHubIsPrivate bool `required:"true" split_words:"true" default:"false"`
37+
DefaultHubAuthType string `split_words:"true"`
38+
DefaultHubToken string `split_words:"true"`
39+
DefaultHubUserName string `split_words:"true"`
40+
DefaultHubPassword string `split_words:"true"`
41+
DefaultHubSshPrivateKey string `split_words:"true"`
3542
CustomChaosHubPath string `split_words:"true" default:"/tmp/"`
3643
DefaultChaosHubPath string `split_words:"true" default:"/tmp/default/"`
3744
EnableGQLIntrospection string `split_words:"true" default:"false"`

0 commit comments

Comments
 (0)