@@ -0,0 +1,2601 @@
+package io.kubernetes.client.util.conversion;%0A%0Aimport io.kubernetes.client.openapi.models.V1Job;%0Aimport io.kubernetes.client.openapi.models.V1JobSpec;%0Aimport io.kubernetes.client.openapi.models.V1ObjectMeta;%0Aimport io.kubernetes.client.openapi.models.V1OwnerReference;%0Aimport io.kubernetes.client.openapi.models.V1beta1CronJob;%0Aimport io.kubernetes.client.openapi.models.V1beta1CronJobSpec;%0A%0Aimport java.util.Arrays;%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Apublic class Jobs %7B%0A%0A%0A    /**%0A     * Convert V1beta1CronJob object into V1Job object, based on kubectl code https://github.com/kubernetes/kubectl/blob/master/pkg/cmd/create/create_job.go%0A     * @param cronJob cronJob object (required)%0A     * @param jobName cronJob name%0A     * @return V1Job object%0A     */%0A    public static V1Job cronJobToJob(V1beta1CronJob cronJob, String jobName) %7B%0A%0A        Map%3CString, String%3E annotations = new HashMap%3C%3E();%0A        Map%3CString, String%3E labels  = new HashMap%3C%3E();%0A        V1JobSpec jobSpec = null;%0A%0A        V1beta1CronJobSpec cronJobSpec = cronJob.getSpec();%0A%0A        if (cronJobSpec != null && cronJobSpec.getJobTemplate() != null) %7B%0A            V1ObjectMeta metadata = cronJobSpec.getJobTemplate().getMetadata();%0A            if (metadata != null)%7B%0A                if (metadata.getAnnotations() != null) %7B%0A                    annotations.putAll(metadata.getAnnotations());%0A                %7D%0A                if (metadata.getLabels() != null) %7B%0A                    labels.putAll(metadata.getLabels());%0A                %7D%0A            %7D%0A            jobSpec = cronJobSpec.getJobTemplate().getSpec();%0A        %7D%0A%0A        annotations.put(%22cronjob.kubernetes.io/instantiate%22, %22manual%22);%0A%0A        V1OwnerReference v1OwnerReference = new V1OwnerReference();%0A        v1OwnerReference.setKind(%22CronJob%22);%0A        v1OwnerReference.setName(cronJob.getMetadata().getName());%0A        v1OwnerReference.setBlockOwnerDeletion(true);%0A        v1OwnerReference.setController(true);%0A        v1OwnerReference.setUid(cronJob.getMetadata().getUid());%0A        v1OwnerReference.setApiVersion(%22batch/v1beta1%22);%0A%0A        V1ObjectMeta jobMetadata = new V1ObjectMeta();%0A        jobMetadata.setName(jobName != null ? jobName : cronJob.getMetadata().getName() + %22-manual%22);%0A        jobMetadata.setAnnotations(annotations);%0A        jobMetadata.setLabels(labels);%0A        jobMetadata.setOwnerReferences(Arrays.asList(v1OwnerReference));%0A%0A        V1Job job = new V1Job();%0A        job.setKind(%22Job%22);%0A        job.setApiVersion(%22batch/v1%22);%0A        job.setMetadata(jobMetadata);%0A        job.setSpec(jobSpec);%0A%0A        return job;%0A    %7D%0A%0A%7D%0A

Convert cron job to job