Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand All @@ -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)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Containers/docs/ReleaseNotes/v7.0.400.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ public void IsRegistryInsecure(string registryName, string? insecureRegistriesEn
var environment = new Dictionary<string, string>();
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));
Expand Down