@Test void testContainerFromConfigWithCommand() { final RunConfig runConfig = initMockRunConfigBuilder() .withCommand("/bin/sh") .build(); final Container result = RunConfigUtil.containerFromConfig(runConfig); assertThat(result) .hasFieldOrPropertyWithValue("args", Collections.emptyList()) .extracting(Container::getCommand) .asList().containsExactly("/bin/sh"); }
static Container containerFromConfig(RunConfig runConfig) { final ContainerBuilder containerBuilder = new ContainerBuilder(); containerBuilder.withName(runConfig.getName()); containerBuilder.withImage(runConfig.getImage()); containerBuilder.withImagePullPolicy(runConfig.getImagePullPolicy()); containerBuilder.withArgs(argsFromConfig(runConfig)); containerBuilder.withCommand(commandFromConfig(runConfig)); if (runConfig.getEnv() != null) { containerBuilder.withEnv(KubernetesResourceUtil.convertMapToEnvVarList(runConfig.getEnv())); } if (runConfig.getPort() > 0) { containerBuilder.withPorts(new ContainerPortBuilder() .withContainerPort(runConfig.getPort()) .build()); } if (runConfig.getLimits() != null) { containerBuilder.editOrNewResources() .addToLimits(runConfig.getLimits()) .endResources(); } if (runConfig.getRequests() != null) { containerBuilder.editOrNewResources() .addToRequests(runConfig.getRequests()) .endResources(); } return containerBuilder.build(); }
RunConfigUtil { static Container containerFromConfig(RunConfig runConfig) { final ContainerBuilder containerBuilder = new ContainerBuilder(); containerBuilder.withName(runConfig.getName()); containerBuilder.withImage(runConfig.getImage()); containerBuilder.withImagePullPolicy(runConfig.getImagePullPolicy()); containerBuilder.withArgs(argsFromConfig(runConfig)); containerBuilder.withCommand(commandFromConfig(runConfig)); if (runConfig.getEnv() != null) { containerBuilder.withEnv(KubernetesResourceUtil.convertMapToEnvVarList(runConfig.getEnv())); } if (runConfig.getPort() > 0) { containerBuilder.withPorts(new ContainerPortBuilder() .withContainerPort(runConfig.getPort()) .build()); } if (runConfig.getLimits() != null) { containerBuilder.editOrNewResources() .addToLimits(runConfig.getLimits()) .endResources(); } if (runConfig.getRequests() != null) { containerBuilder.editOrNewResources() .addToRequests(runConfig.getRequests()) .endResources(); } return containerBuilder.build(); } }
RunConfigUtil { static Container containerFromConfig(RunConfig runConfig) { final ContainerBuilder containerBuilder = new ContainerBuilder(); containerBuilder.withName(runConfig.getName()); containerBuilder.withImage(runConfig.getImage()); containerBuilder.withImagePullPolicy(runConfig.getImagePullPolicy()); containerBuilder.withArgs(argsFromConfig(runConfig)); containerBuilder.withCommand(commandFromConfig(runConfig)); if (runConfig.getEnv() != null) { containerBuilder.withEnv(KubernetesResourceUtil.convertMapToEnvVarList(runConfig.getEnv())); } if (runConfig.getPort() > 0) { containerBuilder.withPorts(new ContainerPortBuilder() .withContainerPort(runConfig.getPort()) .build()); } if (runConfig.getLimits() != null) { containerBuilder.editOrNewResources() .addToLimits(runConfig.getLimits()) .endResources(); } if (runConfig.getRequests() != null) { containerBuilder.editOrNewResources() .addToRequests(runConfig.getRequests()) .endResources(); } return containerBuilder.build(); } private  RunConfigUtil(); }
RunConfigUtil { static Container containerFromConfig(RunConfig runConfig) { final ContainerBuilder containerBuilder = new ContainerBuilder(); containerBuilder.withName(runConfig.getName()); containerBuilder.withImage(runConfig.getImage()); containerBuilder.withImagePullPolicy(runConfig.getImagePullPolicy()); containerBuilder.withArgs(argsFromConfig(runConfig)); containerBuilder.withCommand(commandFromConfig(runConfig)); if (runConfig.getEnv() != null) { containerBuilder.withEnv(KubernetesResourceUtil.convertMapToEnvVarList(runConfig.getEnv())); } if (runConfig.getPort() > 0) { containerBuilder.withPorts(new ContainerPortBuilder() .withContainerPort(runConfig.getPort()) .build()); } if (runConfig.getLimits() != null) { containerBuilder.editOrNewResources() .addToLimits(runConfig.getLimits()) .endResources(); } if (runConfig.getRequests() != null) { containerBuilder.editOrNewResources() .addToRequests(runConfig.getRequests()) .endResources(); } return containerBuilder.build(); } private  RunConfigUtil(); static ObjectMeta getObjectMetadataFromRunConfig(RunConfig generatorRunConfig); static PodSpec getPodSpecFromRunConfig(RunConfig generatorRunConfig); }
RunConfigUtil { static Container containerFromConfig(RunConfig runConfig) { final ContainerBuilder containerBuilder = new ContainerBuilder(); containerBuilder.withName(runConfig.getName()); containerBuilder.withImage(runConfig.getImage()); containerBuilder.withImagePullPolicy(runConfig.getImagePullPolicy()); containerBuilder.withArgs(argsFromConfig(runConfig)); containerBuilder.withCommand(commandFromConfig(runConfig)); if (runConfig.getEnv() != null) { containerBuilder.withEnv(KubernetesResourceUtil.convertMapToEnvVarList(runConfig.getEnv())); } if (runConfig.getPort() > 0) { containerBuilder.withPorts(new ContainerPortBuilder() .withContainerPort(runConfig.getPort()) .build()); } if (runConfig.getLimits() != null) { containerBuilder.editOrNewResources() .addToLimits(runConfig.getLimits()) .endResources(); } if (runConfig.getRequests() != null) { containerBuilder.editOrNewResources() .addToRequests(runConfig.getRequests()) .endResources(); } return containerBuilder.build(); } private  RunConfigUtil(); static ObjectMeta getObjectMetadataFromRunConfig(RunConfig generatorRunConfig); static PodSpec getPodSpecFromRunConfig(RunConfig generatorRunConfig);  }