use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8 by jboss-fuse.
the class ContainerUpgradeAndRollbackTest method deployment.
@Deployment
@StartLevelAware(autostart = true)
public static Archive<?> deployment() {
final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "container-upgrade-rollback-test.jar");
archive.addPackage(CommandSupport.class.getPackage());
archive.setManifest(new Asset() {
@Override
public InputStream openStream() {
OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
builder.addBundleManifestVersion(2);
builder.addBundleSymbolicName(archive.getName());
builder.addBundleVersion("1.0.0");
builder.addImportPackages(ServiceLocator.class, FabricService.class);
builder.addImportPackages("io.fabric8.git");
builder.addImportPackages(AbstractCommand.class, Action.class);
builder.addImportPackage("org.apache.felix.service.command;status=provisional");
builder.addImportPackages(ConfigurationAdmin.class, ServiceTracker.class, Logger.class);
return builder.openStream();
}
});
return archive;
}
use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8 by jboss-fuse.
the class FabricDiscoveryAgent method call.
@Override
public Object call() throws Exception {
LOG.info("Using local ZKClient");
managedZkClient = true;
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder().connectString(System.getProperty("zookeeper.url", "localhost:2181")).retryPolicy(new RetryOneTime(1000)).connectionTimeoutMs(10000);
String password = System.getProperty("zookeeper.password", "admin");
if (password != null && !password.isEmpty()) {
builder.aclProvider(new CuratorACLManager());
builder.authorization("digest", ("fabric:" + password).getBytes());
}
CuratorFramework client = builder.build();
client.start();
client.getZookeeperClient().blockUntilConnectedOrTimedOut();
return client;
}
use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8 by jboss-fuse.
the class KubernetesModelProcessorProcessor method process.
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
CompilationTaskFactory compilationTaskFactory = new CompilationTaskFactory(processingEnv);
Set<TypeElement> processors = new HashSet<>();
// 1st pass collect classes to compile.
for (Element element : roundEnv.getElementsAnnotatedWith(KubernetesModelProcessor.class)) {
processors.add(getClassElement(element));
}
if (processors.isEmpty()) {
return true;
}
StringWriter writer = new StringWriter();
try {
Callable<Boolean> compileTask = compilationTaskFactory.create(processors, writer);
if (!compileTask.call()) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Failed to compile provider classes. See output below.");
printCompileErrors(compilationTaskFactory);
return false;
}
} catch (Exception e) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Error to compile provider classes, due to: " + e.getMessage() + ". See output below.");
return false;
} finally {
String output = writer.toString();
if (Strings.isNullOrBlank(output)) {
output = "success";
}
processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Fabric8 model generator compiler output:" + output);
}
// 2nd pass generate json.
for (Element element : roundEnv.getElementsAnnotatedWith(KubernetesModelProcessor.class)) {
KubernetesModelProcessor annotation = element.getAnnotation(KubernetesModelProcessor.class);
String kubernetesJsonFileName = annotation.value();
KubernetesResource json = readJson(kubernetesJsonFileName);
Builder<? extends KubernetesResource> builder;
if (json instanceof KubernetesList) {
builder = new KubernetesListBuilder((KubernetesList) json);
} else if (json instanceof Template) {
builder = new TemplateBuilder((Template) json);
} else if (json != null) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Unknown Kubernetes json type:" + json.getClass());
return false;
} else {
return false;
}
try {
if (element instanceof TypeElement) {
for (ExecutableElement methodElement : ElementFilter.methodsIn(element.getEnclosedElements())) {
TypeElement classElement = getClassElement(element);
Class<?> cls = Class.forName(classElement.getQualifiedName().toString());
final Object instance = cls.newInstance();
final String methodName = methodElement.getSimpleName().toString();
if (builder instanceof Visitable) {
((Visitable) builder).accept(new Visitor() {
@Override
public void visit(Object o) {
for (Method m : findMethods(instance, methodName, o.getClass())) {
Named named = m.getAnnotation(Named.class);
if (named != null && !Strings.isNullOrBlank(named.value())) {
String objectName = getName(o);
// If a name has been explicitly specified check if there is a match
if (!named.value().equals(objectName)) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING, "Named method:" + m.getName() + " with name:" + named.value() + " doesn't match: " + objectName + ", ignoring");
return;
}
}
try {
m.invoke(instance, o);
} catch (IllegalAccessException e) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Error invoking visitor method:" + m.getName() + " on:" + instance + "with argument:" + o);
} catch (InvocationTargetException e) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Error invoking visitor method:" + m.getName() + " on:" + instance + "with argument:" + o);
}
}
}
});
} else {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Json type is not visitable.");
}
}
}
json = builder.build();
generateJson(kubernetesJsonFileName, json);
} catch (Exception ex) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Error creating Kubernetes configuration:" + ex.getMessage());
}
}
return true;
}
use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project kie-wb-common by kiegroup.
the class OpenShiftAccessInterfaceImpl method buildOpenShiftConfig.
// package-protected for junit testing purposes (from inside the package)
static OpenShiftConfig buildOpenShiftConfig(OpenShiftProviderConfig config) {
OpenShiftConfigBuilder builder = new OpenShiftConfigBuilder(OpenShiftConfig.wrap(Config.autoConfigure(null)));
/*
* Kubernetes configuration properties; see io.fabric8.kubernetes.client.Config
*/
String allProxy = trimToNull(config.getAllProxy());
if (allProxy != null) {
builder = builder.withHttpProxy(allProxy);
builder = builder.withHttpsProxy(allProxy);
}
String httpProxy = trimToNull(config.getHttpProxy());
if (httpProxy != null) {
// NOTE: overrides allProxy above
builder = builder.withHttpProxy(httpProxy);
}
String httpsProxy = trimToNull(config.getHttpsProxy());
if (httpsProxy != null) {
// NOTE: overrides allProxy above
builder = builder.withHttpsProxy(httpsProxy);
}
String kubernetesApiVersion = trimToNull(config.getKubernetesApiVersion());
if (kubernetesApiVersion != null) {
builder = builder.withApiVersion(kubernetesApiVersion);
}
String kubernetesAuthBasicPassword = trimToNull(config.getKubernetesAuthBasicPassword());
if (kubernetesAuthBasicPassword != null) {
builder = builder.withPassword(kubernetesAuthBasicPassword);
}
String kubernetesAuthBasicUsername = trimToNull(config.getKubernetesAuthBasicUsername());
if (kubernetesAuthBasicUsername != null) {
builder = builder.withUsername(kubernetesAuthBasicUsername);
}
String kubernetesAuthToken = trimToNull(config.getKubernetesAuthToken());
if (kubernetesAuthToken != null) {
builder = builder.withOauthToken(kubernetesAuthToken);
}
String kubernetesCertsCaData = trimToNull(config.getKubernetesCertsCaData());
if (kubernetesCertsCaData != null) {
builder = builder.withCaCertData(kubernetesCertsCaData);
}
String kubernetesCertsCaFile = trimToNull(config.getKubernetesCertsCaFile());
if (kubernetesCertsCaFile != null) {
builder = builder.withCaCertFile(kubernetesCertsCaFile);
}
String kubernetesCertsClientData = trimToNull(config.getKubernetesCertsClientData());
if (kubernetesCertsClientData != null) {
builder = builder.withClientCertData(kubernetesCertsClientData);
}
String kubernetesCertsClientFile = trimToNull(config.getKubernetesCertsClientFile());
if (kubernetesCertsClientFile != null) {
builder = builder.withClientCertFile(kubernetesCertsClientFile);
}
String kubernetesCertsClientKeyAlgo = trimToNull(config.getKubernetesCertsClientKeyAlgo());
if (kubernetesCertsClientKeyAlgo != null) {
builder = builder.withClientKeyAlgo(kubernetesCertsClientKeyAlgo);
}
String kubernetesCertsClientKeyData = trimToNull(config.getKubernetesCertsClientKeyData());
if (kubernetesCertsClientKeyData != null) {
builder = builder.withClientKeyData(kubernetesCertsClientKeyData);
}
String kubernetesCertsClientKeyFile = trimToNull(config.getKubernetesCertsClientKeyFile());
if (kubernetesCertsClientKeyFile != null) {
builder = builder.withClientKeyFile(kubernetesCertsClientKeyFile);
}
String kubernetesCertsClientKeyPassphrase = trimToNull(config.getKubernetesCertsClientKeyPassphrase());
if (kubernetesCertsClientKeyPassphrase != null) {
builder = builder.withClientKeyPassphrase(kubernetesCertsClientKeyPassphrase);
}
String kubernetesConnectionTimeout = trimToNull(config.getKubernetesConnectionTimeout());
if (kubernetesConnectionTimeout != null) {
builder = builder.withConnectionTimeout(Integer.parseInt(kubernetesConnectionTimeout));
}
String kubernetesKeystoreFile = trimToNull(config.getKubernetesKeystoreFile());
if (kubernetesKeystoreFile != null) {
builder = builder.withKeyStoreFile(kubernetesKeystoreFile);
}
String kubernetesKeystorePassphrase = trimToNull(config.getKubernetesKeystorePassphrase());
if (kubernetesKeystorePassphrase != null) {
builder = builder.withKeyStorePassphrase(kubernetesKeystorePassphrase);
}
String kubernetesLoggingInterval = trimToNull(config.getKubernetesLoggingInterval());
if (kubernetesLoggingInterval != null) {
builder = builder.withLoggingInterval(Integer.parseInt(kubernetesLoggingInterval));
}
String kubernetesMain = trimToNull(config.getKubernetesMain());
if (kubernetesMain != null) {
builder = builder.withMasterUrl(kubernetesMain);
}
String kubernetesNamespace = trimToNull(config.getKubernetesNamespace());
if (kubernetesNamespace != null) {
builder = builder.withNamespace(kubernetesNamespace);
}
String kubernetesRequestTimeout = trimToNull(config.getKubernetesRequestTimeout());
if (kubernetesRequestTimeout != null) {
builder = builder.withRequestTimeout(Integer.parseInt(kubernetesRequestTimeout));
}
String kubernetesRollingTimeout = trimToNull(config.getKubernetesRollingTimeout());
if (kubernetesRollingTimeout != null) {
builder = builder.withRollingTimeout(Long.parseLong(kubernetesRollingTimeout));
}
String kubernetesScaleTimeout = trimToNull(config.getKubernetesScaleTimeout());
if (kubernetesScaleTimeout != null) {
builder = builder.withScaleTimeout(Long.parseLong(kubernetesScaleTimeout));
}
String kubernetesTlsVersions = trimToNull(config.getKubernetesTlsVersions());
if (kubernetesTlsVersions != null) {
String[] split = kubernetesTlsVersions.split(",");
TlsVersion[] vers = new TlsVersion[split.length];
for (int i = 0; i < split.length; i++) {
vers[i] = TlsVersion.forJavaName(split[i]);
}
builder.withTlsVersions(vers);
}
String kubernetesTrustCertificates = trimToNull(config.getKubernetesTrustCertificates());
if (kubernetesTrustCertificates != null) {
builder = builder.withTrustCerts(Boolean.parseBoolean(kubernetesTrustCertificates));
}
String kubernetesTruststoreFile = trimToNull(config.getKubernetesTruststoreFile());
if (kubernetesTruststoreFile != null) {
builder = builder.withTrustStoreFile(kubernetesTruststoreFile);
}
String kubernetesTruststorePassphrase = trimToNull(config.getKubernetesTruststorePassphrase());
if (kubernetesTruststorePassphrase != null) {
builder = builder.withTrustStorePassphrase(kubernetesTruststorePassphrase);
}
String kubernetesUserAgent = trimToNull(config.getKubernetesUserAgent());
if (kubernetesUserAgent != null) {
builder = builder.withUserAgent(kubernetesUserAgent);
}
String kubernetesWatchReconnectInterval = trimToNull(config.getKubernetesWatchReconnectInterval());
if (kubernetesWatchReconnectInterval != null) {
builder = builder.withWatchReconnectInterval(Integer.parseInt(kubernetesWatchReconnectInterval));
}
String kubernetesWatchReconnectLimit = trimToNull(config.getKubernetesWatchReconnectLimit());
if (kubernetesWatchReconnectLimit != null) {
builder = builder.withWatchReconnectLimit(Integer.parseInt(kubernetesWatchReconnectLimit));
}
String kubernetesWebsocketPingInterval = trimToNull(config.getKubernetesWebsocketPingInterval());
if (kubernetesWebsocketPingInterval != null) {
builder = builder.withWebsocketPingInterval(Long.parseLong(kubernetesWebsocketPingInterval));
}
String kubernetesWebsocketTimeout = trimToNull(config.getKubernetesWebsocketTimeout());
if (kubernetesWebsocketTimeout != null) {
builder = builder.withWebsocketTimeout(Long.parseLong(kubernetesWebsocketTimeout));
}
String noProxy = trimToNull(config.getNoProxy());
if (noProxy != null) {
builder = builder.withNoProxy(noProxy.split(","));
}
String proxyPassword = trimToNull(config.getProxyPassword());
if (proxyPassword != null) {
builder = builder.withProxyPassword(proxyPassword);
}
String proxyUsername = trimToNull(config.getProxyUsername());
if (proxyUsername != null) {
builder = builder.withProxyUsername(proxyUsername);
}
/*
* OpenShift configuration properties; see io.fabric8.openshift.client.OpenShiftConfig
*/
String kubernetesOapiVersion = trimToNull(config.getKubernetesOapiVersion());
if (kubernetesOapiVersion != null) {
builder = builder.withOapiVersion(kubernetesOapiVersion);
}
String openshiftBuildTimeout = trimToNull(config.getOpenshiftBuildTimeout());
if (openshiftBuildTimeout != null) {
builder = builder.withBuildTimeout(Long.parseLong(openshiftBuildTimeout));
}
String openshiftUrl = trimToNull(config.getOpenshiftUrl());
if (openshiftUrl != null) {
// The OPENSHIFT_URL environment variable may be set to the root url (i.e. without the '/oapi/version' path) in some configurations
if (isRootUrl(openshiftUrl)) {
openshiftUrl = URLUtils.join(openshiftUrl, "oapi", builder.getOapiVersion());
}
builder = builder.withOpenShiftUrl(openshiftUrl);
} else {
builder.withOpenShiftUrl(URLUtils.join(builder.getMasterUrl(), "oapi", builder.getOapiVersion()));
}
return builder.build();
}
use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project docker-maven-plugin by fabric8io.
the class BuildMojo method proceedWithJibBuild.
private void proceedWithJibBuild(ServiceHub hub, BuildService.BuildContext buildContext, ImageConfiguration imageConfig) throws MojoExecutionException {
log.info("Building Container image with [[B]]JIB(Java Image Builder)[[B]] mode");
new JibBuildService(hub, createMojoParameters(), log).build(jibImageFormat, imageConfig, buildContext.getRegistryConfig());
}
Aggregations