use of io.fabric8.patch.impl.Offline in project fabric8 by jboss-fuse.
the class ApplyPatchMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
getLog().info("Applyings patches to " + outputDirectory);
Offline offline = new Offline(outputDirectory, new Offline.Logger() {
@Override
public void log(int level, String message) {
switch(level) {
case Offline.DEBUG:
getLog().debug(message);
break;
case Offline.INFO:
getLog().info(message);
break;
case Offline.WARN:
getLog().warn(message);
break;
case Offline.ERROR:
getLog().error(message);
break;
}
}
});
try {
for (File patch : patches) {
getLog().info("Applying patch: " + patch);
offline.apply(patch);
}
} catch (Exception e) {
throw new MojoFailureException("Error processing patches", e);
}
}
use of io.fabric8.patch.impl.Offline in project fabric8 by jboss-fuse.
the class ArchetypeTest method assertArchetypeCreated.
private void assertArchetypeCreated(String artifactId, String groupId, String version) throws Exception {
Hashtable<String, String> props = new Hashtable<>();
props.put("offline", "true");
MavenResolver resolver = MavenResolvers.createMavenResolver(props, null);
File archetypejar = resolver.resolveFile(new DefaultArtifact(groupId, artifactId, null, null, version));
assertTrue("archetype jar does not exist", archetypejar.exists());
assertArchetypeCreated(artifactId, groupId, version, archetypejar);
}
use of io.fabric8.patch.impl.Offline in project fabric8 by jboss-fuse.
the class Main method main.
public static void main(String[] args) throws Exception {
File patch;
File base;
if (args.length < 1) {
help();
return;
}
patch = new File(args[0]);
if (!patch.isFile()) {
System.err.println("Invalid patch file");
return;
}
if (args.length > 1) {
base = new File(args[1]);
} else {
base = new File(System.getProperty("karaf.base"));
}
if (!new File(base, "system").isDirectory() || !new File(base, "etc").isDirectory()) {
System.err.println("Invalid karaf-base parameter");
return;
}
new Offline(base).apply(patch);
}
use of io.fabric8.patch.impl.Offline in project fabric8-maven-plugin by fabric8io.
the class AbstractLiveEnricher method getExternalServiceURL.
/**
* Returns the external access to the given service name
*
* @param serviceName name of the service
* @param protocol URL protocol such as <code>http</code>
*/
protected String getExternalServiceURL(String serviceName, String protocol) {
if (!isOnline()) {
getLog().info("Not looking for service " + serviceName + " as we are in offline mode");
return null;
} else {
try {
KubernetesClient kubernetes = getKubernetes();
String ns = kubernetes.getNamespace();
if (Strings.isNullOrBlank(ns)) {
ns = getNamespace();
}
Service service = kubernetes.services().inNamespace(ns).withName(serviceName).get();
return service != null ? KubernetesHelper.getServiceURL(kubernetes, serviceName, ns, protocol, true) : null;
} catch (Throwable e) {
Throwable cause = e;
boolean notFound = false;
boolean connectError = false;
Stack<Throwable> stack = unfoldExceptions(e);
while (!stack.isEmpty()) {
Throwable t = stack.pop();
if (t instanceof ConnectException || "No route to host".equals(t.getMessage())) {
getLog().warn("Cannot connect to Kubernetes to find URL for service %s : %s", serviceName, cause.getMessage());
return null;
} else if (t instanceof IllegalArgumentException || t.getMessage() != null && t.getMessage().matches("^No.*found.*$")) {
getLog().warn("%s", cause.getMessage());
return null;
}
;
}
getLog().warn("Cannot find URL for service %s : %s", serviceName, cause.getMessage());
return null;
}
}
}
Aggregations