-
Notifications
You must be signed in to change notification settings - Fork 645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Find the name of an image in an archive using a pattern #1208
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
happy with it for now, but would favor to move it to an extra section (maybe right after the table) to which we add only a reference here. Otherwise it will blow up the table quite a bit.
Also, I think the explanation is a not 100% clear, so would love to see some more elaborate examples explainng why the one is more useful than the other. E.g. describing the use case. In the example above its not clear to me why **/ is preferable (maybe because I don't understand what you want to achieve ;).