diff --git a/chaoscenter/graphql/server/pkg/chaoshub/ops/gitops.go b/chaoscenter/graphql/server/pkg/chaoshub/ops/gitops.go index 0a4950efef4..9480b144e6d 100644 --- a/chaoscenter/graphql/server/pkg/chaoshub/ops/gitops.go +++ b/chaoscenter/graphql/server/pkg/chaoshub/ops/gitops.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/utils" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" @@ -284,7 +285,7 @@ func (c ChaosHubConfig) generateAuthMethod() (transport.AuthMethod, error) { var auth transport.AuthMethod if c.AuthType == model.AuthTypeToken { auth = &http.BasicAuth{ - Username: "litmus", // this can be anything except an empty string + Username: utils.Config.GitUsername, // must be a non-empty string or 'x-token-auth' for Bitbucket Password: *c.Token, } } else if c.AuthType == model.AuthTypeBasic { diff --git a/chaoscenter/graphql/server/pkg/gitops/gitops.go b/chaoscenter/graphql/server/pkg/gitops/gitops.go index c7b2afda308..8065ace8c30 100644 --- a/chaoscenter/graphql/server/pkg/gitops/gitops.go +++ b/chaoscenter/graphql/server/pkg/gitops/gitops.go @@ -11,6 +11,8 @@ import ( "strings" "time" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/utils" + "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/object" @@ -184,7 +186,7 @@ func (c GitConfig) getAuthMethod() (transport.AuthMethod, error) { case model.AuthTypeToken: return &http.BasicAuth{ - Username: "litmus", // this can be anything except an empty string + Username: utils.Config.GitUsername, // must be a non-empty string or 'x-token-auth' for Bitbucket Password: *c.Token, }, nil diff --git a/chaoscenter/graphql/server/utils/variables.go b/chaoscenter/graphql/server/utils/variables.go index 678c7feb731..3818dc211f4 100644 --- a/chaoscenter/graphql/server/utils/variables.go +++ b/chaoscenter/graphql/server/utils/variables.go @@ -30,6 +30,7 @@ type Configuration struct { GrpcPort string `split_words:"true" default:"8000"` InfraCompatibleVersions string `required:"true" split_words:"true"` DefaultHubGitURL string `required:"true" default:"https://github.com/litmuschaos/chaos-charts"` + GitUsername string `required:"true" split_words:"true" default:"litmus"` DefaultHubBranchName string `required:"true" split_words:"true"` CustomChaosHubPath string `split_words:"true" default:"/tmp/"` DefaultChaosHubPath string `split_words:"true" default:"/tmp/default/"`