use of io.fabric8.patch.management.Patch in project fabric8 by jboss-fuse.
the class PatchApplyAction method doExecute.
@Override
protected Object doExecute() throws Exception {
List<Version> versions;
ProfileService profileService = fabricService.adapt(ProfileService.class);
if (versionId != null && !versionId.isEmpty()) {
Version version = profileService.getRequiredVersion(versionId);
versions = Collections.singletonList(version);
} else if (allVersions) {
versions = new ArrayList<>();
for (String versionId : profileService.getVersions()) {
versions.add(profileService.getRequiredVersion(versionId));
}
} else {
versions = Collections.singletonList(fabricService.getRequiredDefaultVersion());
}
username = username != null && !username.isEmpty() ? username : ShellUtils.retrieveFabricUser(session);
password = password != null ? password : ShellUtils.retrieveFabricUserPassword(session);
promptForJmxCredentialsIfNeeded();
for (Version version : versions) {
fabricService.getPatchService().applyPatch(version, patch, username, password);
}
return null;
}
use of io.fabric8.patch.management.Patch in project fabric8 by jboss-fuse.
the class DummyBatchingProgressMonitor method doPullInternal.
private PullPolicyResult doPullInternal(GitContext context, CredentialsProvider credentialsProvider, boolean allowVersionDelete, boolean allowPush, int forcedTimeoutInSeconds) {
PullPolicyResult pullResult = pullPushPolicy.doPull(context, credentialsProvider, allowVersionDelete, allowPush, forcedTimeoutInSeconds);
if (pullResult.getLastException() == null) {
Map<String, PullPushPolicy.BranchChange> updatedVersions = pullResult.localUpdateVersions();
if (!updatedVersions.isEmpty()) {
if (updatedVersions.containsKey(GitHelpers.MASTER_BRANCH)) {
versionCache.invalidateAll();
} else {
for (String version : updatedVersions.keySet()) {
versionCache.invalidate(version);
}
}
notificationRequired = true;
}
Set<String> pullVersions = pullResult.getVersions();
if (!pullVersions.isEmpty() && !pullVersions.equals(versions)) {
versions.clear();
for (String v : pullVersions) {
if (!v.startsWith("patches-") && !v.startsWith("patch-") && !v.equals(HISTORY_BRANCH) && !v.equals(ADMIN_HISTORY_BRANCH)) {
versions.add(v);
}
}
}
if (pullResult.remoteUpdateRequired()) {
doPushInternal(context, credentialsProvider);
}
}
return pullResult;
}
use of io.fabric8.patch.management.Patch in project fabric8 by jboss-fuse.
the class PatchServiceImplTest method testCheckRequirementsSatisfied.
@Test
public void testCheckRequirementsSatisfied() throws IOException {
PatchServiceImpl.PatchDescriptor descriptor = getPatchDescriptor("test3.patch");
Version version = buildVersion("1.1").withProfiles("karaf", "default", "patch-prereq3", "patch-somethingelse").done();
// this should not throw a RuntimeException
PatchServiceImpl.checkRequirements(version, descriptor);
}
use of io.fabric8.patch.management.Patch in project fabric8 by jboss-fuse.
the class PatchServiceImplTest method testCheckRequirementsMultiplePatches.
@Test
public void testCheckRequirementsMultiplePatches() throws IOException {
Collection<PatchServiceImpl.PatchDescriptor> patches = new LinkedList<PatchServiceImpl.PatchDescriptor>();
patches.add(getPatchDescriptor("test3.patch"));
patches.add(getPatchDescriptor("test4.patch"));
Version version = buildVersion("1.1").withProfiles("karaf", "default", "patch-prereq4a", "patch-prereq3").done();
try {
PatchServiceImpl.checkRequirements(version, patches);
fail("Patch should not have passed requirements check - required patch is missing");
} catch (PatchException e) {
assertTrue(e.getMessage().toLowerCase().contains("required patch 'prereq4b' is missing"));
}
}
use of io.fabric8.patch.management.Patch in project fabric8 by jboss-fuse.
the class PatchServiceImplTest method testGetPatchProfile.
@Test
public void testGetPatchProfile() throws IOException {
PatchServiceImpl.PatchDescriptor test1 = getPatchDescriptor("test1.patch");
PatchServiceImpl.PatchDescriptor test3 = getPatchDescriptor("test3.patch");
Version version = buildVersion("1.1").withProfiles("karaf", "default", "patch-test3").done();
Profile profile = PatchServiceImpl.getPatchProfile(version, test3);
assertNotNull("test3 patch profile should be found", profile);
assertEquals("patch-test3", profile.getId());
assertNull("test1 patch profile should not be found", PatchServiceImpl.getPatchProfile(version, test1));
}
Aggregations