diff --git a/src/Containers/Microsoft.NET.Build.Containers/AuthHandshakeMessageHandler.cs b/src/Containers/Microsoft.NET.Build.Containers/AuthHandshakeMessageHandler.cs index 543db320b5c4..172f968baa30 100644 --- a/src/Containers/Microsoft.NET.Build.Containers/AuthHandshakeMessageHandler.cs +++ b/src/Containers/Microsoft.NET.Build.Containers/AuthHandshakeMessageHandler.cs @@ -157,8 +157,8 @@ public DateTimeOffset ResolvedExpiration private async Task<(AuthenticationHeaderValue, DateTimeOffset)?> GetAuthenticationAsync(string registry, string scheme, AuthInfo? bearerAuthInfo, CancellationToken cancellationToken) { // Allow overrides for auth via environment variables - string? credU = Environment.GetEnvironmentVariable(ContainerHelpers.HostObjectUser); - string? credP = Environment.GetEnvironmentVariable(ContainerHelpers.HostObjectPass); + string? credU = Environment.GetEnvironmentVariable(ContainerHelpers.HostObjectUser) ?? Environment.GetEnvironmentVariable(ContainerHelpers.HostObjectUserLegacy); + string? credP = Environment.GetEnvironmentVariable(ContainerHelpers.HostObjectPass) ?? Environment.GetEnvironmentVariable(ContainerHelpers.HostObjectPassLegacy); // fetch creds for the host DockerCredentials? privateRepoCreds; diff --git a/src/Containers/Microsoft.NET.Build.Containers/ContainerHelpers.cs b/src/Containers/Microsoft.NET.Build.Containers/ContainerHelpers.cs index 81cfde3bab90..137755cdeb3d 100644 --- a/src/Containers/Microsoft.NET.Build.Containers/ContainerHelpers.cs +++ b/src/Containers/Microsoft.NET.Build.Containers/ContainerHelpers.cs @@ -16,9 +16,11 @@ namespace Microsoft.NET.Build.Containers; public static class ContainerHelpers { - internal const string HostObjectUser = "SDK_CONTAINER_REGISTRY_UNAME"; + internal const string HostObjectUser = "DOTNET_CONTAINER_REGISTRY_UNAME"; + internal const string HostObjectUserLegacy = "SDK_CONTAINER_REGISTRY_UNAME"; - internal const string HostObjectPass = "SDK_CONTAINER_REGISTRY_PWORD"; + internal const string HostObjectPass = "DOTNET_CONTAINER_REGISTRY_PWORD"; + internal const string HostObjectPassLegacy = "SDK_CONTAINER_REGISTRY_PWORD"; internal const string DockerRegistryAlias = "docker.io"; diff --git a/src/Containers/Microsoft.NET.Build.Containers/Registry/RegistrySettings.cs b/src/Containers/Microsoft.NET.Build.Containers/Registry/RegistrySettings.cs index 19e5b6eef6a3..9ea9005af46a 100644 --- a/src/Containers/Microsoft.NET.Build.Containers/Registry/RegistrySettings.cs +++ b/src/Containers/Microsoft.NET.Build.Containers/Registry/RegistrySettings.cs @@ -12,9 +12,14 @@ public RegistrySettings(string? registryName = null, IEnvironmentProvider? envir { environment ??= new EnvironmentProvider(); - ChunkedUploadSizeBytes = environment.GetEnvironmentVariableAsNullableInt(EnvVariables.ChunkedUploadSizeBytes); - ForceChunkedUpload = environment.GetEnvironmentVariableAsBool(EnvVariables.ForceChunkedUpload, defaultValue: false); - ParallelUploadEnabled = environment.GetEnvironmentVariableAsBool(EnvVariables.ParallelUploadEnabled, defaultValue: true); + ChunkedUploadSizeBytes = environment.GetEnvironmentVariableAsNullableInt(EnvVariables.ChunkedUploadSizeBytes) ?? + environment.GetEnvironmentVariableAsNullableInt(EnvVariables.ChunkedUploadSizeBytesLegacy); + ForceChunkedUpload = Environment.GetEnvironmentVariable(EnvVariables.ForceChunkedUpload) is not null ? + environment.GetEnvironmentVariableAsBool(EnvVariables.ForceChunkedUpload, defaultValue: false) : + environment.GetEnvironmentVariableAsBool(EnvVariables.ForceChunkedUploadLegacy, defaultValue: false); + ParallelUploadEnabled = Environment.GetEnvironmentVariable(EnvVariables.ParallelUploadEnabled) is not null ? + environment.GetEnvironmentVariableAsBool(EnvVariables.ParallelUploadEnabled, defaultValue: true) : + environment.GetEnvironmentVariableAsBool(EnvVariables.ParallelUploadEnabledLegacy, defaultValue: true); if (registryName is not null) { @@ -53,12 +58,15 @@ public RegistrySettings(string? registryName = null, IEnvironmentProvider? envir internal struct EnvVariables { - internal const string ChunkedUploadSizeBytes = "SDK_CONTAINER_REGISTRY_CHUNKED_UPLOAD_SIZE_BYTES"; + internal const string ChunkedUploadSizeBytes = "DOTNET_CONTAINER_REGISTRY_CHUNKED_UPLOAD_SIZE_BYTES"; + internal const string ChunkedUploadSizeBytesLegacy = "SDK_CONTAINER_REGISTRY_CHUNKED_UPLOAD_SIZE_BYTES"; - internal const string ForceChunkedUpload = "SDK_CONTAINER_DEBUG_REGISTRY_FORCE_CHUNKED_UPLOAD"; - internal const string ParallelUploadEnabled = "SDK_CONTAINER_REGISTRY_PARALLEL_UPLOAD"; + internal const string ForceChunkedUpload = "DOTNET_CONTAINER_DEBUG_REGISTRY_FORCE_CHUNKED_UPLOAD"; + internal const string ForceChunkedUploadLegacy = "SDK_CONTAINER_DEBUG_REGISTRY_FORCE_CHUNKED_UPLOAD"; + internal const string ParallelUploadEnabled = "DOTNET_CONTAINER_REGISTRY_PARALLEL_UPLOAD"; + internal const string ParallelUploadEnabledLegacy = "SDK_CONTAINER_REGISTRY_PARALLEL_UPLOAD"; - internal const string InsecureRegistries = "SDK_CONTAINER_INSECURE_REGISTRIES"; + internal const string InsecureRegistries = "DOTNET_CONTAINER_INSECURE_REGISTRIES"; } private static bool IsInsecureRegistry(IEnvironmentProvider environment, string registryName) @@ -70,7 +78,7 @@ private static bool IsInsecureRegistry(IEnvironmentProvider environment, string return true; } - // SDK_CONTAINER_INSECURE_REGISTRIES is a semicolon separated list of insecure registry names. + // DOTNET_CONTAINER_INSECURE_REGISTRIES is a semicolon separated list of insecure registry names. string? insecureRegistriesEnv = environment.GetEnvironmentVariable(EnvVariables.InsecureRegistries); if (insecureRegistriesEnv is not null) { diff --git a/src/Containers/docs/ReleaseNotes/v7.0.400.md b/src/Containers/docs/ReleaseNotes/v7.0.400.md index 94ae3054009b..0986e20ab196 100644 --- a/src/Containers/docs/ReleaseNotes/v7.0.400.md +++ b/src/Containers/docs/ReleaseNotes/v7.0.400.md @@ -11,13 +11,13 @@ This version brings the following new features and enhancements: In addition, we fixed some protocol bugs that blocked usage with registries like Harbor. * Several environment variables were added to allow more explicit control over the layer upload process: - * SDK_CONTAINER_REGISTRY_PARALLEL_UPLOAD + * DOTNET_CONTAINER_REGISTRY_PARALLEL_UPLOAD * determines if layers of the generated image can be uploaded in parallel or in series. * defaults to `true` for all registries except AWS ECR - * SDK_CONTAINER_DEBUG_REGISTRY_FORCE_CHUNKED_UPLOAD + * DOTNET_CONTAINER_DEBUG_REGISTRY_FORCE_CHUNKED_UPLOAD * if set to `true`, we will always try to upload layers in chunks instead of all in one upload. * defaults to `false`. - * SDK_CONTAINER_REGISTRY_CHUNKED_UPLOAD_SIZE_BYTES + * DOTNET_CONTAINER_REGISTRY_CHUNKED_UPLOAD_SIZE_BYTES * allows for explicit control over the size of the chunks uploaded when using chunked uploads. * note that by default we prefer atomic uploads, so setting this might not have any impact if your registry supports atomic uploads. * does not have a default, but the default chunk size is 64Kb. diff --git a/src/Tests/Microsoft.NET.Build.Containers.UnitTests/RegistryTests.cs b/src/Tests/Microsoft.NET.Build.Containers.UnitTests/RegistryTests.cs index 11c80a75c845..d01aab77d77b 100644 --- a/src/Tests/Microsoft.NET.Build.Containers.UnitTests/RegistryTests.cs +++ b/src/Tests/Microsoft.NET.Build.Containers.UnitTests/RegistryTests.cs @@ -531,7 +531,7 @@ public void IsRegistryInsecure(string registryName, string? insecureRegistriesEn var environment = new Dictionary(); if (insecureRegistriesEnvvar is not null) { - environment["SDK_CONTAINER_INSECURE_REGISTRIES"] = insecureRegistriesEnvvar; + environment["DOTNET_CONTAINER_INSECURE_REGISTRIES"] = insecureRegistriesEnvvar; } var registrySettings = new RegistrySettings(registryName, new MockEnvironmentProvider(environment));