Esempio n. 1
0
 private static async Task <string> GetErrorMessageAsync(IProcess dockerProcess)
 {
     using (Stream stderrStream = dockerProcess.GetErrorStream())
         using (StreamReader stderr = new StreamReader(stderrStream))
         {
             return(await stderr.ReadToEndAsync().ConfigureAwait(false));
         }
 }
Esempio n. 2
0
 private void ThrowUnhandledUrlException(IProcess process)
 {
     using (StreamReader processStderrReader =
                new StreamReader(process.GetErrorStream(), Encoding.UTF8))
     {
         string errorOutput = processStderrReader.ReadToEnd();
         throw new CredentialHelperUnhandledServerUrlException(
                   credentialHelper, registry, errorOutput);
     }
 }
Esempio n. 3
0
        /**
         * Tags the image referenced by {@code originalImageReference} with a new image reference {@code
         * newImageReference}.
         *
         * @param originalImageReference the existing image reference on the Docker daemon
         * @param newImageReference the new image reference
         * @see <a
         *     href="https://docs.docker.com/engine/reference/commandline/tag/">https://docs.docker.com/engine/reference/commandline/tag/</a>
         * @throws InterruptedException if the 'docker tag' process is interrupted.
         * @throws IOException if an I/O exception occurs or {@code docker tag} failed
         */
        public async Task TagAsync(IImageReference originalImageReference, ImageReference newImageReference)
        {
            originalImageReference = originalImageReference ?? throw new ArgumentNullException(nameof(originalImageReference));

            newImageReference = newImageReference ?? throw new ArgumentNullException(nameof(newImageReference));
            // Runs 'docker tag'.
            IProcess dockerProcess =
                Docker("tag", originalImageReference.ToString(), newImageReference.ToString());

            if (dockerProcess.WaitFor() != 0)
            {
                using (StreamReader stderr =
                           new StreamReader(dockerProcess.GetErrorStream(), Encoding.UTF8))
                {
                    string errorMessage = await stderr.ReadToEndAsync().ConfigureAwait(false);

                    throw new IOException(
                              "'docker tag' command failed with error: " + errorMessage);
                }
            }
        }