use of io.fabric8.insight.metrics.model.Result in project carbon-apimgt by wso2.
the class KubernetesGatewayImpl method createServiceResource.
/**
* Create a service in cms
*
* @param serviceTemplate Service template as a String
* @param serviceName Name of the service
* @throws ContainerBasedGatewayException if failed to create a service
*/
private void createServiceResource(String serviceTemplate, String serviceName) throws ContainerBasedGatewayException {
HasMetadata resource = getResourcesFromTemplate(serviceTemplate);
try {
if (resource instanceof Service) {
// check whether there are existing service already
if (client.services().inNamespace(namespace).withName(serviceName).get() == null) {
log.debug("Deploying in CMS type: {} and the Service resource definition: {} ", cmsType, serviceTemplate);
Service service = (Service) resource;
Service result = client.services().inNamespace(namespace).create(service);
log.info("Created Service : " + result.getMetadata().getName() + " in Namespace : " + result.getMetadata().getNamespace() + " in " + cmsType);
} else {
log.info("There exist a service with the same name in " + cmsType + ". Service name : " + serviceName);
}
} else {
throw new ContainerBasedGatewayException("Loaded Resource is not a Service in " + cmsType + "! " + resource, ExceptionCodes.LOADED_RESOURCE_DEFINITION_IS_NOT_VALID);
}
} catch (KubernetesClientException e) {
throw new ContainerBasedGatewayException("Error while creating container based gateway service in " + cmsType + "!", e, ExceptionCodes.DEDICATED_CONTAINER_GATEWAY_CREATION_FAILED);
}
}
use of io.fabric8.insight.metrics.model.Result in project docker-maven-plugin by fabric8io.
the class QueryService method getLatestContainerForImage.
/**
* Get the id of the latest container started for an image
*
* @param image for which its container are looked up
* @return container or <code>null</code> if no container has been started for this image.
* @throws DockerAccessException if the request fails
*/
public Container getLatestContainerForImage(String image) throws DockerAccessException {
long newest = 0;
Container result = null;
for (Container container : getContainersForImage(image)) {
long timestamp = container.getCreated();
if (timestamp < newest) {
continue;
}
newest = timestamp;
result = container;
}
return result;
}
use of io.fabric8.insight.metrics.model.Result in project docker-maven-plugin by fabric8io.
the class DockerAssemblyManagerTest method assemblyFiles.
@Test
public void assemblyFiles(@Injectable final MojoParameters mojoParams, @Injectable final MavenProject project, @Injectable final Assembly assembly) throws AssemblyFormattingException, ArchiveCreationException, InvalidAssemblerConfigurationException, MojoExecutionException, AssemblyReadException, IllegalAccessException {
ReflectionUtils.setVariableValueInObject(assemblyManager, "trackArchiver", trackArchiver);
new Expectations() {
{
mojoParams.getOutputDirectory();
result = "target/";
times = 3;
mojoParams.getProject();
project.getBasedir();
result = ".";
assemblyReader.readAssemblies((AssemblerConfigurationSource) any);
result = Arrays.asList(assembly);
}
};
BuildImageConfiguration buildConfig = createBuildConfig();
assemblyManager.getAssemblyFiles("testImage", buildConfig, mojoParams, new AnsiLogger(new SystemStreamLog(), true, true));
}
use of io.fabric8.insight.metrics.model.Result in project docker-maven-plugin by fabric8io.
the class ConfigHelperTest method filter.
@Test
public void filter() throws Exception {
List<ImageConfiguration> configs = Arrays.asList(new ImageConfiguration.Builder().name("test").build());
CatchingLog logCatcher = new CatchingLog();
List<ImageConfiguration> result = ConfigHelper.resolveImages(new AnsiLogger(logCatcher, true, true), configs, createResolver(), "bla", createCustomizer());
assertEquals(0, result.size());
assertTrue(resolverCalled);
assertTrue(customizerCalled);
assertTrue(logCatcher.getWarnMessage().contains("test"));
assertTrue(logCatcher.getWarnMessage().contains("bla"));
}
use of io.fabric8.insight.metrics.model.Result in project docker-maven-plugin by fabric8io.
the class VolumeServiceTest method testCreateVolumeConfig.
@Test
public void testCreateVolumeConfig() throws Exception {
final VolumeConfiguration config = new VolumeConfiguration.Builder().name("testVolume").driver("test").opts(withMap("opts")).labels(withMap("labels")).build();
new Expectations() {
{
// Use a 'delegate' to verify the argument given directly. No need
// for an 'intermediate' return method in the service just to check this.
docker.createVolume(with(new Delegate<VolumeCreateConfig>() {
void check(VolumeCreateConfig vcc) {
assertThat(vcc.getName(), is("testVolume"));
JSONObject vccJson = (JSONObject) JSONParser.parseJSON(vcc.toJson());
assertEquals(vccJson.get("Driver"), "test");
}
}));
result = "testVolume";
}
};
String volume = new VolumeService(docker).createVolume(config);
assertEquals(volume, "testVolume");
}
Aggregations