Search in sources :

Example 51 with Entry

use of io.fabric8.maven.docker.config.CopyConfiguration.Entry in project docker-maven-plugin by fabric8io.

the class CopyConfigurationTest method assertEntriesAsProperties.

private void assertEntriesAsProperties(final CopyConfiguration cfg, Collection<Entry> expected) {
    final List<Properties> actual = cfg.getEntriesAsListOfProperties();
    if (expected == null) {
        assertNull(actual);
        return;
    }
    assertNotNull(actual);
    assertEquals(expected.size(), actual.size());
    final Iterator<Properties> actualIterator = actual.iterator();
    for (Entry expectedEntry : expected) {
        final Properties actualEntry = actualIterator.next();
        assertEquals(expectedEntry.getContainerPath(), actualEntry.get(CONTAINER_PATH_PROPERTY));
        assertEquals(expectedEntry.getHostDirectory(), actualEntry.get(HOST_DIRECTORY_PROPERTY));
    }
}
Also used : Entry(io.fabric8.maven.docker.config.CopyConfiguration.Entry) Properties(java.util.Properties)

Example 52 with Entry

use of io.fabric8.maven.docker.config.CopyConfiguration.Entry in project docker-maven-plugin by fabric8io.

the class CopyConfigurationTest method entriesAsListOfProperties.

private List<Properties> entriesAsListOfProperties(Collection<Entry> expected) {
    if (expected == null) {
        return null;
    }
    final List<Properties> propertiesList = new ArrayList<>(expected.size());
    for (Entry entry : expected) {
        final Properties properties = new Properties();
        final String containerPath = entry.getContainerPath();
        final String hostDirectory = entry.getHostDirectory();
        if (containerPath != null && hostDirectory == null) {
            properties.put("", containerPath);
        } else {
            if (containerPath != null) {
                properties.put(CONTAINER_PATH_PROPERTY, containerPath);
            }
            if (hostDirectory != null) {
                properties.put(HOST_DIRECTORY_PROPERTY, hostDirectory);
            }
        }
        properties.put("some.garbage", "which should be ignored");
        propertiesList.add(properties);
    }
    return propertiesList;
}
Also used : Entry(io.fabric8.maven.docker.config.CopyConfiguration.Entry) ArrayList(java.util.ArrayList) Properties(java.util.Properties)

Example 53 with Entry

use of io.fabric8.maven.docker.config.CopyConfiguration.Entry in project docker-maven-plugin by fabric8io.

the class CopyConfigurationTest method copyOfNotNull.

@Test
public void copyOfNotNull() {
    final List<Entry> expected = entries();
    final CopyConfiguration original = new Builder().entries(expected).build();
    final CopyConfiguration copy = new Builder(original).build();
    assertEntries(copy, expected);
    assertEntriesAsProperties(copy, expected);
}
Also used : Entry(io.fabric8.maven.docker.config.CopyConfiguration.Entry) Builder(io.fabric8.maven.docker.config.CopyConfiguration.Builder) Test(org.junit.Test)

Example 54 with Entry

use of io.fabric8.maven.docker.config.CopyConfiguration.Entry in project docker-maven-plugin by fabric8io.

the class CopyConfigurationTest method entryGetters.

@Test
public void entryGetters() {
    final String containerPath = "container";
    final String hostDirectory = "host";
    final Entry entry = new Entry(containerPath, hostDirectory);
    assertEquals(containerPath, entry.getContainerPath());
    assertEquals(hostDirectory, entry.getHostDirectory());
}
Also used : Entry(io.fabric8.maven.docker.config.CopyConfiguration.Entry) Test(org.junit.Test)

Example 55 with Entry

use of io.fabric8.maven.docker.config.CopyConfiguration.Entry in project syndesis-qe by syndesisio.

the class Syndesis method updateAddon.

/**
 * Enable or disable the addon
 *
 * @param addon - which type of addon
 * @param enabled - enable or disable?
 * @param properties - additional properties for the specific addon
 */
public void updateAddon(Addon addon, boolean enabled, Map<String, Object> properties) {
    log.info((enabled ? "Enabling " : "Disabling ") + addon + " addon.");
    JSONObject cr = new JSONObject(getCr());
    JSONObject specAddon = cr.getJSONObject("spec").getJSONObject("addons").getJSONObject(addon.getValue());
    specAddon.put("enabled", enabled);
    if (properties != null) {
        for (Map.Entry<String, Object> entry : properties.entrySet()) {
            log.info("Adding property '" + entry.getKey() + ": " + entry.getValue() + "' for addon " + addon.getValue() + " to the CR");
            specAddon.put(entry.getKey(), entry.getValue());
        }
    }
    try {
        this.editCr(cr.toMap());
    } catch (KubernetesClientException kce) {
        if (kce.getMessage().contains("the object has been modified")) {
            log.warn("CR was modified in the mean time, retrying in 30 seconds");
            TestUtils.sleepIgnoreInterrupt(30000L);
            updateAddon(addon, enabled, properties);
        } else {
            throw kce;
        }
    }
}
Also used : JSONObject(org.json.JSONObject) JSONObject(org.json.JSONObject) Map(java.util.Map) HashMap(java.util.HashMap) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException)

Aggregations

Map (java.util.Map)89 HashMap (java.util.HashMap)57 IOException (java.io.IOException)31 File (java.io.File)30 ArrayList (java.util.ArrayList)26 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)16 List (java.util.List)14 Properties (java.util.Properties)14 HashSet (java.util.HashSet)10 Entry (io.fabric8.maven.docker.config.CopyConfiguration.Entry)9 ZipFile (org.apache.commons.compress.archivers.zip.ZipFile)9 Test (org.junit.Test)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 LinkedHashMap (java.util.LinkedHashMap)8 TreeMap (java.util.TreeMap)8 Resource (io.fabric8.kubernetes.client.dsl.Resource)7 FileInputStream (java.io.FileInputStream)7 Set (java.util.Set)7 Profile (io.fabric8.api.Profile)6 ProfileService (io.fabric8.api.ProfileService)5