Skip to content

Commit e1f0d64

Browse files
fix: Add Git Username env variable #4315 (#4915)
Signed-off-by: Thiha Min Thant <[email protected]> Co-authored-by: Saranya Jena <[email protected]>
1 parent c8e145c commit e1f0d64

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

chaoscenter/graphql/server/pkg/chaoshub/ops/gitops.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"strings"
77

88
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model"
9+
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/utils"
910

1011
"github.com/go-git/go-git/v5"
1112
"github.com/go-git/go-git/v5/plumbing"
@@ -284,7 +285,7 @@ func (c ChaosHubConfig) generateAuthMethod() (transport.AuthMethod, error) {
284285
var auth transport.AuthMethod
285286
if c.AuthType == model.AuthTypeToken {
286287
auth = &http.BasicAuth{
287-
Username: "litmus", // this can be anything except an empty string
288+
Username: utils.Config.GitUsername, // must be a non-empty string or 'x-token-auth' for Bitbucket
288289
Password: *c.Token,
289290
}
290291
} else if c.AuthType == model.AuthTypeBasic {

chaoscenter/graphql/server/pkg/gitops/gitops.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
"strings"
1212
"time"
1313

14+
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/utils"
15+
1416
"github.com/go-git/go-git/v5"
1517
"github.com/go-git/go-git/v5/plumbing"
1618
"github.com/go-git/go-git/v5/plumbing/object"
@@ -184,7 +186,7 @@ func (c GitConfig) getAuthMethod() (transport.AuthMethod, error) {
184186

185187
case model.AuthTypeToken:
186188
return &http.BasicAuth{
187-
Username: "litmus", // this can be anything except an empty string
189+
Username: utils.Config.GitUsername, // must be a non-empty string or 'x-token-auth' for Bitbucket
188190
Password: *c.Token,
189191
}, nil
190192

chaoscenter/graphql/server/utils/variables.go

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type Configuration struct {
3030
GrpcPort string `split_words:"true" default:"8000"`
3131
InfraCompatibleVersions string `required:"true" split_words:"true"`
3232
DefaultHubGitURL string `required:"true" default:"https://github.com/litmuschaos/chaos-charts"`
33+
GitUsername string `required:"true" split_words:"true" default:"litmus"`
3334
DefaultHubBranchName string `required:"true" split_words:"true"`
3435
CustomChaosHubPath string `split_words:"true" default:"/tmp/"`
3536
DefaultChaosHubPath string `split_words:"true" default:"/tmp/default/"`

0 commit comments

Comments
 (0)