Fix docker image tag information 02/3002/1
authorSerban Jora <sj2381@att.com>
Wed, 3 Oct 2018 06:22:40 +0000 (02:22 -0400)
committerSerban Jora <sj2381@att.com>
Wed, 3 Oct 2018 06:24:57 +0000 (02:24 -0400)
Change-Id: I13faceabb50404cc00d3bbc84526926f6edb12f4
Signed-off-by: Serban Jora <sj2381@att.com>
Issue-ID: ACUMOS-1781

gateway/src/main/java/org/acumos/federation/gateway/controller/CatalogController.java
gateway/src/main/java/org/acumos/federation/gateway/service/impl/ContentServiceImpl.java

index 997cdd6..09dcda5 100644 (file)
@@ -507,14 +507,9 @@ public class CatalogController extends AbstractController {
                
                if (ArtifactType.DockerImage == ArtifactType.forCode(theArtifact.getArtifactTypeCode())) {
                        if (artifactUri != null) {
-                               Identifier imageId = Identifier.fromCompoundString(artifactUri);
-                       
-                               String imageTag = imageId.tag.orNull();
-                               if (imageTag != null) {
-                                       log.debug(EELFLoggerDelegate.debugLogger,       "encodeArtifact: encoded docker image uri to tag " + imageTag);
-                                       theArtifact.setName(imageTag);
-                                       theArtifact.setDescription(imageTag);
-                               }
+                               //ugly but avoids parsing the manifest on the receiving side
+                               //this seems to be what on-boarding is doing anyway, otherwise this would amount to information loss
+                               theArtifact.setDescription(artifactUri);
                        }
                }
        }
index 37c8884..4f7fc4d 100644 (file)
@@ -136,8 +136,10 @@ public class ContentServiceImpl extends AbstractServiceImpl
                                List<Image> images = docker.listImagesCmd().exec();
                                log.debug(EELFLoggerDelegate.debugLogger, "Available docker images: {}", images);
 
+                               //this relies on the presence of the original uri/tag in the description (which is what the controller does), otherwise
+                               //we'd need to pick this information from the manifest
                                Image image = images.stream()
-                                                                                               .filter(i -> i.getRepoTags() != null && Stream.of(i.getRepoTags()).anyMatch(t -> t.equals(theArtifact.getUri())))
+                                                                                               .filter(i -> i.getRepoTags() != null && Stream.of(i.getRepoTags()).anyMatch(t -> t.equals(theArtifact.getDescription())))
                                                                                                .findFirst()
                                                                                                .orElse(null);
                                if (image == null) {
@@ -145,7 +147,7 @@ public class ContentServiceImpl extends AbstractServiceImpl
                                        throw new ServiceException("Could not find loaded docker image for " + theArtifact);
                                }
        
-                               //new image name for re-tagging
+                               //new image name for re-tagging. is this really necessary ??
                                String imageName = theArtifact.getName() + "_" + theSolutionId; 
                                docker.tagImageCmd(image.getId(), imageName, theArtifact.getVersion()).exec();
                                log.debug(EELFLoggerDelegate.debugLogger, "Re-tagged docker image: {} to {}:{}", image, imageName, theArtifact.getVersion());