Skip to content

fix: set SSL_CERT_FILE for git-sync for custom CA during GitHub App Auth#2141

Open
samirtahir91 wants to merge 3 commits intoGoogleContainerTools:mainfrom
samirtahir91:fix/git-sync-ca-cert-github-app
Open

fix: set SSL_CERT_FILE for git-sync for custom CA during GitHub App Auth#2141
samirtahir91 wants to merge 3 commits intoGoogleContainerTools:mainfrom
samirtahir91:fix/git-sync-ca-cert-github-app

Conversation

@samirtahir91
Copy link
Copy Markdown
Contributor

This PR updates the git-sync reconciler to have the SSL_CERT_FILE env variable set to custom CA certificate when the root/repo sync has as custom ca cert defined.

Without is Github App Auth fails due to SSL errors.

Issue - #2140

@google-oss-prow
Copy link
Copy Markdown

Hi @samirtahir91. Thanks for your PR.

I'm waiting for a GoogleContainerTools member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds the SSL_CERT_FILE environment variable to the git-sync container when a CA certificate is provided, ensuring that GitHub App token exchanges using the Go net/http client can validate certificates. The review feedback points out a typo in the added comment and suggests using a constant for the environment variable name to align with the project's coding patterns.

Comment on lines +275 to 280
// SSL_CERT_FILE is needed for Github App token exchange
// as it uses net/http client and not the git CLI.
result = append(result, corev1.EnvVar{
Name: "SSL_CERT_FILE",
Value: caCertFilePath,
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The comment contains a typo ("Github" should be "GitHub") and could be more precise. Additionally, using a hardcoded string for the environment variable name "SSL_CERT_FILE" is inconsistent with the existing pattern in this file, where environment variable names are defined as constants (e.g., GitSSLCAInfo on line 54). While I cannot suggest adding a constant to the const block as it is outside the diff range, consider defining one for SSL_CERT_FILE to maintain consistency with the rest of the file.

Suggested change
// SSL_CERT_FILE is needed for Github App token exchange
// as it uses net/http client and not the git CLI.
result = append(result, corev1.EnvVar{
Name: "SSL_CERT_FILE",
Value: caCertFilePath,
})
// SSL_CERT_FILE is needed for GitHub App token exchange,
// as it uses the Go net/http client and not the git CLI.
result = append(result, corev1.EnvVar{
Name: "SSL_CERT_FILE",
Value: caCertFilePath,
})

@samirtahir91
Copy link
Copy Markdown
Contributor Author

@tiffanny29631 - Are you happy to review please?

Copy link
Copy Markdown
Contributor

@tiffanny29631 tiffanny29631 left a comment

Choose a reason for hiding this comment

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

Nice fix! Since we have an existing test suite in gitsync_env_test.go, could we add a test case to TestGitSyncEnvVars to verify this change?

@samirtahir91 samirtahir91 force-pushed the fix/git-sync-ca-cert-github-app branch from a97a9b0 to 9bfbace Compare April 24, 2026 15:40
@google-oss-prow google-oss-prow Bot added size/M and removed size/XS labels Apr 24, 2026
@samirtahir91
Copy link
Copy Markdown
Contributor Author

Nice fix! Since we have an existing test suite in gitsync_env_test.go, could we add a test case to TestGitSyncEnvVars to verify this change?

Added test, can you review please

Copy link
Copy Markdown
Contributor

@tiffanny29631 tiffanny29631 left a comment

Choose a reason for hiding this comment

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

/lgtm

@google-oss-prow
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tiffanny29631

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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