本文整理了Java中io.fabric8.openshift.api.model.Build.getMetadata()
方法的一些代码示例,展示了Build.getMetadata()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Build.getMetadata()
方法的具体详情如下:
包路径:io.fabric8.openshift.api.model.Build
类名称:Build
方法名:getMetadata
暂无
代码示例来源:origin: fabric8io/kubernetes-client
private void deleteBuilds() {
if (getName() == null) {
return;
}
String buildConfigLabelValue = getName().substring(0, Math.min(getName().length(), 63));
BuildList matchingBuilds = new BuildOperationsImpl(client, (OpenShiftConfig) config, namespace).inNamespace(namespace).withLabel(BUILD_CONFIG_LABEL, buildConfigLabelValue).list();
if (matchingBuilds.getItems() != null) {
for (Build matchingBuild : matchingBuilds.getItems()) {
if (matchingBuild.getMetadata() != null &&
matchingBuild.getMetadata().getAnnotations() != null &&
getName().equals(matchingBuild.getMetadata().getAnnotations().get(BUILD_CONFIG_ANNOTATION))) {
new BuildOperationsImpl(client, (OpenShiftConfig) config, namespace).inNamespace(matchingBuild.getMetadata().getNamespace()).withName(matchingBuild.getMetadata().getName()).delete();
}
}
}
}
代码示例来源:origin: io.fabric8.jenkins.plugins/openshift-sync
@Override
public int compare(Build b1, Build b2) {
return Long.compare(
parseTimestamp(b1.getMetadata().getCreationTimestamp()),
parseTimestamp(b2.getMetadata().getCreationTimestamp())
);
}
});
代码示例来源:origin: io.fabric8.jenkins.plugins/openshift-sync
public static void cancelOpenShiftBuild(Build build) {
logger.info("cancelling build in namespace " + build.getMetadata().getNamespace() + " with name: " + build.getMetadata().getName());
getOpenShiftClient().builds().inNamespace(build.getMetadata().getNamespace()).withName(build.getMetadata().getName())
.edit()
.editStatus().withPhase(CANCELLED).endStatus()
.done();
}
代码示例来源:origin: io.fabric8/openshift-client
private void deleteBuilds() {
if (getName() == null) {
return;
}
String buildConfigLabelValue = getName().substring(0, Math.min(getName().length(), 63));
BuildList matchingBuilds = new BuildOperationsImpl(client, (OpenShiftConfig) config, namespace).inNamespace(namespace).withLabel(BUILD_CONFIG_LABEL, buildConfigLabelValue).list();
if (matchingBuilds.getItems() != null) {
for (Build matchingBuild : matchingBuilds.getItems()) {
if (matchingBuild.getMetadata() != null &&
matchingBuild.getMetadata().getAnnotations() != null &&
getName().equals(matchingBuild.getMetadata().getAnnotations().get(BUILD_CONFIG_ANNOTATION))) {
new BuildOperationsImpl(client, (OpenShiftConfig) config, namespace).inNamespace(matchingBuild.getMetadata().getNamespace()).withName(matchingBuild.getMetadata().getName()).delete();
}
}
}
}
代码示例来源:origin: io.fabric8/fabric8-build-workflow
protected static Build createBuild(BuildCorrelationKey key) {
Build build = new Build();
build.setMetadata(new ObjectMeta());
build.getMetadata().setName(key.getBuildName());
build.getMetadata().setNamespace(key.getNamespace());
build.getMetadata().setUid(key.getBuildUuid());
BuildStatus status = new BuildStatus();
status.setCompletionTimestamp(new Date().toString());
build.setStatus(status);
return build;
}
}
代码示例来源:origin: io.syndesis.server/server-openshift
private Build waitForBuild(Build r, long timeout, TimeUnit timeUnit) throws InterruptedException {
long end = System.currentTimeMillis() + timeUnit.toMillis(timeout);
Build next = r;
int retriesLeft = config.getMaximumRetries();
while ( System.currentTimeMillis() < end) {
if (next.getStatus() != null && ("Complete".equals(next.getStatus().getPhase()) || "Failed".equals(next.getStatus().getPhase()))) {
return next;
}
try {
next = openShiftClient.builds().inNamespace(next.getMetadata().getNamespace()).withName(next.getMetadata().getName()).get();
} catch (KubernetesClientException e) {
checkRetryPolicy(e, retriesLeft--);
}
Thread.sleep(config.getPollingInterval());
}
throw SyndesisServerException.launderThrowable(new TimeoutException("Timed out waiting for build completion."));
}
代码示例来源:origin: fabric8io/kubernetes-client
.withNewMetadata().withName("custom-build-config").endMetadata()
.build());
log("Build:", build.getMetadata().getName());
log("\t\t\t"+b.getMetadata().getName());
log("\t\t\t\t\t Log:");client.builds().inNamespace("thisisatest").withName(b.getMetadata().getName()).watchLog(System.out);
代码示例来源:origin: io.fabric8.jenkins.plugins/openshift-sync
public static Job getJobFromBuild(Build build) {
String buildConfigName = build.getStatus().getConfig().getName();
if (StringUtils.isEmpty(buildConfigName)) {
return null;
}
BuildConfig buildConfig = getOpenShiftClient().buildConfigs().inNamespace(build.getMetadata().getNamespace()).withName(buildConfigName).get();
if (buildConfig == null) {
return null;
}
return BuildTrigger.DESCRIPTOR.getJobFromBuildConfigUid(buildConfig.getMetadata().getUid());
}
}
代码示例来源:origin: org.domeos/kubernetes-model
public BuildFluentImpl(Build instance){
this.withApiVersion(instance.getApiVersion());
this.withKind(instance.getKind());
this.withMetadata(instance.getMetadata());
this.withSpec(instance.getSpec());
this.withStatus(instance.getStatus());
}
代码示例来源:origin: org.apache.stratos/kubernetes-model
public BuildBuilder( BuildFluent<?> fluent , Build instance ){
this.fluent = fluent; fluent.withApiVersion(instance.getApiVersion()); fluent.withKind(instance.getKind()); fluent.withMetadata(instance.getMetadata()); fluent.withSpec(instance.getSpec()); fluent.withStatus(instance.getStatus());
}
public BuildBuilder( Build instance ){
代码示例来源:origin: io.fabric8.schemagenerator/kubernetes-model
public BuildBuilder( BuildFluent<?> fluent , Build instance ){
this.fluent = fluent; fluent.withApiVersion(instance.getApiVersion()); fluent.withKind(instance.getKind()); fluent.withMetadata(instance.getMetadata()); fluent.withSpec(instance.getSpec()); fluent.withStatus(instance.getStatus());
}
public BuildBuilder( Build instance ){
代码示例来源:origin: org.domeos/kubernetes-model
public BuildBuilder(BuildFluent<?> fluent,Build instance,Boolean validationEnabled){
this.fluent = fluent;
fluent.withApiVersion(instance.getApiVersion());
fluent.withKind(instance.getKind());
fluent.withMetadata(instance.getMetadata());
fluent.withSpec(instance.getSpec());
fluent.withStatus(instance.getStatus());
this.validationEnabled = validationEnabled;
}
public BuildBuilder(Build instance){
代码示例来源:origin: org.domeos/kubernetes-model
public BuildBuilder(Build instance,Boolean validationEnabled){
this.fluent = this;
this.withApiVersion(instance.getApiVersion());
this.withKind(instance.getKind());
this.withMetadata(instance.getMetadata());
this.withSpec(instance.getSpec());
this.withStatus(instance.getStatus());
this.validationEnabled = validationEnabled;
}
代码示例来源:origin: io.fabric8.schemagenerator/kubernetes-model
public BuildBuilder( Build instance ){
this.fluent = this; this.withApiVersion(instance.getApiVersion()); this.withKind(instance.getKind()); this.withMetadata(instance.getMetadata()); this.withSpec(instance.getSpec()); this.withStatus(instance.getStatus());
}
代码示例来源:origin: org.apache.stratos/kubernetes-model
public BuildBuilder( Build instance ){
this.fluent = this; this.withApiVersion(instance.getApiVersion()); this.withKind(instance.getKind()); this.withMetadata(instance.getMetadata()); this.withSpec(instance.getSpec()); this.withStatus(instance.getStatus());
}
代码示例来源:origin: io.syndesis.server/server-monitoring
if (build.isPresent()) {
podName = build.get().getMetadata().getAnnotations().get(BUILD_POD_NAME_ANNOTATION);
if (podName != null) {
final Pod pod = getPod(podName);
代码示例来源:origin: io.fabric8.jenkins.plugins/openshift-sync
public static void cancelBuild(Job job, Build build) {
String buildUid = build.getMetadata().getUid();
Jenkins jenkins = Jenkins.getInstance();
if (jenkins != null) {
Queue buildQueue = jenkins.getQueue();
for (Queue.Item item : buildQueue.getItems()) {
for (Cause cause : item.getCauses()) {
if (cause instanceof BuildCause && ((BuildCause) cause).getUid().equals(buildUid)) {
buildQueue.cancel(item);
cancelOpenShiftBuild(build);
return;
}
}
}
for (Object obj : job.getNewBuilds()) {
if (obj instanceof WorkflowRun) {
WorkflowRun b = (WorkflowRun) obj;
BuildCause cause = b.getCause(BuildCause.class);
if (cause != null && cause.getUid().equals(buildUid)) {
Executor e = b.getExecutor();
if (e != null) {
e.interrupt(ABORTED);
break;
}
}
}
}
cancelOpenShiftBuild(build);
}
}
代码示例来源:origin: fabric8io/fabric8-maven-plugin
private void logBuildFailure(OpenShiftClient client, String buildName) throws Fabric8ServiceException {
try {
List<Build> builds = client.builds().inNamespace(client.getNamespace()).list().getItems();
for(Build build : builds) {
if(build.getMetadata().getName().contains(buildName)) {
log.error(build.getMetadata().getName() + "\t" + "\t" + build.getStatus().getReason() + "\t" + build.getStatus().getMessage());
throw new Fabric8ServiceException("Unable to build the image using the OpenShift build service", new KubernetesClientException(build.getStatus().getReason() + " " + build.getStatus().getMessage()));
}
}
log.error("Also, check cluster events via `oc get events` to see what could have possibly gone wrong");
} catch (KubernetesClientException clientException) {
Status status = clientException.getStatus();
if (status != null)
log.error("OpenShift Error: [%d] %s", status.getCode(), status.getMessage());
}
}
代码示例来源:origin: io.fabric8.jenkins.plugins/openshift-sync
public BuildCause(Build build) {
if (build == null || build.getMetadata() == null) {
return;
}
ObjectMeta meta = build.getMetadata();
uid = meta.getUid();
namespace = meta.getNamespace();
name = meta.getName();
if (build.getSpec() != null) {
if (build.getSpec().getSource() != null && build.getSpec().getSource().getGit() != null) {
GitBuildSource git = build.getSpec().getSource().getGit();
gitUri = git.getUri();
}
if (build.getSpec().getRevision() != null && build.getSpec().getRevision().getGit() != null) {
commit = build.getSpec().getRevision().getGit().getCommit();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!