[REMOVE] Remove unused Docker Registry API endpoints and related service methods

main
bjkim 9 months ago
parent 0c22c832e0
commit d648e70eba

@ -43,51 +43,4 @@ public class DockerRegistryController {
return dockerRegistryService.listTags(repo) return dockerRegistryService.listTags(repo)
.map(ResponseEntity::ok); .map(ResponseEntity::ok);
} }
@GetMapping("/repositories/{repo}/tags-with-digest")
@Operation(summary = "태그 목록 + digest 조회")
public Mono<ResponseEntity<List<TagWithDigest>>> listTagsWithDigest(
@PathVariable String repo) {
return dockerRegistryService.listTagsWithDigest(repo)
.map(ResponseEntity::ok);
}
@PostMapping(value = "/repositories/{repo}/upload", consumes = MediaType.APPLICATION_OCTET_STREAM_VALUE)
@Operation(summary = "이미지 업로드")
public Mono<ResponseEntity<String>> uploadImage(@PathVariable String repo,
@RequestParam String tag,
@RequestBody byte[] content) {
return dockerRegistryService.uploadImage(repo, tag, content)
.map(ResponseEntity::ok);
}
@GetMapping("/repositories/{repo}/download/{digest}")
@Operation(summary = "이미지 다운로드")
public Mono<ResponseEntity<byte[]>> downloadImage(@PathVariable String repo,
@PathVariable String digest) {
return dockerRegistryService.downloadImage(repo, digest)
.map(bytes -> ResponseEntity.ok()
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.body(bytes));
}
@GetMapping("/repositories/{repo}/manifest/{tag}")
@Operation(summary = "태그로 manifest 조회")
public Mono<ResponseEntity<JsonNode>> getManifest(
@PathVariable String repo,
@PathVariable String tag) {
return dockerRegistryService.getManifestByTag(repo, tag)
.map(ResponseEntity::ok);
}
@GetMapping("/repositories/{repo}/digest/{tag}")
@Operation(summary = "태그로 digest 조회")
public Mono<ResponseEntity<String>> getDigest(
@PathVariable String repo,
@PathVariable String tag) {
return dockerRegistryService.getDigestByTag(repo, tag)
.map(ResponseEntity::ok);
}
} }

@ -70,62 +70,4 @@ public class DockerRegistryService {
.retrieve() .retrieve()
.bodyToMono(JsonNode.class); .bodyToMono(JsonNode.class);
} }
public Mono<List<TagWithDigest>> listTagsWithDigest(String repository) {
return listTags(repository)
.flatMapMany(json -> {
JsonNode tagsNode = json.get("tags");
if (tagsNode == null || !tagsNode.isArray()) {
return Flux.empty();
}
return Flux.fromIterable(
StreamSupport.stream(tagsNode.spliterator(), false)
.map(JsonNode::asText)
.toList()
);
})
.flatMap(tag -> getDigestByTag(repository, tag)
.map(digest -> new TagWithDigest(tag, digest))
)
.collectList();
}
public Mono<String> uploadImage(String repository, String tag, byte[] content) {
return webClientBuilder.build()
.put()
.uri(REGISTRY_URL + "/v2/" + repository + "/blobs/uploads/")
.header(HttpHeaders.CONTENT_TYPE, "application/octet-stream")
.bodyValue(content)
.retrieve()
.bodyToMono(String.class);
}
public Mono<byte[]> downloadImage(String repository, String digest) {
return webClientBuilder.build()
.get()
.uri(REGISTRY_URL + "/v2/" + repository + "/blobs/" + digest)
.retrieve()
.bodyToMono(byte[].class);
}
public Mono<JsonNode> getManifestByTag(String repository, String tag) {
return webClientBuilder.build()
.get()
.uri(REGISTRY_URL + "/v2/" + repository + "/manifests/" + tag)
.header("Accept", "application/vnd.oci.image.index.v1+json")
.retrieve()
.bodyToMono(JsonNode.class);
}
// SHA(Digest)값만 가져옴
public Mono<String> getDigestByTag(String repository, String tag) {
return webClientBuilder.build()
.get()
.uri(REGISTRY_URL + "/v2/" + repository + "/manifests/" + tag)
.header("Accept", "application/vnd.oci.image.index.v1+json")
.retrieve()
.toBodilessEntity()
.map(resp -> resp.getHeaders().getFirst("Docker-Content-Digest"));
}
} }

Loading…
Cancel
Save