• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Resource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getServicesByLabel

import io.fabric8.kubernetes.client.dsl.Resource; //导入依赖的package包/类
private static ServiceList getServicesByLabel(Map<String, String> labels, KubernetesClient client)
    throws KubernetesClientException {
  Objects.requireNonNull(client, "no client available");
  final MixedOperation<Service, ServiceList, DoneableService, Resource<Service, DoneableService>>
      services = client.services();
  final FilterWatchListDeletable<Service, ServiceList, Boolean, Watch, Watcher<Service>>
      listable = createLabelFilterQuery(labels, services);
  return listable.list();
}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:10,代码来源:KubeDiscovery.java


示例2: createLabelFilterQuery

import io.fabric8.kubernetes.client.dsl.Resource; //导入依赖的package包/类
private static FilterWatchListDeletable<Service, ServiceList, Boolean, Watch, Watcher<Service>>
    createLabelFilterQuery(
        Map<String, String> labels,
        MixedOperation<Service, ServiceList, DoneableService, Resource<Service, DoneableService>>
            services) {
  FilterWatchListDeletable<Service, ServiceList, Boolean, Watch, Watcher<Service>> listable =
      null;
  for (Entry<String, String> entry : labels.entrySet()) {
    listable =
        listable == null
            ? services.withLabel(entry.getKey(), entry.getValue())
            : listable.withLabel(entry.getKey(), entry.getValue());
  }
  return listable;
}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:16,代码来源:KubeDiscovery.java


示例3: testOpenShiftProjectCreationWhenProjectDoesNotExist

import io.fabric8.kubernetes.client.dsl.Resource; //导入依赖的package包/类
@Test
public void testOpenShiftProjectCreationWhenProjectDoesNotExist() throws Exception {
  // given
  MetadataNested projectMetadata = prepareProjectRequest();

  Resource resource = prepareProjectResource(PROJECT_NAME);
  doThrow(new KubernetesClientException("error", 403, null)).when(resource).get();

  // when
  OpenShiftProject openShiftProject =
      new OpenShiftProject(clientFactory, PROJECT_NAME, WORKSPACE_ID);

  // then
  verify(projectMetadata).withName(PROJECT_NAME);
}
 
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:OpenShiftProjectTest.java


示例4: prepareProjectResource

import io.fabric8.kubernetes.client.dsl.Resource; //导入依赖的package包/类
private Resource prepareProjectResource(String projectName) {
  Resource projectResource = mock(Resource.class);

  NonNamespaceOperation projectOperation = mock(NonNamespaceOperation.class);
  doReturn(projectResource).when(projectOperation).withName(projectName);
  doReturn(projectOperation).when(openShiftClient).projects();
  openShiftClient.projects().withName(projectName).get();
  return projectResource;
}
 
开发者ID:eclipse,项目名称:che,代码行数:10,代码来源:OpenShiftProjectTest.java


示例5: addServiceAccountRole

import io.fabric8.kubernetes.client.dsl.Resource; //导入依赖的package包/类
private void addServiceAccountRole(String prjName, String name, String role) {
    Resource<PolicyBinding, DoneablePolicyBinding> bindingResource =
            delegate.policyBindings().inNamespace(prjName).withName(":default");
    DoneablePolicyBinding binding;
    if (bindingResource.get() == null) {
        binding = bindingResource.createNew();
    } else {
        binding = bindingResource.edit();
    }
    binding.editOrNewMetadata()
        .withName(":default")
        .endMetadata()
        .editOrNewPolicyRef()
        .withName("default")
        .endPolicyRef()
        .addNewRoleBinding()
        .withName(role)
        .editOrNewRoleBinding()
        .editOrNewMetadata()
        .withName(role)
        .withNamespace(prjName)
        .endMetadata()
        .addToUserNames("system:serviceaccount:" + prjName + ":" + name)
        .addNewSubject()
        .withName("default")
        .withNamespace(prjName)
        .withKind("ServiceAccount")
        .endSubject()
        .withNewRoleRef()
        .withName(role)
        .endRoleRef()
        .endRoleBinding()
        .endRoleBinding()
        .done();
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:36,代码来源:OpenShiftClient.java


示例6: addSystemGroupRole

import io.fabric8.kubernetes.client.dsl.Resource; //导入依赖的package包/类
private void addSystemGroupRole(String prjName, String name, String role) {
    Resource<PolicyBinding, DoneablePolicyBinding> bindingResource =
            delegate.policyBindings().inNamespace(prjName).withName(":default");
    DoneablePolicyBinding binding;
    if (bindingResource.get() == null) {
        binding = bindingResource.createNew();
    } else {
        binding = bindingResource.edit();
    }
    binding.editOrNewMetadata()
        .withName(":default")
        .endMetadata()
        .editOrNewPolicyRef()
        .withName("default")
        .endPolicyRef()
        .addNewRoleBinding()
        .withName(role)
        .editOrNewRoleBinding()
        .editOrNewMetadata()
        .withName(role)
        .withNamespace(prjName)
        .endMetadata()
        .addToGroupNames("system:serviceaccounts:" + prjName)
        .addNewSubject()
        .withName("default")
        .withNamespace(prjName)
        .withKind("SystemGroup")
        .endSubject()
        .withNewRoleRef()
        .withName(role)
        .endRoleRef()
        .endRoleBinding()
        .endRoleBinding()
        .done();
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:36,代码来源:OpenShiftClient.java


示例7: mockComponentStatus

import io.fabric8.kubernetes.client.dsl.Resource; //导入依赖的package包/类
private void mockComponentStatus(ComponentStatus result) {
    @SuppressWarnings("unchecked")
    Resource<ComponentStatus, DoneableComponentStatus> componentStatusResource = Mockito.mock(Resource.class);
    when(componentStatusResource.get()).thenReturn(result);
    when(this.mixedOperationMock.withName("controller-manager")).thenReturn(componentStatusResource);
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:7,代码来源:KubernetesStatusApiTest.java


示例8: testLogger

import io.fabric8.kubernetes.client.dsl.Resource; //导入依赖的package包/类
@Test
public void testLogger() {
    String ns = "myspace";
    String component = "me";
    Clock clock = Clock.fixed(Instant.ofEpochSecond(10), ZoneId.of("UTC"));

    String message = "it crashed";

    KubernetesClient mockClient = mock(KubernetesClient.class);
    MixedOperation<Event, EventList, DoneableEvent, Resource<Event, DoneableEvent>> eventOperation = mock(MixedOperation.class);
    Resource<Event, DoneableEvent> eventResource = mock(Resource.class);

    when(mockClient.events()).thenReturn(eventOperation);
    when(eventOperation.inNamespace(any())).thenReturn(eventOperation);
    when(eventOperation.withName(startsWith("me."))).thenReturn(eventResource);
    when(eventResource.get()).thenReturn(null);

    EventLogger logger = new KubeEventLogger(mockClient, ns, clock, component);
    logger.log(TestReason.NONE, "it crashed", Warning, TestKind.KIND, "myqueue");

    ArgumentCaptor<Event> eventArgumentCaptor = ArgumentCaptor.forClass(Event.class);
    verify(eventResource).create(eventArgumentCaptor.capture());
    Event newEvent = eventArgumentCaptor.getValue();
    assertNotNull(newEvent);
    assertThat(newEvent.getMessage(), is(message));
    assertThat(newEvent.getReason(), is(TestReason.NONE.name()));
    assertThat(newEvent.getType(), is(Warning.name()));
    assertThat(newEvent.getFirstTimestamp(), is(clock.instant().toString()));
    assertThat(newEvent.getLastTimestamp(), is(clock.instant().toString()));
    assertThat(newEvent.getCount(), is(1));
    assertThat(newEvent.getInvolvedObject().getName(), is("myqueue"));
    assertThat(newEvent.getInvolvedObject().getKind(), is(TestKind.KIND.name()));

    newEvent.setFirstTimestamp(Instant.ofEpochSecond(5).toString());
    when(eventResource.get()).thenReturn(newEvent);
    logger.log(TestReason.NONE, "it crashed", Warning, TestKind.KIND, "myqueue");

    eventArgumentCaptor = ArgumentCaptor.forClass(Event.class);
    verify(eventResource).create(eventArgumentCaptor.capture());
    newEvent = eventArgumentCaptor.getValue();
    assertNotNull(newEvent);
    assertThat(newEvent.getMessage(), is(message));
    assertThat(newEvent.getReason(), is(TestReason.NONE.name()));
    assertThat(newEvent.getType(), is(Warning.name()));
    assertThat(newEvent.getFirstTimestamp(), is(Instant.ofEpochSecond(5).toString()));
    assertThat(newEvent.getLastTimestamp(), is(clock.instant().toString()));
    assertThat(newEvent.getCount(), is(2));
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:49,代码来源:KubeEventLoggerTest.java


示例9: prepareProject

import io.fabric8.kubernetes.client.dsl.Resource; //导入依赖的package包/类
private void prepareProject(String projectName) {
  Project project = mock(Project.class);
  Resource projectResource = prepareProjectResource(projectName);
  doReturn(project).when(projectResource).get();
}
 
开发者ID:eclipse,项目名称:che,代码行数:6,代码来源:OpenShiftProjectTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BSFEngine类代码示例发布时间:2022-05-22
下一篇:
Java MapAnnotation类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap