Search in sources :

Example 11 with Context

use of io.fabric8.kubernetes.api.model.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.kubernetes.api.model.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.kubernetes.api.model.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.kubernetes.api.model.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.kubernetes.api.model.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.Test)135 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)58 Async (io.vertx.ext.unit.Async)52 Expectations (mockit.Expectations)34 Probe (io.fabric8.kubernetes.api.model.Probe)33 Reconciliation (io.strimzi.controller.cluster.Reconciliation)24 File (java.io.File)23 Git (org.eclipse.jgit.api.Git)23 GitContext (io.fabric8.api.GitContext)21 IOException (java.io.IOException)21 ConfigMapOperator (io.strimzi.controller.cluster.operator.resource.ConfigMapOperator)20 ServiceOperator (io.strimzi.controller.cluster.operator.resource.ServiceOperator)20 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)18 HashMap (java.util.HashMap)17 LockHandle (io.fabric8.api.LockHandle)15 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)15 NonNamespaceOperation (io.fabric8.kubernetes.client.dsl.NonNamespaceOperation)15 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)15 MixedOperation (io.fabric8.kubernetes.client.dsl.MixedOperation)14 Resource (io.fabric8.kubernetes.client.dsl.Resource)14