Пример #1
0
        public static void Login(string username, string password, string server, bool isDryRun)
        {
            Version clientVersion = GetClientVersion();

            if (clientVersion >= new Version(17, 7))
            {
                ProcessStartInfo startInfo = new ProcessStartInfo(
                    "docker", $"login -u {username} --password-stdin {server}")
                {
                    RedirectStandardInput = true
                };
                ExecuteHelper.ExecuteWithRetry(
                    startInfo,
                    process =>
                {
                    process.StandardInput.WriteLine(password);
                    process.StandardInput.Close();
                },
                    isDryRun);
            }
            else
            {
                ExecuteHelper.ExecuteWithRetry(
                    "docker",
                    $"login -u {username} -p {password} {server}",
                    isDryRun,
                    executeMessageOverride: $"login -u {username} -p ******** {server}");
            }
        }
Пример #2
0
        public string?BuildImage(
            string dockerfilePath,
            string buildContextPath,
            string platform,
            IEnumerable <string> tags,
            IDictionary <string, string?> buildArgs,
            bool isRetryEnabled,
            bool isDryRun)
        {
            string tagArgs = $"-t {string.Join(" -t ", tags)}";

            IEnumerable <string> buildArgList = buildArgs
                                                .Select(buildArg => $" --build-arg {buildArg.Key}={buildArg.Value}");
            string buildArgsString = string.Join(string.Empty, buildArgList);

            string dockerArgs = $"build --platform {platform} {tagArgs} -f {dockerfilePath}{buildArgsString} {buildContextPath}";

            if (isRetryEnabled)
            {
                return(ExecuteHelper.ExecuteWithRetry("docker", dockerArgs, isDryRun));
            }
            else
            {
                return(ExecuteHelper.Execute("docker", dockerArgs, isDryRun));
            }
        }
Пример #3
0
 public static void PullBaseImages(ManifestInfo manifest, Options options)
 {
     Utilities.WriteHeading("PULLING LATEST BASE IMAGES");
     foreach (string fromImage in manifest.GetExternalFromImages())
     {
         ExecuteHelper.ExecuteWithRetry("docker", $"pull {fromImage}", options.IsDryRun);
     }
 }
Пример #4
0
        public JArray Inspect(string image, bool isDryRun)
        {
            string output = ExecuteHelper.ExecuteWithRetry("manifest-tool", $"inspect {image} --raw", isDryRun);

            if (isDryRun)
            {
                return(null);
            }

            return(JsonConvert.DeserializeObject <JArray>(output));
        }
Пример #5
0
        public static void PullBaseImages(ManifestInfo manifest, Options options)
        {
            Logger.WriteHeading("PULLING LATEST BASE IMAGES");
            IEnumerable <string> baseImages = manifest.GetExternalFromImages().ToArray();

            if (baseImages.Any())
            {
                foreach (string fromImage in baseImages)
                {
                    ExecuteHelper.ExecuteWithRetry("docker", $"pull {fromImage}", options.IsDryRun);
                }
            }
            else
            {
                Logger.WriteMessage("No external base images to pull");
            }
        }
Пример #6
0
 private static void Logout(string server, bool isDryRun)
 {
     ExecuteHelper.ExecuteWithRetry("docker", $"logout {server}", isDryRun);
 }
Пример #7
0
 public static void PullImage(string image, bool isDryRun)
 {
     ExecuteHelper.ExecuteWithRetry("docker", $"pull {image}", isDryRun);
 }
Пример #8
0
 public void PushImage(string tag, bool isDryRun) => ExecuteHelper.ExecuteWithRetry("docker", $"push {tag}", isDryRun);
Пример #9
0
 public void PushFromSpec(string manifestFile, bool isDryRun)
 {
     // ExecuteWithRetry because the manifest-tool fails periodically while communicating
     // with the Docker Registry.
     ExecuteHelper.ExecuteWithRetry("manifest-tool", $"push from-spec {manifestFile}", isDryRun);
 }