Skip to content
Permalink
Browse files

fix comment

Signed-off-by: runzexia <runzexia@yunify.com>
  • Loading branch information
runzexia committed Jul 19, 2019
1 parent 338dd5a commit 149d9bddff9fde9767c18a7dc6c082ae3e9b96b2
Showing with 16 additions and 13 deletions.
  1. +16 −13 src/main/java/com/microsoft/jenkins/kubernetes/wrapper/V1ResourceManager.java
@@ -430,7 +430,7 @@ V1Job getCurrentResource() {
@Override
V1Job applyResource(V1Job original, V1Job current) {
V1Job job = null;
V1Job putJob = getPutObject(original);
V1Job putJob = getPutObject(original, current);
try {
job = batchV1ApiInstance.replaceNamespacedJob(
getName(), getNamespace(), putJob, getPretty(), null);
@@ -449,12 +449,13 @@ V1Job applyResource(V1Job original, V1Job current) {
* https://kubernetes.io/blog/2019/01/14/apiserver-dry-run-and-kubectl-diff/
*
* @param original Current Object in Cluster
* @param current Current object submitted by the user
* @return Job With Default Value
*/
V1Job getPutObject(V1Job original) {
V1Job getPutObject(V1Job original, V1Job current) {
// Clone Object to avoid modifications to the original object.
V1Job dryRunReq = KubernetesJsonUtils.getKubernetesJson().deserialize(
KubernetesJsonUtils.getKubernetesJson().serialize(get()), V1Job.class);
KubernetesJsonUtils.getKubernetesJson().serialize(current), V1Job.class);
// Build dryRun Request Object
V1Job dryRunRes = null;
dryRunReq.getMetadata().setName(null);
@@ -481,7 +482,7 @@ V1Job getPutObject(V1Job original) {
// According to
// https://github.com/kubernetes/kubernetes/blob/152b09ac550d50deeeff7162093332b4f7f0397d/pkg/registry/batch/job/strategy.go#L101
// https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/#specifying-your-own-pod-selector
if (BooleanUtils.isNotTrue(get().getSpec().isManualSelector())) {
if (BooleanUtils.isNotTrue(current.getSpec().isManualSelector())) {
String controllerUid = original.getMetadata().getLabels().get(KUBERNETES_CONTROLLER_UID_FIELD);
dryRunRes.getMetadata().getLabels().put(KUBERNETES_CONTROLLER_UID_FIELD, controllerUid);
dryRunRes.getMetadata().getLabels().put(KUBERNETES_JOB_NAME_FIELD, getName());
@@ -493,7 +494,7 @@ V1Job getPutObject(V1Job original) {
}

V1ResourceManager.recoverPodImagePullPolicy(original.getSpec().getTemplate().getSpec(),
get().getSpec().getTemplate().getSpec(),
current.getSpec().getTemplate().getSpec(),
dryRunRes.getSpec().getTemplate().getSpec());
return dryRunRes;
}
@@ -535,7 +536,7 @@ V1Pod getCurrentResource() {
@Override
V1Pod applyResource(V1Pod original, V1Pod current) {
V1Pod pod = null;
V1Pod putPod = getPutObject(original);
V1Pod putPod = getPutObject(original, current);
try {
pod = coreV1ApiInstance.replaceNamespacedPod(
getName(), getNamespace(), putPod, getPretty(), null);
@@ -554,12 +555,13 @@ V1Pod applyResource(V1Pod original, V1Pod current) {
* https://kubernetes.io/blog/2019/01/14/apiserver-dry-run-and-kubectl-diff/
*
* @param original Current Object in Cluster
* @param current Current object submitted by the user
* @return Pod With Default Value
*/
V1Pod getPutObject(V1Pod original) {
V1Pod getPutObject(V1Pod original, V1Pod current) {
// Clone Object to avoid modifications to the original object.
V1Pod dryRunReq = KubernetesJsonUtils.getKubernetesJson().deserialize(
KubernetesJsonUtils.getKubernetesJson().serialize(get()), V1Pod.class);
KubernetesJsonUtils.getKubernetesJson().serialize(current), V1Pod.class);
// Build dryRun Request Object
V1Pod dryRunRes = null;
dryRunReq.getMetadata().setName(null);
@@ -590,7 +592,7 @@ V1Pod getPutObject(V1Pod original) {

V1ResourceManager.recoverPodImagePullPolicy(
original.getSpec(),
get().getSpec(),
current.getSpec(),
dryRunRes.getSpec());

return dryRunRes;
@@ -831,7 +833,7 @@ V1StatefulSet getCurrentResource() {
V1StatefulSet applyResource(V1StatefulSet original, V1StatefulSet current) {
V1StatefulSet result = null;
try {
V1StatefulSet putStatefulSet = getPutObject(original);
V1StatefulSet putStatefulSet = getPutObject(original, current);
result = appsV1ApiInstance.replaceNamespacedStatefulSet(
getName(), getNamespace(), putStatefulSet, getPretty(), null);
} catch (ApiException e) {
@@ -860,12 +862,13 @@ V1StatefulSet createResource(V1StatefulSet current) {
* https://kubernetes.io/blog/2019/01/14/apiserver-dry-run-and-kubectl-diff/
*
* @param original Current Object in Cluster
* @param current Current object submitted by the user
* @return StatefulSet With Default Value
*/
V1StatefulSet getPutObject(V1StatefulSet original) {
V1StatefulSet getPutObject(V1StatefulSet original, V1StatefulSet current) {
// Clone Object to avoid modifications to the original object.
V1StatefulSet dryRunReq = KubernetesJsonUtils.getKubernetesJson().deserialize(
KubernetesJsonUtils.getKubernetesJson().serialize(get()), V1StatefulSet.class);
KubernetesJsonUtils.getKubernetesJson().serialize(current), V1StatefulSet.class);
// Build dryRun Request Object
V1StatefulSet dryRunRes = null;
dryRunReq.getMetadata().setName(null);
@@ -891,7 +894,7 @@ V1StatefulSet getPutObject(V1StatefulSet original) {

V1ResourceManager.recoverPodImagePullPolicy(
original.getSpec().getTemplate().getSpec(),
get().getSpec().getTemplate().getSpec(),
current.getSpec().getTemplate().getSpec(),
dryRunRes.getSpec().getTemplate().getSpec());

return dryRunRes;

0 comments on commit 149d9bd

Please sign in to comment.
You can’t perform that action at this time.