Skip to content

Commit d52efe6

Browse files
authored
do not set variables until before they are used
1 parent 86b25b0 commit d52efe6

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/spec-configuration/httpOCIRegistry.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,6 @@ async function getCredential(params: CommonParams, ociRef: OCIRef | OCICollectio
148148
const { output, env } = params;
149149
const { registry } = ociRef;
150150

151-
const githubToken = env['GITHUB_TOKEN'];
152-
const githubHost = env['GITHUB_HOST'];
153-
154151
if (!!env['DEVCONTAINERS_OCI_AUTH']) {
155152
// eg: DEVCONTAINERS_OCI_AUTH=service1|user1|token1,service2|user2|token2
156153
const authContexts = env['DEVCONTAINERS_OCI_AUTH'].split(',');
@@ -167,12 +164,17 @@ async function getCredential(params: CommonParams, ociRef: OCIRef | OCICollectio
167164
}
168165
}
169166

170-
// Attempt to use the docker config file or available credential helpers.
167+
// Attempt to use the docker config file or available credential helper(s).
171168
const credentialFromDockerConfig = await getCredentialFromDockerConfigOrCredentialHelper(params, registry);
172169
if (credentialFromDockerConfig) {
173170
return credentialFromDockerConfig;
174171
}
175172

173+
const githubToken = env['GITHUB_TOKEN'];
174+
const githubHost = env['GITHUB_HOST'];
175+
if (githubHost) {
176+
output.write(`[httpOci] Environment GITHUB_HOST is set to '${githubHost}'`, LogLevel.Trace);
177+
}
176178
if (registry === 'ghcr.io' && githubToken && (!githubHost || githubHost === 'github.com')) {
177179
output.write('[httpOci] Using environment GITHUB_TOKEN for auth', LogLevel.Trace);
178180
const userToken = `USERNAME:${env['GITHUB_TOKEN']}`;

0 commit comments

Comments
 (0)