Skip to content

Commit

Permalink
Use meaningful value for plugin broker container name instead of gene…
Browse files Browse the repository at this point in the history
…rated one

Signed-off-by: Sergii Leshchenko <sleshche@redhat.com>
  • Loading branch information
sleshchenko committed Jan 25, 2019
1 parent c7e0919 commit e41994d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private Container newContainer(
@Nullable String brokerVolumeName) {
final ContainerBuilder cb =
new ContainerBuilder()
.withName(generateUniqueName(CONTAINER_NAME_SUFFIX))
.withName(image.toLowerCase().replaceAll("[^\\d\\w-]", "-"))
.withImage(image)
.withArgs(
"-push-endpoint",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.common.collect.ImmutableMap;
import io.fabric8.kubernetes.api.model.Container;
import io.fabric8.kubernetes.api.model.EnvVar;
import io.fabric8.kubernetes.api.model.PodSpec;
import java.util.Collection;
import java.util.List;
import org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity;
Expand Down Expand Up @@ -121,6 +122,7 @@ public void testInitBrokerContainer() throws Exception {
List<Container> initContainers = brokersConfigs.pod.getSpec().getInitContainers();
assertEquals(initContainers.size(), 1);
Container initContainer = initContainers.get(0);
assertEquals(initContainer.getName(), "init-image");
assertEquals(initContainer.getImage(), INIT_IMAGE);
assertEquals(initContainer.getImagePullPolicy(), IMAGE_PULL_POLICY);
assertEquals(
Expand All @@ -139,4 +141,27 @@ public void testInitBrokerContainer() throws Exception {
assertEquals(Containers.getRamLimit(initContainer), 262144000);
assertEquals(Containers.getRamLimit(initContainer), 262144000);
}

@Test
public void shouldNameContainersAfterPluginBrokerImage() throws Exception {
// given
Collection<PluginMeta> metas = singletonList(new PluginMeta().type(SUPPORTED_TYPE));
ArgumentCaptor<BrokersConfigs> captor = ArgumentCaptor.forClass(BrokersConfigs.class);

// when
factory.create(metas, runtimeId, new BrokersResult());

// then
verify(factory).doCreate(captor.capture());
BrokersConfigs brokersConfigs = captor.getValue();
PodSpec brokerPodSpec = brokersConfigs.pod.getSpec();

List<Container> initContainers = brokerPodSpec.getInitContainers();
assertEquals(initContainers.size(), 1);
assertEquals(initContainers.get(0).getName(), "init-image");

List<Container> containers = brokerPodSpec.getContainers();
assertEquals(containers.size(), 1);
assertEquals(containers.get(0).getName(), "testrepo-image-tag");
}
}

0 comments on commit e41994d

Please sign in to comment.