Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit 33c7449

Browse files
authored
Configure GHCR credentials in configure command (#68)
1 parent 8c451a8 commit 33c7449

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/Valet/App.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,17 @@ public async Task<int> UpdateValetAsync(string? username = null, string? passwor
2323
{
2424
await _dockerService.VerifyDockerRunningAsync().ConfigureAwait(false);
2525

26+
var environmentVariables = await _configurationService.ReadCurrentVariablesAsync().ConfigureAwait(false);
27+
2628
username ??= Environment.GetEnvironmentVariable("GHCR_USERNAME");
2729
password ??= Environment.GetEnvironmentVariable("GHCR_PASSWORD");
2830

31+
if (username == null)
32+
environmentVariables.TryGetValue("GHCR_USERNAME", out username);
33+
34+
if (password == null)
35+
environmentVariables.TryGetValue("GHCR_PASSWORD", out password);
36+
2937
await _dockerService.UpdateImageAsync(
3038
ValetImage,
3139
ValetContainerRegistry,

src/Valet/Constants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ public static class Constants
66
{
77
private static readonly List<Variable> UserInputVariables = new()
88
{
9+
new Variable("GHCR_USERNAME", Provider.GitHub, "GitHub handle used to authenticate with the GitHub Container Registry"),
10+
new Variable("GHCR_PASSWORD", Provider.GitHub, "Personal access token to authenticate with the GitHub Container Registry"),
911
new Variable("GITHUB_ACCESS_TOKEN", Provider.GitHub, "Personal access token for GitHub"),
1012
new Variable("GITHUB_INSTANCE_URL", Provider.GitHub, "Base url of the GitHub instance", "https://github.com"),
1113
new Variable("AZURE_DEVOPS_ACCESS_TOKEN", Provider.AzureDevOps, "Personal access token for Azure DevOps"),

0 commit comments

Comments
 (0)