|
| 1 | +/* |
| 2 | +Copyright 2020 The Kubernetes Authors. |
| 3 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +you may not use this file except in compliance with the License. |
| 5 | +You may obtain a copy of the License at |
| 6 | +http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +Unless required by applicable law or agreed to in writing, software |
| 8 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | +See the License for the specific language governing permissions and |
| 11 | +limitations under the License. |
| 12 | +*/ |
| 13 | +package io.kubernetes.client.extended.kubectl; |
| 14 | + |
| 15 | +import io.kubernetes.client.common.KubernetesListObject; |
| 16 | +import io.kubernetes.client.common.KubernetesObject; |
| 17 | +import io.kubernetes.client.custom.V1Patch; |
| 18 | +import io.kubernetes.client.util.generic.GenericKubernetesApi; |
| 19 | + |
| 20 | +public class KubectlPatch<ApiType extends KubernetesObject> |
| 21 | + extends Kubectl.ResourceBuilder<ApiType, KubectlPatch<ApiType>> |
| 22 | + implements Kubectl.Executable<ApiType> { |
| 23 | + |
| 24 | + private Class<ApiType> apiTypeClass; |
| 25 | + private Class<KubernetesListObject> apiListTypeClass; |
| 26 | + private V1Patch patchContent; |
| 27 | + |
| 28 | + KubectlPatch(Class<ApiType> apiTypeClass) { |
| 29 | + super(apiTypeClass); |
| 30 | + } |
| 31 | + |
| 32 | + public KubectlPatch patchContent(V1Patch patchContent) { |
| 33 | + this.patchContent = patchContent; |
| 34 | + return this; |
| 35 | + } |
| 36 | + |
| 37 | + @Override |
| 38 | + public ApiType execute() { |
| 39 | + GenericKubernetesApi genericKubernetesApi = getGenericApi(); |
| 40 | + return (ApiType) genericKubernetesApi.patch(namespace, name, patchContent); |
| 41 | + } |
| 42 | +} |
0 commit comments