-
Notifications
You must be signed in to change notification settings - Fork 188
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
support multiple docker parameters and task labels #1169
Merged
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
1bae103
support multiple docker parameters and task labels
df3239f
make checkstyle happy
ssalinas 5e087c6
constructor args need @JsonProperty
ssalinas cef1df4
objects for custom (de)serialization
ssalinas efdcfa4
add missing dep on jackson-core
ssalinas 4bfad3d
spacing in pom
ssalinas a1b871e
No @JsonProperty on static JsonCreator
ssalinas 4f6eaa5
smart serialize, use map when no dupe keys
ssalinas 11899c4
back to sqaure 1 on this
ssalinas 3903be4
more cleanup
ssalinas 45b967f
Merge branch 'master' into multi-params-and-labels
ssalinas f9de4c9
separate fields for new docker params and task labels
ssalinas 63a3f97
move checks to validator
ssalinas 66caf6f
fix merge conflicts with master
ssalinas 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
68 changes: 68 additions & 0 deletions
68
SingularityBase/src/main/java/com/hubspot/mesos/SingularityDockerParameter.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,68 @@ | ||
package com.hubspot.mesos; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.google.common.base.Optional; | ||
|
||
public class SingularityDockerParameter { | ||
private final String key; | ||
private final String value; | ||
|
||
@JsonCreator | ||
public static SingularityDockerParameter fromString(String value) { | ||
return new SingularityDockerParameter(value, ""); | ||
} | ||
|
||
@JsonCreator | ||
public SingularityDockerParameter(@JsonProperty("key") String key, @JsonProperty("value") String value) { | ||
this.key = key; | ||
this.value = value; | ||
} | ||
|
||
public String getKey() { | ||
return key; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "SingularityDockerParameter{" + | ||
"key='" + key + '\'' + | ||
", value=" + value + | ||
'}'; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
SingularityDockerParameter that = (SingularityDockerParameter) o; | ||
return Objects.equals(key, that.key) && | ||
Objects.equals(value, that.value); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(key, value); | ||
} | ||
|
||
public static List<SingularityDockerParameter> parametersFromMap(Map<String, String> parametersMap) { | ||
List<SingularityDockerParameter> parameters = new ArrayList<>(); | ||
for (Map.Entry<String, String> entry : parametersMap.entrySet()) { | ||
parameters.add(new SingularityDockerParameter(entry.getKey(), entry.getValue())); | ||
} | ||
return parameters; | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
SingularityBase/src/main/java/com/hubspot/mesos/SingularityMesosTaskLabel.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,68 @@ | ||
package com.hubspot.mesos; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.google.common.base.Optional; | ||
|
||
public class SingularityMesosTaskLabel { | ||
private final String key; | ||
private final Optional<String> value; | ||
|
||
@JsonCreator | ||
public static SingularityMesosTaskLabel fromString(String value) { | ||
return new SingularityMesosTaskLabel(value, Optional.<String> absent()); | ||
} | ||
|
||
@JsonCreator | ||
public SingularityMesosTaskLabel(@JsonProperty("key") String key, @JsonProperty("value") Optional<String> value) { | ||
this.key = key; | ||
this.value = value; | ||
} | ||
|
||
public String getKey() { | ||
return key; | ||
} | ||
|
||
public Optional<String> getValue() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "SingularityLabel{" + | ||
"key='" + key + '\'' + | ||
", value=" + value + | ||
'}'; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
SingularityMesosTaskLabel that = (SingularityMesosTaskLabel) o; | ||
return Objects.equals(key, that.key) && | ||
Objects.equals(value, that.value); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(key, value); | ||
} | ||
|
||
public static List<SingularityMesosTaskLabel> labelsFromMap(Map<String, String> parametersMap) { | ||
List<SingularityMesosTaskLabel> labels = new ArrayList<>(); | ||
for (Map.Entry<String, String> entry : parametersMap.entrySet()) { | ||
labels.add(new SingularityMesosTaskLabel(entry.getKey(), Optional.of(entry.getValue()))); | ||
} | ||
return labels; | ||
} | ||
} |
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.
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.
I'm a little hesitant of putting these kinds of exceptions in constructors -- if we somehow had a bogus one saved we'd be throwing every time it was deserialized. What do you think about moving this into
SingularityValidator
instead?