Home / Class/ LayerArchiveFactory Class — spring-boot Architecture

LayerArchiveFactory Class — spring-boot Architecture

Architecture documentation for the LayerArchiveFactory class in ExportedImageTar.java from the spring-boot codebase.

Entity Profile

Relationship Graph

Source Code

buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/ExportedImageTar.java lines 96–141

	private abstract static class LayerArchiveFactory {

		/**
		 * Create a new {@link TarArchive} if the given entry represents a layer.
		 * @param tar the tar input stream
		 * @param entry the candidate entry
		 * @return a new {@link TarArchive} instance or {@code null} if this entry is not
		 * a layer.
		 */
		abstract @Nullable TarArchive getLayerArchive(TarArchiveInputStream tar, TarArchiveEntry entry);

		/**
		 * Create a new {@link LayerArchiveFactory} for the given tar file using either
		 * the {@code index.json} or {@code manifest.json} to detect layers.
		 * @param reference the image that was referenced
		 * @param tarFile the source tar file
		 * @return a new {@link LayerArchiveFactory} instance
		 * @throws IOException on IO error
		 */
		static LayerArchiveFactory create(ImageReference reference, Path tarFile) throws IOException {
			try (TarArchiveInputStream tar = openTar(tarFile)) {
				ImageArchiveIndex index = null;
				ImageArchiveManifest manifest = null;
				TarArchiveEntry entry = tar.getNextEntry();
				while (entry != null) {
					if ("index.json".equals(entry.getName())) {
						index = ImageArchiveIndex.of(tar);
						break;
					}
					if ("manifest.json".equals(entry.getName())) {
						manifest = ImageArchiveManifest.of(tar);
					}
					entry = tar.getNextEntry();
				}
				Assert.state(index != null || manifest != null,
						() -> "Exported image '%s' does not contain 'index.json' or 'manifest.json'"
							.formatted(reference));
				if (index != null) {
					return new IndexLayerArchiveFactory(tarFile, index);
				}
				Assert.state(manifest != null, "'manifest' must not be null");
				return new ManifestLayerArchiveFactory(manifest);
			}
		}

	}

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free