Skip to content

Commit

Permalink
If workspace base image does not have labels, skip merge of image lab…
Browse files Browse the repository at this point in the history
…els (#7252)

* If image does not have labels, skip merge

Relates to #7249
If image does not have labels in config, the merge fails with nullpointerexception.
This patch does the merge only if labels!=null

Signed-off-by: Olivier Sallou <olivier.sallou@gmail.com>
  • Loading branch information
osallou authored and benoitf committed Nov 9, 2017
1 parent a17f120 commit d9a79e1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Expand Up @@ -86,7 +86,10 @@ public Object invoke(MethodInvocation methodInvocation) throws Throwable {

// Now merge all labels
final Map<String, String> allLabels = new HashMap<>(containerLabels);
allLabels.putAll(imageLabels);
if (imageLabels != null) {
// If image has some labels, merge them
allLabels.putAll(imageLabels);
}

// Get all ports exposed by the container and by the image
// it is under the form "22/tcp"
Expand Down
Expand Up @@ -114,6 +114,16 @@ protected void setup() throws Exception {
when(imageInfoConfig.getEnv()).thenReturn(envImageConfig);
}

@Test
public void testRulesWithNullImageLabels() throws Throwable {
when(imageInfoConfig.getLabels()).thenReturn(null);
containerLabels.put("foo1", "bar");

traefikCreateContainerInterceptor.invoke(methodInvocation);

Assert.assertFalse(containerLabels.containsKey("traefik.service-tomcat8.frontend.rule"));
}

@Test
public void testRules() throws Throwable {
containerLabels.put("foo1", "bar");
Expand Down

0 comments on commit d9a79e1

Please sign in to comment.