66
77using Aspire . Hosting . ApplicationModel ;
88using Aspire . Hosting . Azure . Provisioning . Internal ;
9- using Aspire . Hosting . Dcp . Process ;
109using Aspire . Hosting . Pipelines ;
1110using Aspire . Hosting . Publishing ;
1211using Azure . Core ;
@@ -51,8 +50,8 @@ private static async Task AuthenticateToAcrHelper(IReportingTask loginTask, stri
5150
5251 logger . LogDebug ( "Logging in to registry {RegistryEndpoint} using container runtime {RuntimeName}" , registryEndpoint , containerRuntime . Name ) ;
5352
54- // Login to the registry using the container runtime with custom logging
55- await LoginToRegistryWithLoggingAsync ( containerRuntime , registryEndpoint , AcrUsername , accessToken . Token , logger , cancellationToken ) . ConfigureAwait ( false ) ;
53+ // Login to the registry using the container runtime
54+ await containerRuntime . LoginToRegistryAsync ( registryEndpoint , AcrUsername , accessToken . Token , cancellationToken ) . ConfigureAwait ( false ) ;
5655
5756 await loginTask . CompleteAsync ( $ "Successfully logged in to **{ registryEndpoint } **", CompletionState . Completed , cancellationToken ) . ConfigureAwait ( false ) ;
5857 }
@@ -63,45 +62,6 @@ private static async Task AuthenticateToAcrHelper(IReportingTask loginTask, stri
6362 }
6463 }
6564
66- private static async Task LoginToRegistryWithLoggingAsync ( IContainerRuntime containerRuntime , string registryServer , string username , string password , ILogger logger , CancellationToken cancellationToken )
67- {
68- var arguments = $ "login \" { registryServer } \" --username \" { username } \" --password-stdin";
69-
70- var spec = new ProcessSpec ( containerRuntime is DockerContainerRuntime ? "docker" : "podman" )
71- {
72- Arguments = arguments ,
73- StandardInputContent = password ,
74- OnOutputData = output =>
75- {
76- logger . LogDebug ( "{RuntimeName} login (stdout): {Output}" , containerRuntime . Name , output ) ;
77- } ,
78- OnErrorData = error =>
79- {
80- logger . LogDebug ( "{RuntimeName} login (stderr): {Error}" , containerRuntime . Name , error ) ;
81- } ,
82- ThrowOnNonZeroReturnCode = false ,
83- InheritEnv = true
84- } ;
85-
86- logger . LogDebug ( "Running {RuntimeName} login to registry: {RegistryServer}" , containerRuntime . Name , registryServer ) ;
87- var ( pendingProcessResult , processDisposable ) = ProcessUtil . Run ( spec ) ;
88-
89- await using ( processDisposable )
90- {
91- var processResult = await pendingProcessResult
92- . WaitAsync ( cancellationToken )
93- . ConfigureAwait ( false ) ;
94-
95- if ( processResult . ExitCode != 0 )
96- {
97- logger . LogError ( "{RuntimeName} login to {RegistryServer} failed with exit code {ExitCode}." , containerRuntime . Name , registryServer , processResult . ExitCode ) ;
98- throw new DistributedApplicationException ( $ "{ containerRuntime . Name } login failed with exit code { processResult . ExitCode } .") ;
99- }
100-
101- logger . LogDebug ( "{RuntimeName} login to {RegistryServer} succeeded." , containerRuntime . Name , registryServer ) ;
102- }
103- }
104-
10565 public static async Task PushImageToRegistryAsync ( IContainerRegistry registry , IResource resource , PipelineStepContext context , IResourceContainerImageBuilder containerImageBuilder )
10666 {
10767 var registryName = await registry . Name . GetValueAsync ( context . CancellationToken ) . ConfigureAwait ( false ) ??
0 commit comments