コード例 #1
0
ファイル: WriteTarFileStep.cs プロジェクト: tiaotiao97/jib
        public async Task <BuildResult> CallAsync()
        {
            await pullAndCacheBaseImageLayersStep.GetFuture().ConfigureAwait(false);

            await buildAndCacheApplicationLayersStep.GetFuture().ConfigureAwait(false);

            await buildImageStep.GetFuture().ConfigureAwait(false);

            string description = string.Format(
                CultureInfo.CurrentCulture,
                Resources.WriteTarFileStepDescriptionFormat,
                outputPath.GetFileName());

            buildConfiguration.GetEventHandlers().Dispatch(LogEvent.Progress(description));

            using (progressEventDispatcherFactory.Create(description, this.Index))
            {
                Image image = await buildImageStep.GetFuture().ConfigureAwait(false);

                // Builds the image to a tarball.
                Files.CreateDirectories(outputPath.GetParent());
                using (Stream outputStream =
                           new BufferedStream(FileOperations.NewLockingOutputStream(outputPath)))
                {
                    await new ImageTarball(image, buildConfiguration.GetTargetImageConfiguration().GetImage())
                    .WriteToAsync(outputStream).ConfigureAwait(false);
                }

                return(await BuildResult.FromImageAsync(image, buildConfiguration.GetTargetFormat()).ConfigureAwait(false));
            }
        }
コード例 #2
0
        private Credential RetrieveFromDockerCredentialHelper(SystemPath credentialHelper)
        {
            Credential credentials =
                dockerCredentialHelperFactory(imageReference.GetRegistry(), credentialHelper)
                .Retrieve();

            LogGotCredentialsFrom(credentialHelper.GetFileName().ToString());
            return(credentials);
        }
コード例 #3
0
 /**
  * Gets the diff ID portion of the layer filename.
  *
  * @param layerFile the layer file to parse for the diff ID
  * @return the diff ID portion of the layer file filename
  * @throws CacheCorruptedException if no valid diff ID could be parsed
  */
 public DescriptorDigest GetDiffId(SystemPath layerFile)
 {
     try
     {
         layerFile = layerFile ?? throw new ArgumentNullException(nameof(layerFile));
         string diffId = layerFile.GetFileName().ToString();
         return(DescriptorDigest.FromHash(diffId));
     }
     catch (Exception ex) when(ex is DigestException || ex is IndexOutOfRangeException)
     {
         throw new CacheCorruptedException(
                   cacheDirectory, "Layer file did not include valid diff ID: " + layerFile, ex);
     }
 }
コード例 #4
0
 public static string GetFileName(string path)
 {
     return(SystemPath.GetFileName(path));
 }
コード例 #5
0
 /**
  * Returns whether or not {@code file} is a layer contents file.
  *
  * @param file the file to check
  * @return {@code true} if {@code file} is a layer contents file; {@code false} otherwise
  */
 public static bool IsLayerFile(SystemPath file)
 {
     return(file?.GetFileName().ToString().Length == DescriptorDigest.HashLength);
 }