Search in sources :

Example 11 with Context

use of io.fabric8.mockwebserver.Context 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 12 with Context

use of io.fabric8.mockwebserver.Context in project fabric8 by jboss-fuse.

the class FabricGitFacade method write.

@Override
public CommitInfo write(final String branch, final String path, final String commitMessage, final String authorName, final String authorEmail, final String contents) {
    assertValid();
    final PersonIdent personIdent = new PersonIdent(authorName, authorEmail);
    return gitWriteOperation(personIdent, new GitOperation<CommitInfo>() {

        public CommitInfo call(Git git, GitContext context) throws Exception {
            checkoutBranch(git, branch);
            File rootDir = getRootGitDirectory(git);
            byte[] data = contents.getBytes();
            CommitInfo answer = doWrite(git, rootDir, branch, path, data, personIdent, commitMessage);
            context.commitMessage(commitMessage);
            return answer;
        }
    });
}
Also used : Git(org.eclipse.jgit.api.Git) PersonIdent(org.eclipse.jgit.lib.PersonIdent) GitContext(io.fabric8.api.GitContext) File(java.io.File) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) IOException(java.io.IOException)

Example 13 with Context

use of io.fabric8.mockwebserver.Context in project fabric8 by jboss-fuse.

the class FabricGitFacade method revertTo.

@Override
public void revertTo(final String branch, final String objectId, final String blobPath, final String commitMessage, final String authorName, final String authorEmail) {
    assertValid();
    final PersonIdent personIdent = new PersonIdent(authorName, authorEmail);
    gitWriteOperation(personIdent, new GitOperation<Void>() {

        public Void call(Git git, GitContext context) throws Exception {
            checkoutBranch(git, branch);
            File rootDir = getRootGitDirectory(git);
            Void answer = doRevert(git, rootDir, branch, objectId, blobPath, commitMessage, personIdent);
            context.commitMessage(commitMessage);
            return answer;
        }
    });
}
Also used : Git(org.eclipse.jgit.api.Git) PersonIdent(org.eclipse.jgit.lib.PersonIdent) GitContext(io.fabric8.api.GitContext) File(java.io.File) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) IOException(java.io.IOException)

Example 14 with Context

use of io.fabric8.mockwebserver.Context in project fabric8 by jboss-fuse.

the class FabricGitFacade method writeBase64.

@Override
public CommitInfo writeBase64(final String branch, final String path, final String commitMessage, final String authorName, final String authorEmail, final String contents) {
    assertValid();
    final PersonIdent personIdent = new PersonIdent(authorName, authorEmail);
    return gitWriteOperation(personIdent, new GitOperation<CommitInfo>() {

        public CommitInfo call(Git git, GitContext context) throws Exception {
            checkoutBranch(git, branch);
            File rootDir = getRootGitDirectory(git);
            byte[] data = Base64.decode(contents);
            CommitInfo answer = doWrite(git, rootDir, branch, path, data, personIdent, commitMessage);
            context.commitMessage(commitMessage);
            return answer;
        }
    });
}
Also used : Git(org.eclipse.jgit.api.Git) PersonIdent(org.eclipse.jgit.lib.PersonIdent) GitContext(io.fabric8.api.GitContext) File(java.io.File) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) IOException(java.io.IOException)

Example 15 with Context

use of io.fabric8.mockwebserver.Context in project fabric8 by jboss-fuse.

the class FeatureConfigInstaller method restoreConfigAdminIfNeeded.

public void restoreConfigAdminIfNeeded() {
    // we'll be doing confiadmin checks, so configadmin bundle has to be started and has its services registered
    Bundle b = null;
    try {
        b = new BundleUtils(context).findBundle("org.apache.felix.configadmin");
        if (b.getState() != Bundle.ACTIVE) {
            b.start();
            ServiceReference<ConfigurationAdmin> ref = context.getServiceReference(ConfigurationAdmin.class);
            if (ref != null) {
                configAdmin = context.getService(ref);
            }
        }
    } catch (BundleException e) {
        configAdmin = null;
        LOGGER.warn(e.getMessage());
    }
}
Also used : Bundle(org.osgi.framework.Bundle) BundleException(org.osgi.framework.BundleException) BundleUtils(io.fabric8.utils.BundleUtils) ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin)

Aggregations

Test (org.junit.jupiter.api.Test)593 Checkpoint (io.vertx.junit5.Checkpoint)574 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)543 VertxTestContext (io.vertx.junit5.VertxTestContext)542 Vertx (io.vertx.core.Vertx)539 Reconciliation (io.strimzi.operator.common.Reconciliation)532 VertxExtension (io.vertx.junit5.VertxExtension)514 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)514 BeforeAll (org.junit.jupiter.api.BeforeAll)466 AfterAll (org.junit.jupiter.api.AfterAll)462 CoreMatchers.is (org.hamcrest.CoreMatchers.is)458 Future (io.vertx.core.Future)429 Mockito.when (org.mockito.Mockito.when)410 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)379 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)368 PlatformFeaturesAvailability (io.strimzi.operator.PlatformFeaturesAvailability)360 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)356 ResourceOperatorSupplier (io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier)352 List (java.util.List)352 KubernetesVersion (io.strimzi.operator.KubernetesVersion)344