Search in sources :

Example 26 with Config

use of io.fabric8.docker.client.Config in project jointware by isdream.

the class KubernetesClient method create.

@Override
public Object create(Map<String, Object> map) {
    String prefix = null;
    if (map == null || map.get(MASTER_TYPE) == null) {
        return null;
    } else if (map.get(MASTER_TYPE).equals(PROTOCOL_HTTP)) {
        prefix = PROTOCOL_HTTP + "://";
    } else {
        return null;
    }
    Config config = new ConfigBuilder().withMasterUrl(prefix + map.get(MASTER_IP) + ":" + map.get(MASTER_PORT)).build();
    return new DefaultKubernetesClient(config);
}
Also used : Config(io.fabric8.kubernetes.client.Config) ConfigBuilder(io.fabric8.kubernetes.client.ConfigBuilder) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient)

Example 27 with Config

use of io.fabric8.docker.client.Config in project kubernetes by ballerinax.

the class DockerHandler method pushImage.

/**
 * Push docker image.
 *
 * @param dockerModel DockerModel
 * @throws InterruptedException When error with docker build process
 * @throws IOException          When error with docker build process
 */
public void pushImage(DockerModel dockerModel) throws InterruptedException, IOException, KubernetesPluginException {
    AuthConfig authConfig = new AuthConfigBuilder().withUsername(dockerModel.getUsername()).withPassword(dockerModel.getPassword()).build();
    Config config = new ConfigBuilder().withDockerUrl(dockerModel.getDockerHost()).addToAuthConfigs(RegistryUtils.extractRegistry(dockerModel.getName()), authConfig).build();
    DockerClient client = new DefaultDockerClient(config);
    final DockerError dockerError = new DockerError();
    OutputHandle handle = client.image().withName(dockerModel.getName()).push().usingListener(new EventListener() {

        @Override
        public void onSuccess(String message) {
            pushDone.countDown();
        }

        @Override
        public void onError(String message) {
            pushDone.countDown();
            dockerError.setErrorMsg("error pushing docker image: " + message);
        }

        @Override
        public void onError(Throwable t) {
            pushDone.countDown();
            dockerError.setErrorMsg("error pushing docker image: " + t.getMessage());
        }

        @Override
        public void onEvent(String event) {
            printDebug(event);
        }
    }).toRegistry();
    pushDone.await();
    handle.close();
    client.close();
    handleError(dockerError);
}
Also used : AuthConfigBuilder(io.fabric8.docker.api.model.AuthConfigBuilder) DefaultDockerClient(io.fabric8.docker.client.DefaultDockerClient) DockerClient(io.fabric8.docker.client.DockerClient) Config(io.fabric8.docker.client.Config) AuthConfig(io.fabric8.docker.api.model.AuthConfig) DefaultDockerClient(io.fabric8.docker.client.DefaultDockerClient) AuthConfigBuilder(io.fabric8.docker.api.model.AuthConfigBuilder) ConfigBuilder(io.fabric8.docker.client.ConfigBuilder) OutputHandle(io.fabric8.docker.dsl.OutputHandle) AuthConfig(io.fabric8.docker.api.model.AuthConfig) EventListener(io.fabric8.docker.dsl.EventListener)

Example 28 with Config

use of io.fabric8.docker.client.Config in project fabric8 by jboss-fuse.

the class Fabric8Container method start.

@Override
public void start() throws LifecycleException {
    // lets kill any containers that are running before we start
    FabricAssertions.killJavaAndDockerProcesses();
    fabricControllerManager = createFabricControllerManager();
    Fabric8ContainerConfiguration config = configuration.get();
    config.configure(fabricControllerManager);
    try {
        FabricController fabricController = FabricAssertions.assertFabricCreate(fabricControllerManager);
        controller.set(fabricController);
    } catch (Exception e) {
        throw new LifecycleException("Failed to create fabric: " + e, e);
    }
    System.out.println("Created a controller " + controller.get());
}
Also used : LifecycleException(org.jboss.arquillian.container.spi.client.container.LifecycleException) FabricController(io.fabric8.testkit.FabricController) LifecycleException(org.jboss.arquillian.container.spi.client.container.LifecycleException) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException)

Example 29 with Config

use of io.fabric8.docker.client.Config in project fabric8 by jboss-fuse.

the class ProxyServlet method init.

/**
 * Initialize the <code>ProxyServlet</code>
 *
 * @param config The Servlet configuration passed in by the servlet container
 */
@Override
public void init(ServletConfig config) throws ServletException {
    HttpProxyRuleBase ruleBase = new HttpProxyRuleBase();
    loadRuleBase(config, ruleBase);
    resolver.setMappingRules(ruleBase);
    Protocol.registerProtocol("http", new Protocol("http", new NonBindingSocketFactory(), 80));
    Protocol.registerProtocol("https", new Protocol("https", new NonBindingSocketFactory(), 443));
}
Also used : HttpProxyRuleBase(io.fabric8.gateway.model.HttpProxyRuleBase) Protocol(org.apache.commons.httpclient.protocol.Protocol) NonBindingSocketFactory(io.fabric8.gateway.servlet.support.NonBindingSocketFactory)

Example 30 with Config

use of io.fabric8.docker.client.Config in project fabric8 by jboss-fuse.

the class Log4jLogQuery method loadCoords.

protected String loadCoords(String coords, String filePath, String classifier) throws IOException {
    String[] split = coords.split("/");
    if (split != null && split.length > 2) {
        String groupId = split[0];
        String artifactId = split[1];
        String version = split[2];
        if (resolver == null) {
            Properties defaultProperties = getDefaultProperties();
            Properties systemProperties = System.getProperties();
            if (config == null) {
                Properties combined = new Properties();
                combined.putAll(defaultProperties);
                combined.putAll(systemProperties);
                if (properties != null) {
                    combined.putAll(properties);
                }
                config = new MavenConfigurationImpl(new PropertiesPropertyResolver(combined), ServiceConstants.PID);
            }
            resolver = new AetherBasedResolver(config);
        }
        File file = resolver.resolveFile(groupId, artifactId, classifier, "jar", version);
        if (file.exists() && file.isFile()) {
            if (isRoot(filePath)) {
                return jarIndex(file);
            }
            String fileUri = file.toURI().toString();
            URL url = new URL("jar:" + fileUri + "!" + filePath);
            return loadString(url);
        }
    }
    return null;
}
Also used : MavenConfigurationImpl(io.fabric8.maven.util.MavenConfigurationImpl) PropertiesPropertyResolver(org.ops4j.util.property.PropertiesPropertyResolver) Properties(java.util.Properties) File(java.io.File) URL(java.net.URL) AetherBasedResolver(io.fabric8.maven.url.internal.AetherBasedResolver)

Aggregations

Test (org.junit.Test)128 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)44 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)43 IOException (java.io.IOException)41 HashMap (java.util.HashMap)40 File (java.io.File)31 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)28 ResourceConfig (io.fabric8.maven.core.config.ResourceConfig)28 Map (java.util.Map)28 RunImageConfiguration (io.fabric8.maven.docker.config.RunImageConfiguration)24 ArrayList (java.util.ArrayList)24 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)23 AbstractConfigHandlerTest (io.fabric8.maven.docker.config.handler.AbstractConfigHandlerTest)21 Expectations (mockit.Expectations)20 DefaultKubernetesClient (io.fabric8.kubernetes.client.DefaultKubernetesClient)19 ConfigMapBuilder (io.fabric8.kubernetes.api.model.ConfigMapBuilder)17 DeploymentConfig (io.fabric8.openshift.api.model.DeploymentConfig)16 VolumeConfig (io.fabric8.maven.core.config.VolumeConfig)15 AuthConfig (io.fabric8.maven.docker.access.AuthConfig)14 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)12