Skip to content
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

Use meaningful value for plugin broker container name instead of generated one #12372

Merged
merged 1 commit into from
Jan 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
}
}