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

fix(controller): always pass credentials to kargo render #1696

Merged
merged 1 commit into from
Mar 27, 2024

Conversation

krancour
Copy link
Member

Prior to #1674 we did always pass credentials to Kargo Render. We stopped because Kargo proper now handles all the checking out and committing -- or so I thought...

I had forgotten that Kargo Render will, even if given a local repo that is already checked out to the correct source commit, check if the target branch exists remotely and attempt to pull from it. It does this because it wants up-to-date metadata from the target branch, if it exists.

Signed-off-by: Kent Rancourt <kent.rancourt@gmail.com>
@krancour krancour added this to the v0.5.0 milestone Mar 27, 2024
@krancour krancour self-assigned this Mar 27, 2024
@krancour krancour requested a review from a team as a code owner March 27, 2024 18:24
@krancour krancour changed the title always pass credentials to kargo render fix(controller): always pass credentials to kargo render Mar 27, 2024
Copy link

netlify bot commented Mar 27, 2024

Deploy Preview for docs-kargo-akuity-io canceled.

Name Link
🔨 Latest commit 3238fe0
🔍 Latest deploy log https://app.netlify.com/sites/docs-kargo-akuity-io/deploys/660464759af4e100086c8af3

@@ -103,7 +103,7 @@ CMD ["pnpm", "dev"]
# - the official image we publish
# - purposefully last so that it is the default target when building
####################################################################################################
FROM ghcr.io/akuity/kargo-render:v0.1.0-rc.38 as final
FROM ghcr.io/akuity/kargo-render:v0.1.0-rc.39 as final
Copy link
Member Author

Choose a reason for hiding this comment

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

This fixes a bug where Kargo render sometimes pushed a new, empty target branch to the remote even when instructed not to commit anything.

Comment on lines +65 to +77
"--repo-username",
req.RepoCreds.Username,
"--output",
"json",
}
for _, image := range req.Images {
cmdTokens = append(cmdTokens, "--image", image)
}
cmd := exec.Command(cmdTokens[0], cmdTokens[1:]...) // nolint: gosec
cmd.Env = append(
os.Environ(),
fmt.Sprintf("KARGO_RENDER_REPO_PASSWORD=%s", req.RepoCreds.Password),
)
Copy link
Member Author

Choose a reason for hiding this comment

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

One of two key changes. Most everything else is just updates to function signatures to get these creds down to here.

@@ -97,6 +99,7 @@ func (r *renderer) apply(
Images: images,
LocalInPath: workingDir,
LocalOutPath: writeDir,
RepoCreds: repoCreds,
Copy link
Member Author

Choose a reason for hiding this comment

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

One of two key changes. Most everything else is just updates to function signatures to get these creds down to here.

Copy link

codecov bot commented Mar 27, 2024

Codecov Report

Attention: Patch coverage is 22.22222% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 43.92%. Comparing base (f96a413) to head (3238fe0).

Files Patch % Lines
internal/kargo-render/render.go 0.00% 6 Missing ⚠️
internal/controller/promotion/git.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1696      +/-   ##
==========================================
- Coverage   43.93%   43.92%   -0.02%     
==========================================
  Files         203      203              
  Lines       13061    13070       +9     
==========================================
+ Hits         5739     5741       +2     
- Misses       7075     7082       +7     
  Partials      247      247              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hiddeco hiddeco self-requested a review March 27, 2024 18:35
Copy link
Contributor

@hiddeco hiddeco left a comment

Choose a reason for hiding this comment

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

Tested this with a scenario which was previously failing, and it works great!

@krancour krancour added this pull request to the merge queue Mar 27, 2024
Merged via the queue into akuity:main with commit 38ae6e6 Mar 27, 2024
19 of 21 checks passed
@krancour krancour deleted the krancour/render-creds branch March 27, 2024 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants