use of io.fabric8.api.Version in project fabric8 by jboss-fuse.
the class DummyBatchingProgressMonitor method createProfile.
@Override
public String createProfile(GitContext context, final Profile profile) {
IllegalStateAssertion.assertNotNull(profile, "profile");
LockHandle writeLock = aquireWriteLock();
try {
assertValid();
GitOperation<String> gitop = new GitOperation<String>() {
public String call(Git git, GitContext context) throws Exception {
String versionId = profile.getVersion();
String profileId = profile.getId();
Version version = getRequiredVersion(versionId);
IllegalStateAssertion.assertFalse(version.hasProfile(profileId), "Profile already exists: " + profileId);
checkoutRequiredProfileBranch(git, context, versionId, profileId);
return createOrUpdateProfile(context, null, profile, new HashSet<String>());
}
};
return executeInternal(context, null, gitop);
} finally {
writeLock.unlock();
}
}
use of io.fabric8.api.Version 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.api.Version in project fabric8 by jboss-fuse.
the class DummyBatchingProgressMonitor method getVersionIds.
@Override
public List<String> getVersionIds(GitContext context) {
LockHandle readLock = aquireReadLock();
try {
assertValid();
GitOperation<List<String>> gitop = new GitOperation<List<String>>() {
public List<String> call(Git git, GitContext context) throws Exception {
List<String> result = new ArrayList<>(versions);
// we do not want to expose master branch as a version
if (result.contains(GitHelpers.MASTER_BRANCH)) {
result.remove(GitHelpers.MASTER_BRANCH);
}
Collections.sort(result, VersionSequence.getComparator());
return Collections.unmodifiableList(result);
}
};
return executeInternal(context, null, gitop);
} finally {
readLock.unlock();
}
}
use of io.fabric8.api.Version in project fabric8 by jboss-fuse.
the class PushPullPolicyIT method initLocalGitRepositoryAndPushToServletRepository.
@Before
public void initLocalGitRepositoryAndPushToServletRepository() throws Exception {
dirLocal = new File("target/data-local");
dirServlet = new File("target/data-servlet");
FileUtils.deleteDirectory(dirLocal);
FileUtils.deleteDirectory(dirServlet);
local = Git.init().setDirectory(dirLocal).setGitDir(new File(dirLocal, ".git")).call();
servlet = Git.init().setDirectory(dirServlet).setBare(true).call();
// local -> servlet
local.getRepository().getConfig().setString("remote", "origin", "url", dirServlet.getCanonicalPath());
local.getRepository().getConfig().setString("remote", "origin", "fetch", "+refs/heads/*:refs/remotes/origin/*");
local.getRepository().getConfig().save();
// master branch - ensemble profiles
prepareMasterBranch();
// version 1.0 - created by importing initial profiles
prepare10Branch();
prepareBranch("1.0.1", "1.0", 3);
prepareBranch("1.1", "1.0", 4);
prepareBranch("1.2", "1.1", 2);
local.push().setRemote("origin").setPushAll().setPushTags().call();
policy = new DefaultPullPushPolicy(local, "origin", 42);
}
use of io.fabric8.api.Version in project fabric8 by jboss-fuse.
the class FabricFeaturesServiceImpl method getAllProfilesOverlay.
/**
* Creates an aggregation of all available {@link Profile}s.
*/
private Profile getAllProfilesOverlay() {
Container container = fabricService.get().getCurrentContainer();
ProfileService profileService = fabricService.get().adapt(ProfileService.class);
Version version = container.getVersion();
Profile versionProfile = getVersionProfile(version);
return Profiles.getEffectiveProfile(fabricService.get(), profileService.getOverlayProfile(versionProfile));
}
Aggregations