Search in sources :

Example 76 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class FabricResource method versions.

/**
 * Returns the list of version ids
 */
@GET
@Path("versions")
public Map<String, String> versions() {
    FabricService fabricService = getFabricService();
    if (fabricService != null) {
        ProfileService profileService = fabricService.adapt(ProfileService.class);
        List<String> versionIds = profileService.getVersions();
        return mapToLinks(versionIds, "/version/");
    } else {
        noFabricService();
    }
    return Collections.emptyMap();
}
Also used : ProfileService(io.fabric8.api.ProfileService) FabricService(io.fabric8.api.FabricService) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 77 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class FabricWebRegistrationHandler method registerWebapp.

/**
 * Registers a webapp to the registry.
 */
private void registerWebapp(Container container, WebEvent webEvent) {
    String id = container.getId();
    String url = "${zk:" + id + "/http}" + webEvent.getContextPath();
    String bundleName = webEvent.getBundle().getSymbolicName();
    String bundleVersion = webEvent.getBundle().getVersion().toString();
    setJolokiaUrl(container, url, bundleName);
    Version version = container.getVersion();
    String versionId = version != null ? version.getId() : null;
    String json = "{\"id\":" + jsonEncodeString(id) + ",\"services\":[" + jsonEncodeString(url) + "]" + ",\"version\":" + JsonHelper.jsonEncodeString(versionId) + ",\"bundleName\":" + jsonEncodeString(bundleName) + ",\"bundleVersion\":" + jsonEncodeString(bundleVersion) + ",\"container\":" + jsonEncodeString(id) + "}";
    try {
        synchronized (webEvent.getBundle()) {
            setData(curator.get(), ZkPath.WEBAPPS_CONTAINER.getPath(bundleName, webEvent.getBundle().getVersion().toString(), id), json, CreateMode.EPHEMERAL);
        }
    } catch (Exception e) {
        LOGGER.error("Failed to register webapp {}.", webEvent.getContextPath(), e);
    }
}
Also used : Version(io.fabric8.api.Version) JsonHelper.jsonEncodeString(io.fabric8.internal.JsonHelper.jsonEncodeString) KeeperException(org.apache.zookeeper.KeeperException)

Example 78 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class ProvisionSupport method profileAvailable.

public static Boolean profileAvailable(String profile, String version, Long timeout) throws Exception {
    FabricService fabricService = ServiceLocator.awaitService(FabricService.class);
    ProfileRegistry profileRegistry = fabricService.adapt(ProfileRegistry.class);
    for (long t = 0; (!profileRegistry.hasProfile(version, profile) && t < timeout); t += 2000L) {
        Thread.sleep(2000L);
    }
    return profileRegistry.hasProfile(version, profile);
}
Also used : FabricService(io.fabric8.api.FabricService) ProfileRegistry(io.fabric8.api.ProfileRegistry)

Example 79 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class Log4jLogQuery method loadCoords.

protected String loadCoords(String coords, String filePath, String classifier) throws IOException {
    String[] split = coords.split("/");
    if (split != null && split.length > 2) {
        String groupId = split[0];
        String artifactId = split[1];
        String version = split[2];
        if (resolver == null) {
            Properties defaultProperties = getDefaultProperties();
            Properties systemProperties = System.getProperties();
            if (config == null) {
                Properties combined = new Properties();
                combined.putAll(defaultProperties);
                combined.putAll(systemProperties);
                if (properties != null) {
                    combined.putAll(properties);
                }
                config = new MavenConfigurationImpl(new PropertiesPropertyResolver(combined), ServiceConstants.PID);
            }
            resolver = new AetherBasedResolver(config);
        }
        File file = resolver.resolveFile(groupId, artifactId, classifier, "jar", version);
        if (file.exists() && file.isFile()) {
            if (isRoot(filePath)) {
                return jarIndex(file);
            }
            String fileUri = file.toURI().toString();
            URL url = new URL("jar:" + fileUri + "!" + filePath);
            return loadString(url);
        }
    }
    return null;
}
Also used : MavenConfigurationImpl(io.fabric8.maven.util.MavenConfigurationImpl) PropertiesPropertyResolver(org.ops4j.util.property.PropertiesPropertyResolver) Properties(java.util.Properties) File(java.io.File) URL(java.net.URL) AetherBasedResolver(io.fabric8.maven.url.internal.AetherBasedResolver)

Example 80 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class AbstractProfileManagementTest method testCreateVersionFrom.

@Test
public void testCreateVersionFrom() throws Exception {
    // [FABRIC-1169] Profile version attributes leak to other versions
    // VersionState v12 = getProxy().createVersion("1.0", "1.2", Collections.singletonMap("keyA", "valA"));
    VersionState v12 = getProxy().createVersionFrom("1.0", "1.2", null);
    try {
        Assert.assertEquals("1.2", v12.getId());
        // Assert.assertEquals("valA", v12.getAttributes().get("keyA"));
        List<String> profiles = v12.getProfiles();
        Assert.assertTrue(profiles.contains("default"));
        Assert.assertTrue(profiles.contains("fabric"));
    } finally {
        getProxy().deleteVersion("1.2");
    }
}
Also used : VersionState(io.fabric8.api.mxbean.VersionState) Test(org.junit.Test)

Aggregations

Test (org.junit.jupiter.api.Test)134 Map (java.util.Map)92 Version (io.fabric8.api.Version)74 Profile (io.fabric8.api.Profile)70 IOException (java.io.IOException)67 ArrayList (java.util.ArrayList)66 File (java.io.File)64 HashMap (java.util.HashMap)64 Vertx (io.vertx.core.Vertx)58 Test (org.junit.Test)58 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)57 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)56 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)55 Checkpoint (io.vertx.junit5.Checkpoint)54 VertxExtension (io.vertx.junit5.VertxExtension)54 VertxTestContext (io.vertx.junit5.VertxTestContext)54 Pod (io.fabric8.kubernetes.api.model.Pod)52 Reconciliation (io.strimzi.operator.common.Reconciliation)50 BeforeAll (org.junit.jupiter.api.BeforeAll)50 Collections (java.util.Collections)49