io.fabric8.openshift.api.model.BuildConfigList Java Examples

The following examples show how to use io.fabric8.openshift.api.model.BuildConfigList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BuildConfigCrudTest.java    From kubernetes-client with Apache License 2.0 6 votes vote down vote up
@Test
public void testCrud() {
  OpenShiftClient client = server.getOpenshiftClient();

  BuildConfig buildConfig = new BuildConfigBuilder()
    .withNewMetadata()
      .withName("bc2")
      .withLabels(Collections.singletonMap("key","value"))
    .endMetadata()
    .build();

  client.buildConfigs().create(buildConfig);

  BuildConfig buildConfig1 = client.buildConfigs().withName("bc2").get();
  assertEquals("value", buildConfig1.getMetadata().getLabels().get("key"));

  BuildConfigList buildConfigList = client.buildConfigs().list();
  assertEquals(1, buildConfigList.getItems().size());
}
 
Example #2
Source File: ListBuildConfigs.java    From kubernetes-client with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
  try {
    OpenShiftClient client = new DefaultOpenShiftClient();
    if (!client.supportsOpenShiftAPIGroup(OpenShiftAPIGroups.BUILD)) {
      System.out.println("WARNING this cluster does not support the API Group " + OpenShiftAPIGroups.BUILD);
      return;
    }
    BuildConfigList list = client.buildConfigs().list();
    if (list == null) {
      System.out.println("ERROR no list returned!");
      return;
    }
    List<BuildConfig> items = list.getItems();
    for (BuildConfig item : items) {
      System.out.println("BuildConfig " + item.getMetadata().getName() + " has version: " + item.getApiVersion());
    }
  } catch (KubernetesClientException e) {
    System.out.println("Failed: " + e);
    e.printStackTrace();
  }
}
 
Example #3
Source File: BuildConfigOperationsImpl.java    From kubernetes-client with Apache License 2.0 6 votes vote down vote up
public BuildConfigOperationsImpl(BuildConfigOperationContext context) {
  super(context.withApiGroupName(BUILD)
    .withPlural("buildconfigs"));

  this.type = BuildConfig.class;
  this.listType = BuildConfigList.class;
  this.doneableType = DoneableBuildConfig.class;

  this.triggerType = context.getTriggerType();
  this.secret = context.getSecret();
  this.authorName = context.getAuthorName();
  this.authorEmail = context.getAuthorEmail() ;
  this.committerName = context.getCommitterName();
  this.committerEmail = context.getCommitterEmail();
  this.commit = context.getCommit();
  this.message = context.getMessage();
  this.asFile = context.getAsFile();
  this.timeout = context.getTimeout();
  this.timeoutUnit = context.getTimeoutUnit();
}
 
Example #4
Source File: BuildConfigTest.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
@Test
public void testList() {
 server.expect().withPath("/apis/build.openshift.io/v1/namespaces/test/buildconfigs").andReturn(200, new BuildConfigListBuilder().build()).once();

 server.expect().withPath("/apis").andReturn(200, new APIGroupListBuilder()
    .addNewGroup()
    .withApiVersion("v1")
    .withName("autoscaling.k8s.io")
    .endGroup()
    .addNewGroup()
    .withApiVersion("v1")
    .withName("security.openshift.io")
    .endGroup()
    .build()).always();

 server.expect().withPath("/apis/build.openshift.io/v1/namespaces/ns1/buildconfigs").andReturn(200, new BuildConfigListBuilder()
    .addNewItem().and()
    .addNewItem().and().build()).once();

 server.expect().withPath("/apis/build.openshift.io/v1/buildconfigs").andReturn(200, new BuildConfigListBuilder()
    .addNewItem().and()
    .addNewItem().and()
    .addNewItem()
    .and().build()).once();

  OpenShiftClient client = server.getOpenshiftClient();

  BuildConfigList buildConfigList = client.buildConfigs().list();
  assertNotNull(buildConfigList);
  assertEquals(0, buildConfigList.getItems().size());

  buildConfigList = client.buildConfigs().inNamespace("ns1").list();
  assertNotNull(buildConfigList);
  assertEquals(2, buildConfigList.getItems().size());

  buildConfigList = client.buildConfigs().inAnyNamespace().list();
  assertNotNull(buildConfigList);
  assertEquals(3, buildConfigList.getItems().size());
}
 
Example #5
Source File: SupportUtilTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Test
public void createSupportZipFileTest() throws IOException {
    final NamespacedOpenShiftClient client = mock(NamespacedOpenShiftClient.class);

    final MixedOperation<Pod, PodList, DoneablePod, PodResource<Pod, DoneablePod>> pods = mock(mixedOperationType());
    when(pods.list()).thenReturn(new PodList());

    when(client.pods()).thenReturn(pods);

    final MixedOperation<BuildConfig, BuildConfigList, DoneableBuildConfig, BuildConfigResource<BuildConfig, DoneableBuildConfig, Void, Build>> bcs = mock(
        mixedOperationType());
    when(bcs.list()).thenReturn(new BuildConfigList());

    when(client.buildConfigs()).thenReturn(bcs);

    final MixedOperation<DeploymentConfig, DeploymentConfigList, DoneableDeploymentConfig, DeployableScalableResource<DeploymentConfig, DoneableDeploymentConfig>> dcs = mock(
        mixedOperationType());
    when(dcs.list()).thenReturn(new DeploymentConfigList());

    when(client.deploymentConfigs()).thenReturn(dcs);

    final MixedOperation<ConfigMap, ConfigMapList, DoneableConfigMap, Resource<ConfigMap, DoneableConfigMap>> cm = mock(mixedOperationType());
    when(cm.list()).thenReturn(new ConfigMapList());

    when(client.configMaps()).thenReturn(cm);

    final MixedOperation<ImageStreamTag, ImageStreamTagList, DoneableImageStreamTag, Resource<ImageStreamTag, DoneableImageStreamTag>> ist = mock(
        mixedOperationType());
    final ImageStreamTagList istl = new ImageStreamTagList();
    final List<ImageStreamTag> istList = new ArrayList<>();
    final ImageStreamTag imageStreamTag = new ImageStreamTag();
    imageStreamTag.setKind("ImageStreamTag");
    final ObjectMeta objectMeta = new ObjectMeta();
    objectMeta.setName("ImageStreamTag1");
    imageStreamTag.setMetadata(objectMeta);
    istList.add(imageStreamTag);
    istl.setItems(istList);

    when(ist.list()).thenReturn(istl);

    when(client.imageStreamTags()).thenReturn(ist);

    final IntegrationHandler integrationHandler = mock(IntegrationHandler.class);
    when(integrationHandler.list(anyInt(), anyInt())).thenReturn(new EmptyListResult<IntegrationOverview>());
    final IntegrationSupportHandler integrationSupportHandler = mock(IntegrationSupportHandler.class);

    final Logger log = mock(Logger.class);
    final SupportUtil supportUtil = new SupportUtil(client, integrationHandler, integrationSupportHandler, log);

    final Map<String, Boolean> configurationMap = new HashMap<>(ImmutableMap.of("int1", true, "int2", true));

    final File output = supportUtil.createSupportZipFile(configurationMap, 1, 20);

    try (final ZipFile zip = new ZipFile(output)) {
        final ZipEntry imageStreamTag1 = zip.getEntry("descriptors/ImageStreamTag/ImageStreamTag1.YAML");
        assertThat(imageStreamTag1).isNotNull();
        AssertionsForClassTypes.assertThat(zip.getInputStream(imageStreamTag1)).hasContent(SupportUtil.YAML.dump(imageStreamTag));
    }

    verify(log).info("Created Support file: {}", output);
    // tests that we haven't logged any error messages
    verifyZeroInteractions(log);
}
 
Example #6
Source File: BuildConfigOperator.java    From strimzi-kafka-operator with Apache License 2.0 4 votes vote down vote up
@Override
protected MixedOperation<BuildConfig, BuildConfigList, DoneableBuildConfig, BuildConfigResource<BuildConfig, DoneableBuildConfig, Void, Build>> operation() {
    return client.buildConfigs();
}
 
Example #7
Source File: BuildConfigIT.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Test
public void list() {
  BuildConfigList bcList = client.buildConfigs().inNamespace(currentNamespace).list();
  assertThat(bcList).isNotNull();
  assertEquals(1, bcList.getItems().size());
}
 
Example #8
Source File: DefaultOpenShiftClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public MixedOperation<BuildConfig, BuildConfigList, DoneableBuildConfig, BuildConfigResource<BuildConfig, DoneableBuildConfig, Void, Build>> buildConfigs() {
  return new BuildConfigOperationsImpl(httpClient, OpenShiftConfig.wrap(getConfiguration()));
}