Skip to content

Commit 3712aec

Browse files
author
OpenShift Bot
authored
Merge pull request #11874 from fabianofranz/bugs_1393230
Merged by openshift-bot
2 parents 6ea6f53 + d5280d0 commit 3712aec

File tree

4 files changed

+117
-15
lines changed

4 files changed

+117
-15
lines changed

Diff for: test/cmd/convert.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
set -o nounset
5+
set -o pipefail
6+
7+
OS_ROOT=$(dirname "${BASH_SOURCE}")/../..
8+
source "${OS_ROOT}/hack/lib/init.sh"
9+
os::log::stacktrace::install
10+
trap os::test::junit::reconcile_output EXIT
11+
12+
# Cleanup cluster resources created by this test
13+
(
14+
set +e
15+
oc delete all --all
16+
exit 0
17+
) &>/dev/null
18+
19+
os::test::junit::declare_suite_start "cmd/convert"
20+
# This test validates the convert command
21+
22+
os::cmd::expect_success "oc convert -f test/testdata/convert/job-v1.yaml | grep 'apiVersion: batch/v1'"
23+
os::cmd::expect_success "oc convert -f test/testdata/convert/job-v2.json | grep 'apiVersion: batch/v2alpha1'"
24+
25+
os::cmd::expect_success "oc convert -f test/testdata/convert/job-v1.yaml --output-version=batch/v2alpha1 | grep 'apiVersion: batch/v2alpha1'"
26+
os::cmd::expect_failure "oc convert -f test/testdata/convert/job-v1.yaml --output-version=batch/v2alpha1 | grep 'apiVersion: batch/v1'"
27+
28+
os::cmd::expect_success "oc convert -f test/testdata/convert --output-version=batch/v2alpha1 | grep 'apiVersion: batch/v2alpha1'"
29+
os::cmd::expect_failure "oc convert -f test/testdata/convert --output-version=batch/v2alpha1 | grep 'apiVersion: batch/v1'"
30+
31+
os::cmd::expect_success_and_text "oc convert -f test/testdata/convert | oc create --dry-run -f -" 'job "pi" created'
32+
os::cmd::expect_success_and_text "oc convert -f test/testdata/convert | oc create --dry-run -f -" 'scheduledjob "hello" created'
33+
34+
echo "convert: ok"
35+
os::test::junit::declare_suite_end

Diff for: test/testdata/convert/job-v1.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: pi
5+
spec:
6+
template:
7+
metadata:
8+
name: pi
9+
spec:
10+
containers:
11+
- name: pi
12+
image: perl
13+
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
14+
restartPolicy: Never

Diff for: test/testdata/convert/job-v2.json

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"kind": "ScheduledJob",
3+
"apiVersion": "batch/v2alpha1",
4+
"metadata": {
5+
"name": "hello",
6+
"creationTimestamp": null
7+
},
8+
"spec": {
9+
"schedule": "0/1 * * * ?",
10+
"concurrencyPolicy": "Allow",
11+
"suspend": false,
12+
"jobTemplate": {
13+
"metadata": {
14+
"creationTimestamp": null
15+
},
16+
"spec": {
17+
"template": {
18+
"metadata": {
19+
"creationTimestamp": null
20+
},
21+
"spec": {
22+
"containers": [
23+
{
24+
"name": "hello",
25+
"image": "busybox",
26+
"args": [
27+
"/bin/sh",
28+
"-c",
29+
"date; echo Hello from the Kubernetes cluster"
30+
],
31+
"resources": {},
32+
"terminationMessagePath": "/dev/termination-log",
33+
"imagePullPolicy": "Always"
34+
}
35+
],
36+
"restartPolicy": "OnFailure",
37+
"terminationGracePeriodSeconds": 30,
38+
"dnsPolicy": "ClusterFirst",
39+
"securityContext": {}
40+
}
41+
}
42+
}
43+
}
44+
},
45+
"status": {}
46+
}

Diff for: vendor/k8s.io/kubernetes/pkg/kubectl/cmd/convert.go

+22-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)