Search in sources :

Example 76 with Image

use of io.fabric8.docker.api.model.Image in project docker-maven-plugin by fabric8io.

the class PropertyConfigHandlerTest method testNoCacheEnabled.

@Test
public void testNoCacheEnabled() throws Exception {
    String[] testData = new String[] { k(ConfigKey.NAME), "image", k(ConfigKey.NOCACHE), "true", k(ConfigKey.FROM), "base" };
    ImageConfiguration config = resolveExternalImageConfig(testData);
    assertEquals(true, config.getBuildConfiguration().nocache());
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) AbstractConfigHandlerTest(io.fabric8.maven.docker.config.handler.AbstractConfigHandlerTest)

Example 77 with Image

use of io.fabric8.docker.api.model.Image in project docker-maven-plugin by fabric8io.

the class PropertyConfigHandlerTest method testNoCacheDisabled.

@Test
public void testNoCacheDisabled() throws Exception {
    String[] testData = new String[] { k(ConfigKey.NAME), "image", k(ConfigKey.NOCACHE), "false", k(ConfigKey.FROM), "base" };
    ImageConfiguration config = resolveExternalImageConfig(testData);
    assertEquals(false, config.getBuildConfiguration().nocache());
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) AbstractConfigHandlerTest(io.fabric8.maven.docker.config.handler.AbstractConfigHandlerTest)

Example 78 with Image

use of io.fabric8.docker.api.model.Image in project docker-maven-plugin by fabric8io.

the class PropertyConfigHandlerTest method resolveExternalImageConfig.

private ImageConfiguration resolveExternalImageConfig(String[] testData) {
    Map<String, String> external = new HashMap<>();
    external.put("type", "props");
    ImageConfiguration config = new ImageConfiguration.Builder().name("image").alias("alias").externalConfig(external).build();
    List<ImageConfiguration> resolvedImageConfigs = resolveImage(config, props(testData));
    assertEquals(1, resolvedImageConfigs.size());
    return resolvedImageConfigs.get(0);
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration)

Example 79 with Image

use of io.fabric8.docker.api.model.Image in project docker-maven-plugin by fabric8io.

the class PropertyConfigHandlerTest method testFilter.

@Test
public void testFilter() {
    String filter = "@";
    String[] testData = new String[] { k(ConfigKey.NAME), "image", k(ConfigKey.FROM), "base", k(ConfigKey.FILTER), filter };
    ImageConfiguration config = resolveExternalImageConfig(testData);
    assertEquals(filter, config.getBuildConfiguration().getFilter());
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) AbstractConfigHandlerTest(io.fabric8.maven.docker.config.handler.AbstractConfigHandlerTest)

Example 80 with Image

use of io.fabric8.docker.api.model.Image in project kie-wb-common by kiegroup.

the class OpenShiftClient method destroy.

public void destroy(String id) throws OpenShiftClientException {
    try {
        OpenShiftRuntimeId runtimeId = OpenShiftRuntimeId.fromString(id);
        String prjName = runtimeId.project();
        String svcName = runtimeId.service();
        // TODO: should we always depend on the app label being specified, or gotten from the service?
        String appName = runtimeId.application();
        if (appName == null || appName.isEmpty()) {
            Service service = delegate.services().inNamespace(prjName).withName(svcName).get();
            if (service != null) {
                appName = service.getMetadata().getLabels().get(APP_LABEL);
            }
        }
        /*
             * cascading delete of deploymentConfigs means we don't have to also do the following:
             *     delegate.deploymentConfigs().inNamespace(prjName).withLabel(APP_LABEL, appName).delete();
             *     delegate.replicationControllers().inNamespace(prjName).withLabel(APP_LABEL, appName).delete();
             *     delegate.pods().inNamespace(prjName).withLabel(APP_LABEL, appName).delete();
             * , but deleting services and routes are still necessary:
             */
        delegate.deploymentConfigs().inNamespace(prjName).withName(svcName).cascading(true).delete();
        if (appName != null) {
            delegate.services().inNamespace(prjName).withLabel(APP_LABEL, appName).delete();
            delegate.routes().inNamespace(prjName).withLabel(APP_LABEL, appName).delete();
        } else {
            delegate.services().inNamespace(prjName).delete();
            delegate.routes().inNamespace(prjName).delete();
        }
        // clean up any generated image streams, secrets, and service accounts
        for (ImageStream item : delegate.imageStreams().inNamespace(prjName).list().getItems()) {
            if (isGuvnorAlaGenerated(item)) {
                delegate.imageStreams().inNamespace(prjName).delete(item);
            }
        }
        for (Secret item : delegate.secrets().inNamespace(prjName).list().getItems()) {
            if (isGuvnorAlaGenerated(item)) {
                delegate.secrets().inNamespace(prjName).delete(item);
            }
        }
        for (ServiceAccount item : delegate.serviceAccounts().inNamespace(prjName).list().getItems()) {
            if (isGuvnorAlaGenerated(item)) {
                delegate.serviceAccounts().inNamespace(prjName).delete(item);
            }
        }
        // clean up generated project
        if (isGuvnorAlaGenerated(delegate.projects().withName(prjName).get())) {
            delegate.projects().withName(prjName).delete();
        }
    } catch (Throwable t) {
        throw new OpenShiftClientException(t.getMessage(), t);
    }
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) ServiceAccount(io.fabric8.kubernetes.api.model.ServiceAccount) Service(io.fabric8.kubernetes.api.model.Service) ImageStream(io.fabric8.openshift.api.model.ImageStream) OpenShiftClientException(org.guvnor.ala.openshift.access.exceptions.OpenShiftClientException) IntOrString(io.fabric8.kubernetes.api.model.IntOrString)

Aggregations

Test (org.junit.Test)35 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)28 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)20 IOException (java.io.IOException)16 AbstractConfigHandlerTest (io.fabric8.maven.docker.config.handler.AbstractConfigHandlerTest)15 File (java.io.File)13 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)12 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)12 ImageStream (io.fabric8.openshift.api.model.ImageStream)10 Arguments (io.fabric8.maven.docker.config.Arguments)8 Service (io.fabric8.kubernetes.api.model.Service)7 Fabric8ServiceException (io.fabric8.maven.core.service.Fabric8ServiceException)7 Deployment (io.fabric8.kubernetes.api.model.extensions.Deployment)6 BuildService (io.fabric8.maven.core.service.BuildService)6 BuildConfig (io.fabric8.openshift.api.model.BuildConfig)6 HashMap (java.util.HashMap)6 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)5 DockerAccessException (io.fabric8.maven.docker.access.DockerAccessException)5 ImageName (io.fabric8.maven.docker.util.ImageName)5 ImageStreamTag (io.fabric8.openshift.api.model.ImageStreamTag)5