I'm doing a git clone, and noticing that my token is logged....
I've looked a bit through secrets, and it seems they only apply why you can use a withSecret block.
Is there a way to protect my credentials when using the dagger.Git method? (I must use HTTPS / GH Token, can't use SSH)
Example Code
func insertCredentials(url string) (string, error) {
username := os.Getenv("GITHUB_USERNAME")
password := os.Getenv("GITHUB_TOKEN")
const githubPrefix = "https://github.com/"
if !strings.HasPrefix(url, githubPrefix) {
return "", fmt.Errorf("invalid GitHub URL: %s", url)
}
// Replace the github prefix with a new prefix containing the credentials
newPrefix := fmt.Sprintf("https://%s:%s@github.com/", username, password)
return strings.Replace(url, githubPrefix, newPrefix, 1), nil
}
....
// In main func
gitURL, err := insertCredentials("https://github.com/dagger/dagger")
if err != nil {
log.Error(err)
return err
}
c.SetSecret("ghApiToken", os.Getenv("GITHUB_TOKEN")) // added per request
src := c.Git(gitURL, dagger.GitOpts{KeepGitDir: true}).
....
This results in a logged opName like this....
git://me:my_token_oops@github.com/foo/service-bar.git#ref