-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #1207 Specify image name pattern when loading from archives.
This PR implements the proposed pattern matching that scans the archive prior to loading and then creates a tag from the image name loaded from the archive to the image name configured in the Maven project. Signed-off-by: William Rose <[email protected]>
- Loading branch information
1 parent
adc22e7
commit 3da45a3
Showing
21 changed files
with
1,177 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/java/io/fabric8/maven/docker/model/ImageArchiveManifest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.fabric8.maven.docker.model; | ||
|
||
import java.util.List; | ||
|
||
import com.google.gson.JsonObject; | ||
|
||
public interface ImageArchiveManifest { | ||
/** | ||
* @return the list of images in the archive. | ||
*/ | ||
List<ImageArchiveManifestEntry> getEntries(); | ||
|
||
/** | ||
* Return the JSON object for the named config | ||
* @param configName | ||
* @return | ||
*/ | ||
JsonObject getConfig(String configName); | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/io/fabric8/maven/docker/model/ImageArchiveManifestAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.fabric8.maven.docker.model; | ||
|
||
import java.util.ArrayList; | ||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
|
||
public class ImageArchiveManifestAdapter implements ImageArchiveManifest { | ||
private List<ImageArchiveManifestEntry> entries; | ||
|
||
private Map<String, JsonObject> config; | ||
|
||
public ImageArchiveManifestAdapter(JsonElement json) { | ||
this.entries = new ArrayList<>(); | ||
|
||
if(json.isJsonArray()) { | ||
for(JsonElement entryJson : json.getAsJsonArray()) { | ||
if(entryJson.isJsonObject()) { | ||
this.entries.add(new ImageArchiveManifestEntryAdapter(entryJson.getAsJsonObject())); | ||
} | ||
} | ||
} | ||
|
||
this.config = new LinkedHashMap<>(); | ||
} | ||
|
||
@Override | ||
public List<ImageArchiveManifestEntry> getEntries() { | ||
return this.entries; | ||
} | ||
|
||
@Override | ||
public JsonObject getConfig(String configName) { | ||
return this.config.get(configName); | ||
} | ||
|
||
public JsonObject putConfig(String configName, JsonObject config) { | ||
return this.config.put(configName, config); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/io/fabric8/maven/docker/model/ImageArchiveManifestEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.fabric8.maven.docker.model; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Interface representing an entry in an image archive manifest. | ||
*/ | ||
public interface ImageArchiveManifestEntry { | ||
/** | ||
* @return the image id for this manifest entry | ||
*/ | ||
String getId(); | ||
|
||
/** | ||
* @return the configuration JSON path for this manifest entry | ||
*/ | ||
String getConfig(); | ||
|
||
/** | ||
* @return the repository tags associated with this manifest entry | ||
*/ | ||
List<String> getRepoTags(); | ||
|
||
/** | ||
* @return the layer archive paths for this manifest entry | ||
*/ | ||
List<String> getLayers(); | ||
} |
67 changes: 67 additions & 0 deletions
67
src/main/java/io/fabric8/maven/docker/model/ImageArchiveManifestEntryAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package io.fabric8.maven.docker.model; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
|
||
/** | ||
* Adapter to convert from JSON representation to model. | ||
*/ | ||
public class ImageArchiveManifestEntryAdapter implements ImageArchiveManifestEntry { | ||
public static final String CONFIG = "Config"; | ||
public static final String REPO_TAGS = "RepoTags"; | ||
public static final String LAYERS = "Layers"; | ||
public static final String CONFIG_JSON_SUFFIX = ".json"; | ||
|
||
private String config; | ||
private List<String> repoTags; | ||
private List<String> layers; | ||
|
||
public ImageArchiveManifestEntryAdapter(JsonObject json) { | ||
JsonElement field; | ||
|
||
if((field = json.get(CONFIG)) != null && field.isJsonPrimitive()) { | ||
this.config = field.getAsString(); | ||
} | ||
|
||
this.repoTags = new ArrayList<>(); | ||
if ((field = json.get(REPO_TAGS)) != null && field.isJsonArray()) { | ||
for(JsonElement item : field.getAsJsonArray()) { | ||
if(item.isJsonPrimitive()) { | ||
this.repoTags.add(item.getAsString()); | ||
} | ||
} | ||
} | ||
|
||
this.layers = new ArrayList<>(); | ||
if ((field = json.get(LAYERS)) != null && field.isJsonArray()) { | ||
for(JsonElement item : field.getAsJsonArray()) { | ||
if(item.isJsonPrimitive()) { | ||
this.layers.add(item.getAsString()); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public String getConfig() { | ||
return config; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return this.config == null || !this.config.endsWith(CONFIG_JSON_SUFFIX) ? this.config : this.config.substring(0, this.config.length() - CONFIG_JSON_SUFFIX.length()); | ||
} | ||
|
||
@Override | ||
public List<String> getRepoTags() { | ||
return repoTags; | ||
} | ||
|
||
@Override | ||
public List<String> getLayers() { | ||
return layers; | ||
} | ||
} |
Oops, something went wrong.