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);
}
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);
}
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());
}
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));
}
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;
}
Aggregations