Search in sources :

Example 31 with Version

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();
    }
}
Also used : LockHandle(io.fabric8.api.LockHandle) Git(org.eclipse.jgit.api.Git) GitContext(io.fabric8.api.GitContext) GitVersion(io.fabric8.api.commands.GitVersion) Version(io.fabric8.api.Version)

Example 32 with Version

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;
}
Also used : PullPolicyResult(io.fabric8.git.PullPushPolicy.PullPolicyResult)

Example 33 with Version

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();
    }
}
Also used : LockHandle(io.fabric8.api.LockHandle) Git(org.eclipse.jgit.api.Git) GitContext(io.fabric8.api.GitContext)

Example 34 with Version

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);
}
Also used : DefaultPullPushPolicy(io.fabric8.git.internal.DefaultPullPushPolicy) File(java.io.File) Before(org.junit.Before)

Example 35 with Version

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));
}
Also used : Container(io.fabric8.api.Container) ProfileService(io.fabric8.api.ProfileService) Version(io.fabric8.api.Version) Profile(io.fabric8.api.Profile)

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