当前位置: 首页>>代码示例>>Java>>正文


Java ObjectMeta类代码示例

本文整理汇总了Java中io.fabric8.kubernetes.api.model.ObjectMeta的典型用法代码示例。如果您正苦于以下问题:Java ObjectMeta类的具体用法?Java ObjectMeta怎么用?Java ObjectMeta使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ObjectMeta类属于io.fabric8.kubernetes.api.model包,在下文中一共展示了ObjectMeta类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    initMocks(this);
    when(factory.kubernetes(any(PluginSettings.class))).thenReturn(mockedClient);
    when(mockedClient.pods()).thenReturn(mockedOperation);
    when(mockedOperation.inNamespace(Constants.KUBERNETES_NAMESPACE_KEY)).thenReturn(mockedNamespaceOperation);

    when(mockedNamespaceOperation.create(any(Pod.class))).thenAnswer(new Answer<Pod>() {
        @Override
        public Pod answer(InvocationOnMock invocation) throws Throwable {
            Object[] args = invocation.getArguments();
            return (Pod) args[0];
        }
    });

    when(mockedNamespaceOperation.withName(anyString())).thenReturn(podResource);
    when(podResource.get()).thenReturn(mockedPod);

    objectMetadata = new ObjectMeta();
    objectMetadata.setCreationTimestamp(getSimpleDateFormat().format(new Date()));

    when(mockedPod.getMetadata()).thenReturn(objectMetadata);
}
 
开发者ID:gocd,项目名称:kubernetes-elastic-agents,代码行数:24,代码来源:ServerPingRequestExecutorTest.java

示例2: createService

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入依赖的package包/类
protected Service createService(final String namespace,
                                final String serviceName,
                                Map<String, String> labels) {
  labels = normalizeLabels(labels);

  final Service service = new Service();
  
  final ObjectMeta metadata = new ObjectMeta();
  metadata.setNamespace(normalizeNamespace(namespace));
  metadata.setName(normalizeServiceName(serviceName));
  metadata.setLabels(labels);
  
  service.setMetadata(metadata);
  service.setSpec(this.createServiceSpec(labels));

  return service;
}
 
开发者ID:microbean,项目名称:microbean-helm,代码行数:18,代码来源:TillerInstaller.java

示例3: createDeployment

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入依赖的package包/类
protected Deployment createDeployment(String namespace,
                                      final String deploymentName,
                                      Map<String, String> labels,
                                      final String serviceAccountName,
                                      final String imageName,
                                      final ImagePullPolicy imagePullPolicy,
                                      final boolean hostNetwork,
                                      final boolean tls,
                                      final boolean verifyTls) {
  namespace = normalizeNamespace(namespace);
  labels = normalizeLabels(labels);

  final Deployment deployment = new Deployment();

  final ObjectMeta metadata = new ObjectMeta();
  metadata.setNamespace(namespace);
  metadata.setName(normalizeDeploymentName(deploymentName));
  metadata.setLabels(labels);
  deployment.setMetadata(metadata);

  deployment.setSpec(this.createDeploymentSpec(labels, serviceAccountName, imageName, imagePullPolicy, namespace, hostNetwork, tls, verifyTls));
  return deployment;
}
 
开发者ID:microbean,项目名称:microbean-helm,代码行数:24,代码来源:TillerInstaller.java

示例4: newPod

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入依赖的package包/类
private Pod newPod(String uid, String namespace, String name, String node) {
    Pod pod = new Pod();

    ObjectMeta objMeta = new ObjectMeta();
    objMeta.setName(name);
    objMeta.setNamespace(namespace);
    objMeta.setUid(uid);

    PodSpec spec = new PodSpec();
    spec.setNodeName(node);

    pod.setMetadata(objMeta);
    pod.setSpec(spec);

    return pod;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:17,代码来源:KubernetesPodApiTest.java

示例5: matches

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入依赖的package包/类
@Override
public boolean matches(Object object) {
    if (object == null || !(object instanceof Deployment)) {
        return false;
    }
    Deployment deployment = (Deployment)object;

    ObjectMeta metadata = deployment.getMetadata();

    DeploymentSpec spec = deployment.getSpec();
    PodTemplateSpec podTemplateSpec = spec.getTemplate();
    String podLabel = podTemplateSpec.getMetadata().getLabels().get("osc-deployment");

    Container container = podTemplateSpec.getSpec().getContainers().get(0);

    return this.name.equals(metadata.getName()) &&
            this.name.equals(podLabel) &&
            this.replicaCount == spec.getReplicas() &&
            this.imageName.equals(container.getImage()) &&
            this.name.equals(container.getName());
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:22,代码来源:KubernetesDeploymentApiTest.java

示例6: BuildCause

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入依赖的package包/类
public BuildCause(Build build, String buildConfigUid) {
    this.buildConfigUid = buildConfigUid;
    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();
        }
    }
}
 
开发者ID:jenkinsci,项目名称:openshift-sync-plugin,代码行数:24,代码来源:BuildCause.java

示例7: isPipelineStrategyBuildConfig

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入依赖的package包/类
/**
 * Checks if a {@link BuildConfig} relates to a Jenkins build
 *
 * @param bc
 *            the BuildConfig
 * @return true if this is an OpenShift BuildConfig which should be mirrored to
 *         a Jenkins Job
 */
public static boolean isPipelineStrategyBuildConfig(BuildConfig bc) {
	if (BuildConfigToJobMapper.JENKINS_PIPELINE_BUILD_STRATEGY
			.equalsIgnoreCase(bc.getSpec().getStrategy().getType())
			&& bc.getSpec().getStrategy().getJenkinsPipelineStrategy() != null) {
		return true;
	}

	ObjectMeta metadata = bc.getMetadata();
	if (metadata != null) {
		Map<String, String> annotations = metadata.getAnnotations();
		if (annotations != null) {
			if (annotations.get("fabric8.link.jenkins.job/label") != null) {
				return true;
			}
		}
	}

	return false;
}
 
开发者ID:jenkinsci,项目名称:openshift-sync-plugin,代码行数:28,代码来源:OpenShiftUtils.java

示例8: fakeServiceAccountKeySecret

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入依赖的package包/类
private static Secret fakeServiceAccountKeySecret(String serviceAccount, long epoch, String jsonKeyId,
    String p12KeyId, String creationTimestamp) {
  final String jsonKeyName = keyName(serviceAccount, jsonKeyId);
  final String p12KeyName = keyName(serviceAccount, p12KeyId);

  final ObjectMeta metadata = new ObjectMeta();
  metadata.setCreationTimestamp(creationTimestamp);
  metadata.setName("styx-wf-sa-keys-" + epoch + "-" + Hashing.sha256().hashString(serviceAccount, UTF_8));
  metadata.setAnnotations(ImmutableMap.of(
      "styx-wf-sa", serviceAccount,
      "styx-wf-sa-json-key-name", jsonKeyName,
      "styx-wf-sa-p12-key-name", p12KeyName));

  return new SecretBuilder()
      .withMetadata(metadata)
      .withData(ImmutableMap.of(
          "styx-wf-sa.json", "json-private-key-data",
          "styx-wf-sa.p12", "p12-private-key-data"))
      .build();
}
 
开发者ID:spotify,项目名称:styx,代码行数:21,代码来源:KubernetesGCPServiceAccountSecretManagerTest.java

示例9: initService

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入依赖的package包/类
public void initService() {
  final ObjectMeta buildmyTestService = new ObjectMetaBuilder().addToLabels("test", "test").withName("myTestService").build();
  final ServicePort portmyTestService = new ServicePortBuilder().withPort(8080).withProtocol("http").build();
  final ServiceSpec specmyTestService = new ServiceSpecBuilder().addNewPort().and()
      .withClusterIP("192.168.1.1").withPorts(portmyTestService).build();

  final ObjectMeta buildmyTestService2 = new ObjectMetaBuilder().addToLabels("test", "test2").withName("myTestService2").build();
  final ServicePort portmyTestService2 = new ServicePortBuilder().withPort(9080).withProtocol("http").build();
  final ServiceSpec specmyTestService2 = new ServiceSpecBuilder().addNewPort().and()
      .withClusterIP("192.168.1.2").withPorts(portmyTestService2).build();

  final Service servicemyTestService = new ServiceBuilder().withMetadata(buildmyTestService).withSpec(specmyTestService).build();
  final Service servicemyTestService2 = new ServiceBuilder().withMetadata(buildmyTestService2).withSpec(specmyTestService2).build();
  server.expect().withPath("/api/v1/namespaces/default/services").andReturn(200, new ServiceListBuilder().addToItems(servicemyTestService,servicemyTestService2).build()).times(2);

}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:17,代码来源:ResolveServicesByNameTest.java

示例10: initService

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入依赖的package包/类
public void initService() {
  final ObjectMeta buildmyTestService = new ObjectMetaBuilder().addToLabels("name", "myTestService").addToLabels("version", "v1").withName("myTestService").build();
  final ServicePort portmyTestService = new ServicePortBuilder().withPort(8080).withProtocol("http").build();
  final ServiceSpec specmyTestService = new ServiceSpecBuilder().addNewPort().and()
      .withClusterIP("192.168.1.1").withPorts(portmyTestService).build();

  final ObjectMeta buildmyTestService2 = new ObjectMetaBuilder().addToLabels("name", "myTestService").addToLabels("version", "v2").withName("myTestService2").build();
  final ServicePort portmyTestService2 = new ServicePortBuilder().withPort(9080).withProtocol("http").build();
  final ServiceSpec specmyTestService2 = new ServiceSpecBuilder().addNewPort().and()
      .withClusterIP("192.168.1.2").withPorts(portmyTestService2).build();

  final Service servicemyTestService = new ServiceBuilder().withMetadata(buildmyTestService).withSpec(specmyTestService).build();
  final Service servicemyTestService2 = new ServiceBuilder().withMetadata(buildmyTestService2).withSpec(specmyTestService2).build();
  server.expect().withPath("/api/v1/namespaces/default/services?labelSelector=name%3DmyTestService,version%3Dv1").andReturn(200, new ServiceListBuilder().addToItems(servicemyTestService).build()).times(1);
  server.expect().withPath("/api/v1/namespaces/default/services?labelSelector=name%3DmyTestService,version%3Dv2").andReturn(200, new ServiceListBuilder().addToItems(servicemyTestService2).build()).times(1);

}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:18,代码来源:ResolveServicesByLabelsConfigAndPortOKOfflineTest.java

示例11: initService

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入依赖的package包/类
public void initService() {
  final ObjectMeta buildmyTestService = new ObjectMetaBuilder().addToLabels("test", "test").withName("myTestService").build();
  final ServicePort portmyTestService_1 = new ServicePortBuilder().withName("mainhttp").withPort(8080).withProtocol("http").build();
  final ServicePort portmyTestService_2 = new ServicePortBuilder().withName("mytcp").withPort(9090).withProtocol("tcp").build();
  final ServiceSpec specmyTestService = new ServiceSpecBuilder().addNewPort().and()
      .withClusterIP("192.168.1.1").withPorts(portmyTestService_1,portmyTestService_2).build();

  final ObjectMeta buildmyTestService2 = new ObjectMetaBuilder().addToLabels("test", "test2").withName("myTestService2").build();
  final ServicePort portmyTestService2_1 = new ServicePortBuilder().withPort(9080).withProtocol("http").build();
  final ServicePort portmyTestService2_2 = new ServicePortBuilder().withName("test").withPort(9090).withProtocol("http").build();
  final ServiceSpec specmyTestService2 = new ServiceSpecBuilder().addNewPort().and()
      .withClusterIP("192.168.1.2").withPorts(portmyTestService2_1,portmyTestService2_2).build();

  final Service servicemyTestService = new ServiceBuilder().withMetadata(buildmyTestService).withSpec(specmyTestService).build();
  final Service servicemyTestService2 = new ServiceBuilder().withMetadata(buildmyTestService2).withSpec(specmyTestService2).build();
  server.expect().withPath("/api/v1/namespaces/default/services").andReturn(200, new ServiceListBuilder().addToItems(servicemyTestService,servicemyTestService2).build()).times(2);

}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:19,代码来源:ResolveServicesByLAbelsWithPortNameTest.java

示例12: initService

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入依赖的package包/类
public void initService() {
  final ObjectMeta buildmyTestService = new ObjectMetaBuilder().addToLabels("name", "myTestService").addToLabels("version", "v1").withName("myTestService").build();
  final ServicePort portmyTestService = new ServicePortBuilder().withPort(8080).withProtocol("http").build();
  final ServiceSpec specmyTestService = new ServiceSpecBuilder().addNewPort().and()
      .withClusterIP("192.168.1.1").withPorts(portmyTestService).build();

  final ObjectMeta buildmyTestService2 = new ObjectMetaBuilder().addToLabels("name", "myTestService").addToLabels("version", "v2").withName("myTestService2").build();
  final ServicePort portmyTestService2 = new ServicePortBuilder().withPort(9080).withProtocol("http").build();
  final ServiceSpec specmyTestService2 = new ServiceSpecBuilder().addNewPort().and()
      .withClusterIP("192.168.1.2").withPorts(portmyTestService2).build();

  final Service servicemyTestService = new ServiceBuilder().withMetadata(buildmyTestService).withSpec(specmyTestService).build();
  final Service servicemyTestService2 = new ServiceBuilder().withMetadata(buildmyTestService2).withSpec(specmyTestService2).build();
  server.expect().withPath("/api/v1/namespaces/default/services?labelSelector=name%3DmyTestService").andReturn(200, new ServiceListBuilder().addToItems(servicemyTestService,servicemyTestService2).build()).times(2);

}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:17,代码来源:ResolveServicesByLabelsTooManyNOKTest.java

示例13: initService

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入依赖的package包/类
public void initService() {
  final ObjectMeta buildmyTestService = new ObjectMetaBuilder().addToLabels("name", "myTestService").addToLabels("version", "v1").withName("myTestService").build();
  final ServicePort portmyTestService = new ServicePortBuilder().withPort(8080).withProtocol("http").build();
  final ServiceSpec specmyTestService = new ServiceSpecBuilder().addNewPort().and()
      .withClusterIP("192.168.1.1").withPorts(portmyTestService).build();

  final ObjectMeta buildmyTestService2 = new ObjectMetaBuilder().addToLabels("name", "myTestService").addToLabels("version", "v2").withName("myTestService2").build();
  final ServicePort portmyTestService2 = new ServicePortBuilder().withPort(9080).withProtocol("http").build();
  final ServiceSpec specmyTestService2 = new ServiceSpecBuilder().addNewPort().and()
      .withClusterIP("192.168.1.2").withPorts(portmyTestService2).build();

  final Service servicemyTestService = new ServiceBuilder().withMetadata(buildmyTestService).withSpec(specmyTestService).build();
  final Service servicemyTestService2 = new ServiceBuilder().withMetadata(buildmyTestService2).withSpec(specmyTestService2).build();
  server.expect().withPath("/api/v1/namespaces/default/services?labelSelector=version%3Dv1").andReturn(200, new ServiceListBuilder().addToItems(servicemyTestService).build()).times(1);
  server.expect().withPath("/api/v1/namespaces/default/services?labelSelector=version%3Dv2").andReturn(200, new ServiceListBuilder().addToItems(servicemyTestService2).build()).times(1);

}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:18,代码来源:ResolveServicesByLabelOKTest.java

示例14: initService

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入依赖的package包/类
public void initService() {
  final ObjectMeta buildmyTestService = new ObjectMetaBuilder().addToLabels("name", "myTestService").addToLabels("version", "v1").withName("myTestService").build();
  final ServicePort portmyTestService = new ServicePortBuilder().withPort(8080).withProtocol("http").build();
  final ServiceSpec specmyTestService = new ServiceSpecBuilder().addNewPort().and()
      .withClusterIP("192.168.1.1").withPorts(portmyTestService).build();

  final ObjectMeta buildmyTestService2 = new ObjectMetaBuilder().addToLabels("name", "myTestService").addToLabels("version", "v2").withName("myTestService2").build();
  final ServicePort portmyTestService2 = new ServicePortBuilder().withPort(9080).withProtocol("http").build();
  final ServiceSpec specmyTestService2 = new ServiceSpecBuilder().addNewPort().and()
      .withClusterIP("192.168.1.2").withPorts(portmyTestService2).build();

  final Service servicemyTestService = new ServiceBuilder().withMetadata(buildmyTestService).withSpec(specmyTestService).build();
  final Service servicemyTestService2 = new ServiceBuilder().withMetadata(buildmyTestService2).withSpec(specmyTestService2).build();
  server.expect().withPath("/api/v1/namespaces/default/services?labelSelector=service1x.name%3Dservice1x.value").andReturn(200, new ServiceListBuilder().build()).times(1);
  server.expect().withPath("/api/v1/namespaces/default/services?labelSelector=service2x.name%3Dservice2x.value").andReturn(200, new ServiceListBuilder().build()).times(1);

}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:18,代码来源:ResolveServicesByLabelWithConfigNOKTest.java

示例15: provision

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入依赖的package包/类
@Override
public void provision(OpenShiftEnvironment osEnv, RuntimeIdentity identity)
    throws InfrastructureException {
  final String workspaceId = identity.getWorkspaceId();
  final Set<Pod> pods = new HashSet<>(osEnv.getPods().values());
  osEnv.getPods().clear();
  for (Pod pod : pods) {
    final ObjectMeta podMeta = pod.getMetadata();
    putLabel(pod, Constants.CHE_ORIGINAL_NAME_LABEL, podMeta.getName());
    final String podName = Names.uniquePodName(podMeta.getName(), workspaceId);
    podMeta.setName(podName);
    osEnv.getPods().put(podName, pod);
  }
  final Set<Route> routes = new HashSet<>(osEnv.getRoutes().values());
  osEnv.getRoutes().clear();
  for (Route route : routes) {
    final ObjectMeta routeMeta = route.getMetadata();
    putLabel(route, Constants.CHE_ORIGINAL_NAME_LABEL, routeMeta.getName());
    final String routeName = Names.uniqueRouteName();
    routeMeta.setName(routeName);
    osEnv.getRoutes().put(routeName, route);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:UniqueNamesProvisioner.java


注:本文中的io.fabric8.kubernetes.api.model.ObjectMeta类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。