Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ target/
# IDEs
.idea/
*.iml
.classpath
.project
.settings

# When testing JSON files
*.json
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/land/oras/CopyUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ else if (source.isIndexMediaType(contentType)) {
}

LOG.debug("Copying index {}", manifestDigest);
target.pushIndex(effectiveTargetRef.withDigest(tag), index);
LOG.debug("Copied index {}", manifestDigest);
Index pushedIndex = target.pushIndex(effectiveTargetRef.withDigest(tag), index);
LOG.debug("Copied index {} with tag {}", pushedIndex, tag);

} else {
throw new OrasException("Unsupported content type: %s".formatted(contentType));
Expand Down
13 changes: 3 additions & 10 deletions src/main/java/land/oras/Index.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public Index withRemovedDescriptor(ManifestDescriptor descriptor) {
return new Index(
schemaVersion,
mediaType,
ArtifactType.from(artifactType),
artifactType,
newManifests,
annotations,
subject,
Expand Down Expand Up @@ -270,18 +270,11 @@ public Index withNewManifests(ManifestDescriptor manifest) {
}
newManifests.add(manifest);
return new Index(
schemaVersion,
mediaType,
ArtifactType.from(artifactType),
newManifests,
annotations,
subject,
descriptor,
registry,
json);
schemaVersion, mediaType, artifactType, newManifests, annotations, subject, descriptor, registry, json);
}

@Override
@JsonIgnore
public ManifestDescriptor getDescriptor() {
return descriptor;
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/land/oras/IndexTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ void shouldRemoveManifest() {
final Index indexFinal = index.withRemovedDescriptor(descriptor1);
assertEquals(1, indexFinal.getManifests().size());
assertEquals(descriptor2.getDigest(), indexFinal.getManifests().get(0).getDigest());
assertNull(index.getArtifactTypeAsString());
assertNull(indexFinal.getArtifactTypeAsString());

OrasException e = assertThrows(OrasException.class, () -> indexFinal.withRemovedDescriptor(descriptor1));
assertEquals(
Expand Down
5 changes: 4 additions & 1 deletion src/test/java/land/oras/OCILayoutTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1042,9 +1042,12 @@ private void assertIndex(Path ociLayoutPath, Manifest manifest, int size, int in
private void assertIndex(Path ociLayoutPath, Index index, int size) {
assertTrue(Files.exists(ociLayoutPath.resolve(Const.OCI_LAYOUT_INDEX)));
Index ociIndex = Index.fromPath(ociLayoutPath.resolve(Const.OCI_LAYOUT_INDEX));
LOG.debug("Index is {}", ociIndex.toJson());
LOG.debug("OCI Index JSON is {}", ociIndex.toJson());
LOG.debug("Expected Index JSON is {}", index.toJson());
assertEquals(2, ociIndex.getSchemaVersion());
assertEquals(size, ociIndex.getManifests().size());
assertEquals(index.getArtifactType(), ociIndex.getArtifactType());
assertEquals(index.getArtifactTypeAsString(), ociIndex.getArtifactTypeAsString());
assertEquals(Const.DEFAULT_INDEX_MEDIA_TYPE, ociIndex.getMediaType());
assertEquals(
index.getDescriptor().getSize(),
Expand Down