use of io.fabric8.openshift.client.DefaultOpenShiftClient in project jointware by isdream.
the class OpenshiftAPIExample method main.
/**
* @param args
*/
public static void main(String[] args) {
DefaultOpenShiftClient client = createClient();
client.pods();
client.extensions().deployments();
client.replicationControllers();
client.secrets();
MixedOperation<Deployment, DeploymentList, DoneableDeployment, ScalableResource<Deployment, DoneableDeployment>> deployment = client.extensions().deployments();
System.out.println(deployment.list().getItems());
}
use of io.fabric8.openshift.client.DefaultOpenShiftClient in project fabric8-maven-plugin by fabric8io.
the class OpenshiftBuildServiceTest method testSuccessfulBuild.
@Test
public void testSuccessfulBuild() throws Exception {
int nTries = 0;
boolean bTestComplete = false;
do {
try {
nTries++;
BuildService.BuildServiceConfig config = defaultConfig.build();
WebServerEventCollector<OpenShiftMockServer> collector = createMockServer(config, true, 50, false, false);
OpenShiftMockServer mockServer = collector.getMockServer();
DefaultOpenShiftClient client = (DefaultOpenShiftClient) mockServer.createOpenShiftClient();
LOG.info("Current write timeout is : {}", client.getHttpClient().writeTimeoutMillis());
LOG.info("Current read timeout is : {}", client.getHttpClient().readTimeoutMillis());
LOG.info("Retry on failure : {}", client.getHttpClient().retryOnConnectionFailure());
OpenshiftBuildService service = new OpenshiftBuildService(client, logger, dockerServiceHub, config);
service.build(image);
// we should Foadd a better way to assert that a certain call has been made
assertTrue(mockServer.getRequestCount() > 8);
collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed");
collector.assertEventsNotRecorded("patch-build-config");
bTestComplete = true;
} catch (Fabric8ServiceException exception) {
Throwable rootCause = getRootCause(exception);
logger.warn("A problem encountered while running test {}, retrying..", exception.getMessage());
// Let's wait for a while, and then retry again
if (rootCause != null && rootCause instanceof IOException) {
continue;
}
}
} while (nTries < MAX_TIMEOUT_RETRIES && !bTestComplete);
}
use of io.fabric8.openshift.client.DefaultOpenShiftClient in project fabric8 by fabric8io.
the class TriggerBuild method main.
public static void main(String... args) {
if (args.length < 1) {
System.out.println("Usage: buildConfigName namespace secret type");
return;
}
String name = args[0];
String namespace = "default";
if (args.length > 1) {
namespace = args[1];
}
OpenShiftClient client = new DefaultOpenShiftClient();
try {
client.buildConfigs().inNamespace(namespace).withName(name).trigger(new WebHookTrigger(true, null));
} catch (Exception e) {
System.out.println("FAILED: " + e);
e.printStackTrace();
}
}
use of io.fabric8.openshift.client.DefaultOpenShiftClient in project fabric8 by fabric8io.
the class WatchBuilds method main.
public static void main(String... args) {
String namespace = null;
if (args.length > 0) {
namespace = args[0];
}
String consoleLink = Links.getFabric8ConsoleLink();
OpenShiftClient client = new DefaultOpenShiftClient();
BuildListener buildListener = new BuildListener() {
@Override
public void onBuildFinished(BuildFinishedEvent event) {
System.out.println("Build: " + event.getUid() + " for config: " + event.getConfigName() + " finished. Status: " + event.getStatus() + " link: " + event.getBuildLink());
}
};
BuildWatcher watcher = new BuildWatcher(client, buildListener, namespace, consoleLink);
long pollTime = 3000;
watcher.schedule(pollTime);
watcher.join();
}
use of io.fabric8.openshift.client.DefaultOpenShiftClient in project fabric8 by jboss-fuse.
the class WatchBuilds method main.
public static void main(String... args) {
String namespace = null;
if (args.length > 0) {
namespace = args[0];
}
String consoleLink = Links.getFabric8ConsoleLink();
OpenShiftClient client = new DefaultOpenShiftClient();
BuildListener buildListener = new BuildListener() {
@Override
public void onBuildFinished(BuildFinishedEvent event) {
System.out.println("Build: " + event.getUid() + " for config: " + event.getConfigName() + " finished. Status: " + event.getStatus() + " link: " + event.getBuildLink());
}
};
BuildWatcher watcher = new BuildWatcher(client, buildListener, namespace, consoleLink);
long pollTime = 3000;
watcher.schedule(pollTime);
watcher.join();
}
Aggregations