Search in sources :

Example 31 with Logger

use of io.fabric8.maven.docker.util.Logger in project fabric8 by fabric8io.

the class SessionListener method loadDependency.

public void loadDependency(Logger log, List<KubernetesList> kubeConfigs, String dependency, Controller controller, Configuration configuration, String namespace) throws Exception {
    // lets test if the dependency is a local string
    String baseDir = System.getProperty("basedir", ".");
    String path = baseDir + "/" + dependency;
    File file = new File(path);
    if (file.exists()) {
        loadDependency(log, kubeConfigs, file, controller, configuration, log, namespace);
    } else {
        String text = readAsString(createURL(dependency));
        Object resources;
        if (text.trim().startsWith("---") || dependency.endsWith(".yml") || dependency.endsWith(".yaml")) {
            resources = loadYaml(text);
        } else {
            resources = loadJson(text);
        }
        addConfig(kubeConfigs, resources, controller, configuration, log, namespace, dependency);
    }
}
Also used : Util.readAsString(io.fabric8.arquillian.utils.Util.readAsString) File(java.io.File)

Example 32 with Logger

use of io.fabric8.maven.docker.util.Logger in project fabric8 by fabric8io.

the class SuiteListener method start.

public void start(@Observes(precedence = 100) BeforeSuite event, Configuration configuration, Logger logger) {
    session = new Session(configuration.getSessionId(), configuration.getNamespace(), logger);
    session.init();
    sessionProducer.set(session);
    controlEvent.fire(new Start(session));
}
Also used : Start(io.fabric8.arquillian.kubernetes.event.Start)

Example 33 with Logger

use of io.fabric8.maven.docker.util.Logger in project fabric8 by fabric8io.

the class SuiteListener method stop.

public void stop(@Observes(precedence = -100) AfterSuite event, Logger logger) {
    controlEvent.fire(new Stop(session));
    session.destroy();
}
Also used : Stop(io.fabric8.arquillian.kubernetes.event.Stop)

Example 34 with Logger

use of io.fabric8.maven.docker.util.Logger in project fabric8 by fabric8io.

the class WebHooks method createGogsWebhook.

/**
 * Creates a webook in the given gogs repo for the user and password if the webhook does not already exist
 */
public static boolean createGogsWebhook(GitRepoClient repoClient, Logger log, String gogsUser, String repoName, String webhookUrl, String webhookSecret) throws JsonProcessingException {
    if (repoClient == null) {
        log.info("Cannot create Gogs webhooks as no Gogs service could be found or created");
        return false;
    }
    String gogsAddress = repoClient.getAddress();
    log.info("Querying webhooks in gogs at address: " + gogsAddress + " for user " + gogsUser + " repoName: " + repoName);
    RepositoryDTO repository = repoClient.getRepository(gogsUser, repoName);
    if (repository == null) {
        log.info("No repository found for user: " + gogsUser + " repo: " + repoName + " so cannot create any web hooks");
    // return false;
    }
    List<WebHookDTO> webhooks = repoClient.getWebhooks(gogsUser, repoName);
    for (WebHookDTO webhook : webhooks) {
        String url = null;
        WebhookConfig config = webhook.getConfig();
        if (config != null) {
            url = config.getUrl();
            if (Objects.equal(webhookUrl, url)) {
                log.info("Already has webhook for: " + url + " so not creating again");
                return false;
            }
            log.info("Ignoring webhook " + url + " from: " + toJson(config));
        }
    }
    CreateWebhookDTO createWebhook = new CreateWebhookDTO();
    createWebhook.setType("gogs");
    WebhookConfig config = createWebhook.getConfig();
    config.setUrl(webhookUrl);
    config.setSecret(webhookSecret);
    WebHookDTO webhook = repoClient.createWebhook(gogsUser, repoName, createWebhook);
    if (log.isDebugEnabled()) {
        log.debug("Got created web hook: " + toJson(webhook));
    }
    log.info("Created webhook for " + webhookUrl + " for user: " + gogsUser + " repoName: " + repoName + " on gogs URL: " + gogsAddress);
    return true;
}
Also used : WebhookConfig(io.fabric8.repo.git.WebhookConfig) WebHookDTO(io.fabric8.repo.git.WebHookDTO) RepositoryDTO(io.fabric8.repo.git.RepositoryDTO) CreateWebhookDTO(io.fabric8.repo.git.CreateWebhookDTO)

Example 35 with Logger

use of io.fabric8.maven.docker.util.Logger in project docker-maven-plugin by fabric8io.

the class LogMatchCallbackTest method matchingSingleLineSucceeds.

@Test(expected = LogCallback.DoneException.class)
public void matchingSingleLineSucceeds() throws Exception {
    final String patternString = "The start has finished right now";
    final LogMatchCallback logMatchCallback = new LogMatchCallback(logger, callback, patternString);
    new Expectations() {

        {
            callback.matched();
            times = 1;
        }
    };
    logMatchCallback.log(1, new Timestamp(), patternString);
}
Also used : Expectations(mockit.Expectations) Timestamp(io.fabric8.maven.docker.util.Timestamp) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)30 File (java.io.File)11 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)10 IOException (java.io.IOException)9 ArrayList (java.util.ArrayList)9 URL (java.net.URL)8 GeneratorContext (io.fabric8.maven.generator.api.GeneratorContext)7 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)6 ResourceValidator (io.fabric8.maven.core.util.validator.ResourceValidator)6 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)6 Logger (io.fabric8.maven.docker.util.Logger)6 Util.readAsString (io.fabric8.arquillian.utils.Util.readAsString)5 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)5 Pod (io.fabric8.kubernetes.api.model.Pod)5 OpenShiftMockServer (io.fabric8.openshift.client.server.mock.OpenShiftMockServer)5 Expectations (mockit.Expectations)5 Logger (io.fabric8.arquillian.kubernetes.log.Logger)4 Deployment (io.fabric8.kubernetes.api.model.extensions.Deployment)4 BuildService (io.fabric8.maven.core.service.BuildService)4 Fabric8ServiceException (io.fabric8.maven.core.service.Fabric8ServiceException)4