Search in sources :

Example 96 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class FabricHTTPGateway method getGatewayVersion.

/**
 * Returns the default profile version used to filter out the current versions of services
 * if no version expression is used the URI template
 */
String getGatewayVersion() {
    assertValid();
    Container currentContainer = fabricService.get().getCurrentContainer();
    if (currentContainer != null) {
        Version version = currentContainer.getVersion();
        if (version != null) {
            return version.getId();
        }
    }
    return null;
}
Also used : Container(io.fabric8.api.Container) Version(io.fabric8.api.Version)

Example 97 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class MappingConfigurationTest method addService.

protected void addService(String path, String service, String version) {
    Map<String, String> params = new HashMap<String, String>();
    params.put("version", version);
    String container = path.contains("HelloWorld") ? "soapy" : "resty";
    params.put("container", container);
    ServiceDTO serviceDetails = new ServiceDTO();
    serviceDetails.setContainer(container);
    serviceDetails.setVersion(version);
    config.updateMappingRules(false, path, Arrays.asList(service), params, serviceDetails);
}
Also used : HashMap(java.util.HashMap) ServiceDTO(io.fabric8.gateway.ServiceDTO)

Example 98 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class GitPatchManagementServiceForStandaloneChildContainersIT method validateInitialGitRepository.

private void validateInitialGitRepository() throws IOException, GitAPIException {
    pm = new GitPatchManagementServiceImpl(bundleContext);
    pm.start();
    pm.ensurePatchManagementInitialized();
    GitPatchRepository repository = ((GitPatchManagementServiceImpl) pm).getGitPatchRepository();
    verify(bsl, atLeastOnce()).setStartLevel(2);
    Git fork = repository.cloneRepository(repository.findOrCreateMainGitRepository(), true);
    List<Ref> tags = fork.tagList().call();
    boolean found1 = false;
    boolean found2 = false;
    for (Ref tag : tags) {
        if ("refs/tags/baseline-6.2.0".equals(tag.getName())) {
            found1 = true;
        }
        if ("refs/tags/baseline-child-2.4.0.redhat-620133".equals(tag.getName())) {
            found2 = true;
        }
    }
    assertTrue("Repository should contain baseline tags for version 6.2.0 (both for root and admin:create based child containrs)", found1 && found2);
    repository.closeRepository(fork, true);
}
Also used : Ref(org.eclipse.jgit.lib.Ref) GitPatchManagementServiceImpl(io.fabric8.patch.management.impl.GitPatchManagementServiceImpl) Git(org.eclipse.jgit.api.Git) GitPatchRepository(io.fabric8.patch.management.impl.GitPatchRepository)

Example 99 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class GitPatchManagementServiceIT method installPPatchHotFixPPatchAndThenRPatch.

/**
 * Installation of R patch <strong>may</strong> leave P patches installed when they provide <strong>only</strong>
 * bundles and the bundles are at higher version
 * @throws IOException
 * @throws GitAPIException
 */
@Test
public void installPPatchHotFixPPatchAndThenRPatch() throws IOException, GitAPIException {
    initializationPerformedBaselineDistributionFoundInSystem();
    // prepare some ZIP patches
    preparePatchZip("src/test/resources/content/patch1", "target/karaf/patches/source/patch-1.zip", false);
    preparePatchZip("src/test/resources/content/patch2", "target/karaf/patches/source/patch-2.zip", false);
    preparePatchZip("src/test/resources/content/patch4", "target/karaf/patches/source/patch-4.zip", false);
    GitPatchRepository repository = ((GitPatchManagementServiceImpl) pm).getGitPatchRepository();
    PatchManagement service = (PatchManagement) pm;
    PatchData patchData1 = service.fetchPatches(new File("target/karaf/patches/source/patch-1.zip").toURI().toURL()).get(0);
    Patch patch1 = service.trackPatch(patchData1);
    PatchData patchData2 = service.fetchPatches(new File("target/karaf/patches/source/patch-2.zip").toURI().toURL()).get(0);
    Patch patch2 = service.trackPatch(patchData2);
    PatchData patchData4 = service.fetchPatches(new File("target/karaf/patches/source/patch-4.zip").toURI().toURL()).get(0);
    Patch patch4 = service.trackPatch(patchData4);
    String tx = service.beginInstallation(PatchKind.NON_ROLLUP);
    service.install(tx, patch1, null);
    service.commitInstallation(tx);
    tx = service.beginInstallation(PatchKind.NON_ROLLUP);
    service.install(tx, patch2, null);
    service.commitInstallation(tx);
    assertTrue("There should be etc/overrides.properties after installing non-rollup patches", new File(karafHome, "etc/overrides.properties").exists());
    // overrides.properties as after installing P patches with new mechanism
    String etcOverridesProperties = FileUtils.readFileToString(new File(karafHome, "etc/overrides.properties"));
    assertThat(etcOverridesProperties, equalTo("mvn:io.fabric8/fabric-tranquility/1.2.5\n"));
    Git fork = repository.cloneRepository(repository.findOrCreateMainGitRepository(), true);
    assertTrue(repository.containsTag(fork, "patch-my-patch-1"));
    assertTrue(repository.containsTag(fork, "patch-my-patch-2"));
    assertFalse(repository.containsTag(fork, "baseline-6.2.0.redhat-002"));
    repository.closeRepository(fork, true);
    tx = service.beginInstallation(PatchKind.ROLLUP);
    service.install(tx, patch4, null);
    service.commitInstallation(tx);
    fork = repository.cloneRepository(repository.findOrCreateMainGitRepository(), true);
    assertFalse(repository.containsTag(fork, "patch-my-patch-1"));
    assertFalse(repository.containsTag(fork, "patch-my-patch-2"));
    assertTrue(repository.containsTag(fork, "baseline-6.2.0.redhat-002"));
    assertTrue("There still should be etc/overrides.properties after installing rollup patch", new File(karafHome, "etc/overrides.properties").exists());
    // overrides.properties as after installing R patch with new mechanism
    etcOverridesProperties = FileUtils.readFileToString(new File(karafHome, "etc/overrides.properties"));
    assertThat(etcOverridesProperties, equalTo("mvn:io.fabric8/fabric-tranquility/1.2.5\n"));
    repository.closeRepository(fork, true);
}
Also used : GitPatchManagementServiceImpl(io.fabric8.patch.management.impl.GitPatchManagementServiceImpl) Git(org.eclipse.jgit.api.Git) GitPatchRepository(io.fabric8.patch.management.impl.GitPatchRepository) File(java.io.File) Test(org.junit.Test)

Example 100 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class GitPatchManagementServiceIT method addPatch1.

/**
 * Patch 1 is non-rollup patch
 * @throws IOException
 * @throws GitAPIException
 */
@Test
public void addPatch1() throws IOException, GitAPIException {
    initializationPerformedBaselineDistributionFoundInSystem();
    // prepare some ZIP patches
    preparePatchZip("src/test/resources/content/patch1", "target/karaf/patches/source/patch-1.zip", false);
    PatchManagement service = (PatchManagement) pm;
    PatchData patchData = service.fetchPatches(new File("target/karaf/patches/source/patch-1.zip").toURI().toURL()).get(0);
    assertThat(patchData.getId(), equalTo("my-patch-1"));
    Patch patch = service.trackPatch(patchData);
    GitPatchRepository repository = ((GitPatchManagementServiceImpl) pm).getGitPatchRepository();
    Git fork = repository.cloneRepository(repository.findOrCreateMainGitRepository(), true);
    // we should see remote branch for the patch, but without checking it out, it won't be available in the clone's local branches
    List<Ref> branches = fork.branchList().setListMode(ListBranchCommand.ListMode.REMOTE).call();
    Ref patchBranch = null;
    for (Ref remoteBranch : branches) {
        if (String.format("refs/remotes/origin/patch-%s", patchData.getId()).equals(remoteBranch.getName())) {
            patchBranch = remoteBranch;
            break;
        }
    }
    assertNotNull("Should find remote branch for the added patch", patchBranch);
    assertThat(patch.getManagedPatch().getCommitId(), equalTo(patchBranch.getObjectId().getName()));
    RevCommit patchCommit = new RevWalk(fork.getRepository()).parseCommit(patchBranch.getObjectId());
    // patch commit should be child of baseline commit
    RevCommit baselineCommit = new RevWalk(fork.getRepository()).parseCommit(patchCommit.getParent(0));
    // this baseline commit should be tagged "baseline-VERSION"
    Ref tag = fork.tagList().call().get(0);
    assertThat(tag.getName(), equalTo("refs/tags/baseline-6.2.0"));
    RevCommit baselineCommitFromTag = new RevWalk(fork.getRepository()).parseCommit(tag.getTarget().getObjectId());
    assertThat(baselineCommit.getId(), equalTo(baselineCommitFromTag.getId()));
    // let's see the patch applied to baseline-6.2.0
    fork.checkout().setName("my-patch-1").setStartPoint("origin/patch-my-patch-1").setCreateBranch(true).call();
    String myProperties = FileUtils.readFileToString(new File(fork.getRepository().getWorkTree(), "etc/my.properties"));
    assertTrue(myProperties.contains("p1 = v1"));
    repository.closeRepository(fork, true);
}
Also used : Ref(org.eclipse.jgit.lib.Ref) GitPatchManagementServiceImpl(io.fabric8.patch.management.impl.GitPatchManagementServiceImpl) Git(org.eclipse.jgit.api.Git) GitPatchRepository(io.fabric8.patch.management.impl.GitPatchRepository) RevWalk(org.eclipse.jgit.revwalk.RevWalk) File(java.io.File) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Aggregations

Version (io.fabric8.api.Version)74 Profile (io.fabric8.api.Profile)70 File (java.io.File)52 Test (org.junit.Test)46 IOException (java.io.IOException)41 ArrayList (java.util.ArrayList)36 Container (io.fabric8.api.Container)35 HashMap (java.util.HashMap)34 ProfileService (io.fabric8.api.ProfileService)27 Map (java.util.Map)25 Git (org.eclipse.jgit.api.Git)22 FabricService (io.fabric8.api.FabricService)21 Version (org.osgi.framework.Version)21 ProfileBuilder (io.fabric8.api.ProfileBuilder)18 GitVersion (io.fabric8.api.commands.GitVersion)18 PatchException (io.fabric8.patch.management.PatchException)15 HashSet (java.util.HashSet)15 TreeMap (java.util.TreeMap)14 LinkedList (java.util.LinkedList)13 GitPatchRepository (io.fabric8.patch.management.impl.GitPatchRepository)12