Skip to content

Commit

Permalink
Debug commit
Browse files Browse the repository at this point in the history
Signed-off-by: Jagpreet Singh Tamber <[email protected]>
  • Loading branch information
jagpreetstamber committed Dec 12, 2024
1 parent 06a0d1e commit da35f8a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions pkg/apis/application/v1alpha1/repository_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ func (repo *Repository) GetGitCreds(store git.CredsStore) git.Creds {
func (repo *Repository) GetHelmCreds() helm.Creds {
if repo.UseAzureWorkloadIdentity {
return helm.NewAzureWorkloadIdentityCreds(
repo.Repo,
getCAPath(repo.Repo),
[]byte(repo.TLSClientCertData),
[]byte(repo.TLSClientCertKey),
Expand Down
5 changes: 5 additions & 0 deletions util/helm/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os/exec"
"path"
"path/filepath"
"reflect"
"regexp"
"strings"

Expand Down Expand Up @@ -271,6 +272,10 @@ func (c *Cmd) PullOCI(repo string, chart string, version string, destination str
"--destination",
destination,
}

fmt.Printf("Repo: %s, Chart: %s, Version: %s, Destination: %s, Creds: %s\n", repo, chart, version, destination, reflect.TypeOf(creds))
fmt.Printf("UserName: %s, Password: %s\n", creds.GetUsername(), creds.GetPassword())

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

Sensitive data returned by a call to GetPassword
flows to a logging call.

if creds.GetCAPath() != "" {
args = append(args, "--ca-file", creds.GetCAPath())
}
Expand Down
16 changes: 12 additions & 4 deletions util/helm/creds.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ func (creds AzureWorkloadIdentityCreds) GetUsername() string {
}

func (creds AzureWorkloadIdentityCreds) GetPassword() string {
token, _ := creds.GetAccessToken(creds.repoUrl) // TODO: propagate error
token, err := creds.GetAccessToken(creds.repoUrl) // TODO: propagate error
if err != nil {
fmt.Println("Erooorororororororororrorororororororororororo")
fmt.Println(err)
}

return token
}
Expand All @@ -98,8 +102,9 @@ func (creds AzureWorkloadIdentityCreds) GetInsecureSkipVerify() bool {
return creds.InsecureSkipVerify
}

func NewAzureWorkloadIdentityCreds(caPath string, certData []byte, keyData []byte, insecureSkipVerify bool) AzureWorkloadIdentityCreds {
func NewAzureWorkloadIdentityCreds(repoUrl string, caPath string, certData []byte, keyData []byte, insecureSkipVerify bool) AzureWorkloadIdentityCreds {
return AzureWorkloadIdentityCreds{
repoUrl: repoUrl,
CAPath: caPath,
CertData: certData,
KeyData: keyData,
Expand All @@ -108,8 +113,11 @@ func NewAzureWorkloadIdentityCreds(caPath string, certData []byte, keyData []byt
}

func (c AzureWorkloadIdentityCreds) GetAccessToken(azureContainerRegistry string) (string, error) {

Check failure on line 115 in util/helm/creds.go

View workflow job for this annotation

GitHub Actions / Lint Go code

unnecessary leading newline (whitespace)

registryHost := strings.Split(azureContainerRegistry, "/")[0]

// Compute hash as key for refresh token in the cache
key, err := argoutils.GenerateCacheKey("accesstoken-%s", azureContainerRegistry)
key, err := argoutils.GenerateCacheKey("accesstoken-%s", registryHost)
if err != nil {
return "", fmt.Errorf("failed to compute key for cache: %w", err)
}
Expand All @@ -121,7 +129,7 @@ func (c AzureWorkloadIdentityCreds) GetAccessToken(azureContainerRegistry string
return t.(string), nil
}

tokenParams, err := c.challengeAzureContainerRegistry(azureContainerRegistry)
tokenParams, err := c.challengeAzureContainerRegistry(registryHost)
if err != nil {
return "", fmt.Errorf("failed to challenge Azure Container Registry: %w", err)
}
Expand Down

0 comments on commit da35f8a

Please sign in to comment.