use of io.kubernetes.client.openapi.models.V1ConfigMap in project heron by twitter.
the class V1ControllerTest method testDisablePodTemplates.
@Test
public void testDisablePodTemplates() {
// ConfigMap with valid Pod Template.
V1ConfigMap configMapValidPod = new V1ConfigMapBuilder().withNewMetadata().withName(CONFIGMAP_NAME).endMetadata().addToData(POD_TEMPLATE_NAME, POD_TEMPLATE_VALID).build();
final String expected = "Pod Templates are disabled";
String message = "";
doReturn(configMapValidPod).when(v1ControllerPodTemplate).getConfigMap(anyString());
try {
v1ControllerPodTemplate.loadPodFromTemplate(true);
} catch (TopologySubmissionException e) {
message = e.getMessage();
}
Assert.assertTrue(message.contains(expected));
}
use of io.kubernetes.client.openapi.models.V1ConfigMap in project java by kubernetes-client.
the class KubectlApplyTest method testApplyConfigMap.
@Test
public void testApplyConfigMap() throws KubectlException, IOException {
wireMockRule.stubFor(patch(urlPathEqualTo("/api/v1/namespaces/foo/configmaps/bar")).withHeader("Content-Type", new EqualToPattern(V1Patch.PATCH_FORMAT_APPLY_YAML)).willReturn(aResponse().withStatus(200).withBody("{\"metadata\":{\"name\":\"bar\",\"namespace\":\"foo\"}}")));
wireMockRule.stubFor(get(urlPathEqualTo("/api")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(DISCOVERY_API))))));
wireMockRule.stubFor(get(urlPathEqualTo("/apis")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(DISCOVERY_APIS))))));
wireMockRule.stubFor(get(urlPathEqualTo("/api/v1")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(DISCOVERY_APIV1))))));
V1ConfigMap configMap = Kubectl.apply(V1ConfigMap.class).apiClient(apiClient).resource(new V1ConfigMap().apiVersion("v1").metadata(new V1ObjectMeta().namespace("foo").name("bar")).data(new HashMap<String, String>() {
{
put("key1", "value1");
}
})).execute();
wireMockRule.verify(1, patchRequestedFor(urlPathEqualTo("/api/v1/namespaces/foo/configmaps/bar")));
assertNotNull(configMap);
}
use of io.kubernetes.client.openapi.models.V1ConfigMap in project java by kubernetes-client.
the class KubectlCreateTest method testCreateConfigMap.
@Test
public void testCreateConfigMap() throws KubectlException, IOException {
wireMockRule.stubFor(post(urlPathEqualTo("/api/v1/namespaces/foo/configmaps")).willReturn(aResponse().withStatus(200).withBody("{\"metadata\":{\"name\":\"bar\",\"namespace\":\"foo\"}}")));
wireMockRule.stubFor(get(urlPathEqualTo("/api")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(DISCOVERY_API))))));
wireMockRule.stubFor(get(urlPathEqualTo("/apis")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(DISCOVERY_APIS))))));
wireMockRule.stubFor(get(urlPathEqualTo("/api/v1")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(DISCOVERY_APIV1))))));
V1ConfigMap configMap = (V1ConfigMap) Kubectl.create(V1ConfigMap.class).apiClient(apiClient).resource(new V1ConfigMap().apiVersion("v1").metadata(new V1ObjectMeta().namespace("foo").name("bar")).data(new HashMap<String, String>() {
{
put("key1", "value1");
}
})).execute();
wireMockRule.verify(1, postRequestedFor(urlPathEqualTo("/api/v1/namespaces/foo/configmaps")));
assertNotNull(configMap);
}
use of io.kubernetes.client.openapi.models.V1ConfigMap in project java by kubernetes-client.
the class KubectlPatchTest method testPatchConfigMap.
@Test
public void testPatchConfigMap() throws KubectlException, IOException {
wireMockRule.stubFor(patch(urlPathEqualTo("/api/v1/namespaces/foo/configmaps/bar")).withHeader("Content-Type", new EqualToPattern(V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH)).willReturn(aResponse().withStatus(200).withBody("{\"metadata\":{\"name\":\"bar\",\"namespace\":\"foo\"}}")));
wireMockRule.stubFor(get(urlPathEqualTo("/api")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(DISCOVERY_API))))));
wireMockRule.stubFor(get(urlPathEqualTo("/apis")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(DISCOVERY_APIS))))));
wireMockRule.stubFor(get(urlPathEqualTo("/api/v1")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(DISCOVERY_APIV1))))));
V1ConfigMap configMap = Kubectl.patch(V1ConfigMap.class).namespace("foo").name("bar").patchType(V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH).patchContent(new V1Patch("{\"data\":{\"key\":\"value\"}}")).apiClient(apiClient).execute();
wireMockRule.verify(1, patchRequestedFor(urlPathEqualTo("/api/v1/namespaces/foo/configmaps/bar")));
assertNotNull(configMap);
}
use of io.kubernetes.client.openapi.models.V1ConfigMap in project java by kubernetes-client.
the class CoreV1Api method patchNamespacedConfigMapWithHttpInfo.
/**
* partially update the specified ConfigMap
*
* @param name name of the ConfigMap (required)
* @param namespace object name and auth scope, such as for teams and projects (required)
* @param body (required)
* @param pretty If 'true', then the output is pretty printed. (optional)
* @param dryRun When present, indicates that modifications should not be persisted. An invalid or
* unrecognized dryRun directive will result in an error response and no further processing of
* the request. Valid values are: - All: all dry run stages will be processed (optional)
* @param fieldManager fieldManager is a name associated with the actor or entity that is making
* these changes. The value must be less than or 128 characters long, and only contain
* printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint. This field is
* required for apply requests (application/apply-patch) but optional for non-apply patch
* types (JsonPatch, MergePatch, StrategicMergePatch). (optional)
* @param fieldValidation fieldValidation determines how the server should respond to
* unknown/duplicate fields in the object in the request. Introduced as alpha in 1.23, older
* servers or servers with the `ServerSideFieldValidation` feature disabled will
* discard valid values specified in this param and not perform any server side field
* validation. Valid values are: - Ignore: ignores unknown/duplicate fields. - Warn: responds
* with a warning for each unknown/duplicate field, but successfully serves the request. -
* Strict: fails the request on unknown/duplicate fields. (optional)
* @param force Force is going to \"force\" Apply requests. It means user will
* re-acquire conflicting fields owned by other people. Force flag must be unset for non-apply
* patch requests. (optional)
* @return ApiResponse<V1ConfigMap>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the
* response body
* @http.response.details
* <table summary="Response Details" border="1">
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
* <tr><td> 200 </td><td> OK </td><td> - </td></tr>
* <tr><td> 201 </td><td> Created </td><td> - </td></tr>
* <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
* </table>
*/
public ApiResponse<V1ConfigMap> patchNamespacedConfigMapWithHttpInfo(String name, String namespace, V1Patch body, String pretty, String dryRun, String fieldManager, String fieldValidation, Boolean force) throws ApiException {
okhttp3.Call localVarCall = patchNamespacedConfigMapValidateBeforeCall(name, namespace, body, pretty, dryRun, fieldManager, fieldValidation, force, null);
Type localVarReturnType = new TypeToken<V1ConfigMap>() {
}.getType();
return localVarApiClient.execute(localVarCall, localVarReturnType);
}
Aggregations