-
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.
Signed-off-by: Jae Gangemi <jgangemi@gmail.com>
- Loading branch information
Showing
19 changed files
with
1,134 additions
and
170 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
69 changes: 69 additions & 0 deletions
69
src/main/java/org/jolokia/docker/maven/config/external/DockerComposeConfiguration.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,69 @@ | ||
package org.jolokia.docker.maven.config.external; | ||
|
||
import java.util.*; | ||
|
||
import org.jolokia.docker.maven.config.*; | ||
|
||
public class DockerComposeConfiguration { | ||
|
||
/** @parameter */ | ||
private String basedir; | ||
|
||
/** @parameter */ | ||
private List<ImageConfiguration> services = new ArrayList<>(); | ||
|
||
/** @parameter */ | ||
private String yamlFile; | ||
|
||
public String getBasedir() { | ||
// the @parameter tags above don't actually do anything, so we need to handle the default here :( | ||
return (basedir == null) ? "src/main/docker" : basedir; | ||
} | ||
|
||
public Map<String, ImageConfiguration> getServiceMap() { | ||
if (services == null) { | ||
return Collections.emptyMap(); | ||
} | ||
|
||
Map<String, ImageConfiguration> map = new HashMap<>(services.size()); | ||
for (ImageConfiguration service : services) { | ||
String alias = service.getAlias(); | ||
if (alias == null) { | ||
throw new IllegalArgumentException("an 'alias' is required when using docker-compose files"); | ||
} | ||
|
||
map.put(alias, service); | ||
} | ||
|
||
return map; | ||
} | ||
|
||
public String getYamlFile() { | ||
// see 'getBasedir' | ||
return (yamlFile == null) ? "docker-compose.yml" : yamlFile; | ||
} | ||
|
||
public static class Builder { | ||
private final DockerComposeConfiguration composeConfig = new DockerComposeConfiguration(); | ||
|
||
public Builder addService(ImageConfiguration service) { | ||
composeConfig.services.add(service); | ||
return this; | ||
} | ||
|
||
public Builder basedir(String basedir) { | ||
composeConfig.basedir = basedir; | ||
return this; | ||
} | ||
|
||
public DockerComposeConfiguration build() { | ||
return composeConfig; | ||
} | ||
|
||
public Builder yamlFile(String yamlFile) { | ||
composeConfig.yamlFile = yamlFile; | ||
return this; | ||
} | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/org/jolokia/docker/maven/config/external/ExternalImageConfiguration.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,44 @@ | ||
package org.jolokia.docker.maven.config.external; | ||
|
||
public class ExternalImageConfiguration { | ||
|
||
/** @parameter */ | ||
private DockerComposeConfiguration compose; | ||
|
||
/** @parameter */ | ||
private PropertiesConfiguration properties; | ||
|
||
public DockerComposeConfiguration getComposeConfiguration() { | ||
return compose; | ||
} | ||
|
||
public boolean hasDockerCompose() { | ||
return compose != null; | ||
} | ||
|
||
public boolean hasProperties() { | ||
return properties != null; | ||
} | ||
|
||
public PropertiesConfiguration getPropertiesConfiguration() { | ||
return properties; | ||
} | ||
|
||
public static class Builder { | ||
private final ExternalImageConfiguration externalConfig = new ExternalImageConfiguration(); | ||
|
||
public Builder compose(DockerComposeConfiguration compose) { | ||
externalConfig.compose = compose; | ||
return this; | ||
} | ||
|
||
public Builder properties(PropertiesConfiguration properties) { | ||
externalConfig.properties = properties; | ||
return this; | ||
} | ||
|
||
public ExternalImageConfiguration build() { | ||
return externalConfig; | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/org/jolokia/docker/maven/config/external/PropertiesConfiguration.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,24 @@ | ||
package org.jolokia.docker.maven.config.external; | ||
|
||
public class PropertiesConfiguration { | ||
|
||
/** @parameter */ | ||
private String prefix; | ||
|
||
public String getPrefix() { | ||
return prefix; | ||
} | ||
|
||
public static class Builder { | ||
private final PropertiesConfiguration propsConfig = new PropertiesConfiguration(); | ||
|
||
public Builder prefix(String prefix) { | ||
propsConfig.prefix = prefix; | ||
return this; | ||
} | ||
|
||
public PropertiesConfiguration build() { | ||
return propsConfig; | ||
} | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
src/main/java/org/jolokia/docker/maven/config/handler/ExternalConfigHandlerException.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,16 @@ | ||
package org.jolokia.docker.maven.config.handler; | ||
|
||
public class ExternalConfigHandlerException extends RuntimeException | ||
{ | ||
private static final long serialVersionUID = -2742743075207582636L; | ||
|
||
public ExternalConfigHandlerException(String message) | ||
{ | ||
super(message); | ||
} | ||
|
||
public ExternalConfigHandlerException(String message, Throwable cause) | ||
{ | ||
super(message, cause); | ||
} | ||
} |
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
Oops, something went wrong.