Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to set git auth token using environment variables #1263

Merged
merged 1 commit into from
May 20, 2020
Merged

Add ability to set git auth token using environment variables #1263

merged 1 commit into from
May 20, 2020

Conversation

yorinasub17
Copy link
Contributor

Description

Currently the only way to set the git auth is by including it in the context git URL. This can be problematic for certain environments such as ECS where the command args are stored in logs. This changeset introduces updates to allow setting the authentication info using the environment variables GIT_USERNAME and GIT_PASSWORD.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes unit tests
  • Adds integration tests if needed.

See the contribution guide for more details.

NOTE: I didn't add an integration test for this change given that it requires real git credentials with a private git repo to fully test. If the maintainers have ideas for how to do this, happy to attempt an implementation. FWIW, I ran this manually after creating a new container and it worked perfectly:

%~> docker run \                                                                                                                                  
  -e GIT_PULL_METHOD=https -e GITHUB_OAUTH_TOKEN -e GIT_USERNAME \
   kaniko:git-auth-token-env \
   --context git://github.com/gruntwork-io/module-ci.git#refs/heads/master \
   --context-sub-path modules/ecs-deploy-runner/docker --no-push \
   --build-arg GITHUB_OAUTH_TOKEN
Enumerating objects: 291, done.
Counting objects: 100% (291/291), done.
Compressing objects: 100% (170/170), done.
Total 5678 (delta 178), reused 196 (delta 112), pack-reused 5387
INFO[0004] Resolved base name python:3.8-alpine to with-secrets
INFO[0004] Resolved base name python:3.8-alpine to without-secrets

Reviewer Notes

  • The code flow looks good.
  • Unit tests and or integration tests added.

Release Notes

Describe any changes here so maintainer can include it in the release notes, or delete this block.

- For git contexts, you can now set authentication credentials for basic auth using environment variables `GIT_USERNAME` and `GIT_PASSWORD`.

Currently the only way to set the git auth is by including it in the context
git URL. This can be problematic for certain environments such as ECS where the
command args for are stored in logs. Introduces updates to allow setting the
authentication info using the environment variables `GIT_USERNAME` and
`GIT_PASSWORD`.
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added the cla: no CLA not signed by all commit authors label May 11, 2020
@yorinasub17
Copy link
Contributor Author

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes CLA signed by all commit authors and removed cla: no CLA not signed by all commit authors labels May 11, 2020
Copy link
Member

@tejal29 tejal29 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your PR!
One questions about usability.

pkg/buildcontext/git.go Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes CLA signed by all commit authors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants