From d648e70ebafcefa77af1ef07a2707f4ed286c929 Mon Sep 17 00:00:00 2001 From: bjkim Date: Mon, 29 Sep 2025 19:56:53 +0900 Subject: [PATCH] [REMOVE] Remove unused Docker Registry API endpoints and related service methods --- .../controllers/DockerRegistryController.java | 47 --------------- .../service/DockerRegistryService.java | 58 ------------------- 2 files changed, 105 deletions(-) diff --git a/src/main/java/kr/re/etri/autoflow/controllers/DockerRegistryController.java b/src/main/java/kr/re/etri/autoflow/controllers/DockerRegistryController.java index 6566a6f..fdd25e7 100644 --- a/src/main/java/kr/re/etri/autoflow/controllers/DockerRegistryController.java +++ b/src/main/java/kr/re/etri/autoflow/controllers/DockerRegistryController.java @@ -43,51 +43,4 @@ public class DockerRegistryController { return dockerRegistryService.listTags(repo) .map(ResponseEntity::ok); } - - @GetMapping("/repositories/{repo}/tags-with-digest") - @Operation(summary = "태그 목록 + digest 조회") - public Mono>> 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> 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> 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> 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> getDigest( - @PathVariable String repo, - @PathVariable String tag) { - return dockerRegistryService.getDigestByTag(repo, tag) - .map(ResponseEntity::ok); - } - } diff --git a/src/main/java/kr/re/etri/autoflow/service/DockerRegistryService.java b/src/main/java/kr/re/etri/autoflow/service/DockerRegistryService.java index d5b5095..d7bad6f 100644 --- a/src/main/java/kr/re/etri/autoflow/service/DockerRegistryService.java +++ b/src/main/java/kr/re/etri/autoflow/service/DockerRegistryService.java @@ -70,62 +70,4 @@ public class DockerRegistryService { .retrieve() .bodyToMono(JsonNode.class); } - - public Mono> 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 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 downloadImage(String repository, String digest) { - return webClientBuilder.build() - .get() - .uri(REGISTRY_URL + "/v2/" + repository + "/blobs/" + digest) - .retrieve() - .bodyToMono(byte[].class); - } - - public Mono 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 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")); - } }