-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Enable Labels in Container Config #750
Changes from 2 commits
b3cd4d5
2cfbe27
ce1ca71
ca90dfd
e31fbc1
0f0a0df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,7 @@ public void testBuilder() { | |
Map<String, String> expectedEnvironment = ImmutableMap.of("key", "value"); | ||
ImmutableList<Port> expectedExposedPorts = | ||
ImmutableList.of(new Port(1000, Protocol.TCP), new Port(2000, Protocol.TCP)); | ||
Map<String, String> expectedLabels = ImmutableMap.of("key1", "value1", "key2", "value2"); | ||
Class<? extends BuildableManifestTemplate> expectedTargetFormat = OCIManifestTemplate.class; | ||
CacheConfiguration expectedApplicationLayersCacheConfiguration = | ||
CacheConfiguration.forPath(Paths.get("application/layers")); | ||
|
@@ -90,6 +91,7 @@ public void testBuilder() { | |
.setProgramArguments(expectedJavaArguments) | ||
.setEnvironment(expectedEnvironment) | ||
.setExposedPorts(expectedExposedPorts) | ||
.setLabels(expectedLabels) | ||
.build(); | ||
BuildConfiguration.Builder buildConfigurationBuilder = | ||
BuildConfiguration.builder(Mockito.mock(BuildLogger.class)) | ||
|
@@ -134,6 +136,7 @@ public void testBuilder() { | |
expectedEnvironment, buildConfiguration.getContainerConfiguration().getEnvironmentMap()); | ||
Assert.assertEquals( | ||
expectedExposedPorts, buildConfiguration.getContainerConfiguration().getExposedPorts()); | ||
Assert.assertEquals(expectedLabels, buildConfiguration.getContainerConfiguration().getLabels()); | ||
Assert.assertEquals(expectedTargetFormat, buildConfiguration.getTargetFormat()); | ||
Assert.assertEquals( | ||
expectedApplicationLayersCacheConfiguration, | ||
|
@@ -250,6 +253,17 @@ public void testBuilder_nullValues() { | |
Assert.assertNull(ex.getMessage()); | ||
} | ||
|
||
// Labels element should not be null. | ||
try { | ||
Map<String, String> badLabels = new HashMap<>(); | ||
badLabels.put("label-key", null); | ||
BuildConfiguration.builder(Mockito.mock(BuildLogger.class)) | ||
.setContainerConfiguration(ContainerConfiguration.builder().setLabels(badLabels).build()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The try block should only be focused on the method being tested. I actually think Map<String, String> badLabels = ...
badLabels.put(...)
Builder builder = ContainerConfiguration.builder();
try {
builder.setLabels(badLabels);
Assert.fail(...);
} catch (...) { There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, makes sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hrmm... looks like we might need to cleanup this whole test class :\ |
||
Assert.fail("The IllegalArgumentException should be thrown."); | ||
} catch (IllegalArgumentException ex) { | ||
Assert.assertNull(ex.getMessage()); | ||
} | ||
|
||
// Environment keys element should not be null. | ||
Map<String, String> nullKeyMap = new HashMap<>(); | ||
nullKeyMap.put(null, "value"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"created":"1970-01-01T00:00:20Z","architecture":"amd64","os":"linux","config":{"Env":["VAR1=VAL1","VAR2=VAL2"],"Entrypoint":["some","entrypoint","command"],"Cmd":["arg1","arg2"],"ExposedPorts":{"1000/tcp":{},"2000/tcp":{},"3000/udp":{}}},"rootfs":{"type":"layers","diff_ids":["sha256:8c662931926fa990b41da3c9f42663a537ccd498130030f9149173a0493832ad"]}} | ||
{"created":"1970-01-01T00:00:20Z","architecture":"amd64","os":"linux","config":{"Env":["VAR1=VAL1","VAR2=VAL2"],"Entrypoint":["some","entrypoint","command"],"Cmd":["arg1","arg2"],"ExposedPorts":{"1000/tcp":{},"2000/tcp":{},"3000/udp":{}},"Labels":{"key1":"value1","key2":"value2"}},"rootfs":{"type":"layers","diff_ids":["sha256:8c662931926fa990b41da3c9f42663a537ccd498130030f9149173a0493832ad"]}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"application/vnd.oci.image.config.v1+json","digest":"sha256:1bc0730d8135d29caa0e0c5b502164195afcab6494e1b024e419dc9d591d778d","size":353},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar+gzip","digest":"sha256:8c662931926fa990b41da3c9f42663a537ccd498130030f9149173a0493832ad","size":1000}]} | ||
{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"application/vnd.oci.image.config.v1+json","digest":"sha256:b988b86bf80435bdfe7b2f361f5e5838bdf2abd5dcb5ff298122504f8fb80e95","size":396},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar+gzip","digest":"sha256:8c662931926fa990b41da3c9f42663a537ccd498130030f9149173a0493832ad","size":1000}]} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"schemaVersion":2,"mediaType":"application/vnd.docker.distribution.manifest.v2+json","config":{"mediaType":"application/vnd.docker.container.image.v1+json","digest":"sha256:1bc0730d8135d29caa0e0c5b502164195afcab6494e1b024e419dc9d591d778d","size":353},"layers":[{"mediaType":"application/vnd.docker.image.rootfs.diff.tar.gzip","digest":"sha256:8c662931926fa990b41da3c9f42663a537ccd498130030f9149173a0493832ad","size":1000}]} | ||
{"schemaVersion":2,"mediaType":"application/vnd.docker.distribution.manifest.v2+json","config":{"mediaType":"application/vnd.docker.container.image.v1+json","digest":"sha256:b988b86bf80435bdfe7b2f361f5e5838bdf2abd5dcb5ff298122504f8fb80e95","size":396},"layers":[{"mediaType":"application/vnd.docker.image.rootfs.diff.tar.gzip","digest":"sha256:8c662931926fa990b41da3c9f42663a537ccd498130030f9149173a0493832ad","size":1000}]} |
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 guess we could do the same thing here as with labels and use a ternary operator.
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.
Yeah, I was going to, but figured it should be in a followup. This ImmutableList -> List change probably shouldn't be part of this PR either. I might go through and do some cleanup after this.