Skip to content

fix(hub): support GITHUB_TOKEN secret fallback for remote template imports#260

Open
chiefkarlin wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
chiefkarlin:fix-import-auth
Open

fix(hub): support GITHUB_TOKEN secret fallback for remote template imports#260
chiefkarlin wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
chiefkarlin:fix-import-auth

Conversation

@chiefkarlin
Copy link
Copy Markdown

This PR resolves an authentication failure when importing remote templates from private GitHub repositories.

Changes

  • Reads project-scoped GITHUB_TOKEN from the secret backend (or database fallback) in pkg/hub/template_bootstrap.go.
  • Passes the retrieved token to FetchRemoteTemplate to authenticate download and git operations.
  • Adds an offline unit test TestImportTemplatesFromRemote_WithProjectGithubToken to verify the secret resolution and fallback path using a mock HTTP client.

Closes #258

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 introduces a fallback mechanism to retrieve a project's GITHUB_TOKEN from either the secret backend or the database when importing templates from a remote source, and adds a corresponding unit test. The feedback recommends using the server's dedicated templateLog instead of the global slog for consistency, and addresses potential data races and test flakiness in the new unit test by protecting shared state with a mutex and restricting the mocked HTTP transport.

Comment thread pkg/hub/template_bootstrap.go
Comment thread pkg/hub/template_bootstrap.go
Comment thread pkg/hub/template_bootstrap_test.go
Comment thread pkg/hub/template_bootstrap_test.go Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Hub unable to import templates from private repositories

1 participant