Skip to content

Commit 1b8086c

Browse files
committed
merge imagestreamtag list on patch
1 parent ce78d7a commit 1b8086c

File tree

7 files changed

+82
-5
lines changed

7 files changed

+82
-5
lines changed

Diff for: api/protobuf-spec/github.com_openshift_origin_pkg_image_apis_image_v1.proto

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

Diff for: api/swagger-spec/openshift-openapi-spec.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -90333,7 +90333,9 @@
9033390333
"type": "array",
9033490334
"items": {
9033590335
"$ref": "#/definitions/com.github.openshift.origin.pkg.image.apis.image.v1.TagReference"
90336-
}
90336+
},
90337+
"x-kubernetes-patch-merge-key": "name",
90338+
"x-kubernetes-patch-strategy": "merge"
9033790339
}
9033890340
}
9033990341
},
@@ -90356,7 +90358,9 @@
9035690358
"type": "array",
9035790359
"items": {
9035890360
"$ref": "#/definitions/com.github.openshift.origin.pkg.image.apis.image.v1.NamedTagEventList"
90359-
}
90361+
},
90362+
"x-kubernetes-patch-merge-key": "tag",
90363+
"x-kubernetes-patch-strategy": "merge"
9036090364
}
9036190365
}
9036290366
},

Diff for: pkg/image/apis/image/v1/generated.proto

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

Diff for: pkg/image/apis/image/v1/types.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ type ImageStreamSpec struct {
184184
// Specify the source for the tags to be imported in each tag via the spec.tags.from reference instead.
185185
DockerImageRepository string `json:"dockerImageRepository,omitempty" protobuf:"bytes,1,opt,name=dockerImageRepository"`
186186
// tags map arbitrary string values to specific image locators
187-
Tags []TagReference `json:"tags,omitempty" protobuf:"bytes,2,rep,name=tags"`
187+
// +patchMergeKey=name
188+
// +patchStrategy=merge
189+
Tags []TagReference `json:"tags,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,2,rep,name=tags"`
188190
}
189191

190192
// ImageLookupPolicy describes how an image stream can be used to override the image references
@@ -272,7 +274,9 @@ type ImageStreamStatus struct {
272274
PublicDockerImageRepository string `json:"publicDockerImageRepository,omitempty" protobuf:"bytes,3,opt,name=publicDockerImageRepository"`
273275
// Tags are a historical record of images associated with each tag. The first entry in the
274276
// TagEvent array is the currently tagged image.
275-
Tags []NamedTagEventList `json:"tags,omitempty" protobuf:"bytes,2,rep,name=tags"`
277+
// +patchMergeKey=tag
278+
// +patchStrategy=merge
279+
Tags []NamedTagEventList `json:"tags,omitempty" patchStrategy:"merge" patchMergeKey:"tag" protobuf:"bytes,2,rep,name=tags"`
276280
}
277281

278282
// NamedTagEventList relates a tag to its image history.

Diff for: pkg/openapi/zz_generated.openapi.go

+12
Original file line numberDiff line numberDiff line change
@@ -6136,6 +6136,12 @@ func GetOpenAPIDefinitions(ref openapi.ReferenceCallback) map[string]openapi.Ope
61366136
},
61376137
},
61386138
"tags": {
6139+
VendorExtensible: spec.VendorExtensible{
6140+
Extensions: spec.Extensions{
6141+
"x-kubernetes-patch-merge-key": "name",
6142+
"x-kubernetes-patch-strategy": "merge",
6143+
},
6144+
},
61396145
SchemaProps: spec.SchemaProps{
61406146
Description: "tags map arbitrary string values to specific image locators",
61416147
Type: []string{"array"},
@@ -6174,6 +6180,12 @@ func GetOpenAPIDefinitions(ref openapi.ReferenceCallback) map[string]openapi.Ope
61746180
},
61756181
},
61766182
"tags": {
6183+
VendorExtensible: spec.VendorExtensible{
6184+
Extensions: spec.Extensions{
6185+
"x-kubernetes-patch-merge-key": "tag",
6186+
"x-kubernetes-patch-strategy": "merge",
6187+
},
6188+
},
61776189
SchemaProps: spec.SchemaProps{
61786190
Description: "Tags are a historical record of images associated with each tag. The first entry in the TagEvent array is the currently tagged image.",
61796191
Type: []string{"array"},

Diff for: test/cmd/images.sh

+12-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trap os::test::junit::reconcile_output EXIT
99
os::cmd::expect_success 'oc login -u system:admin'
1010
cluster_admin_context="$( oc config current-context )"
1111
os::cmd::expect_success "oc config use-context '${original_context}'"
12-
oc delete project test-cmd-images-2 --context=${cluster_admin_context}
12+
oc delete project test-cmd-images-2 merge-tags --context=${cluster_admin_context}
1313
oc delete all,templates --all --context=${cluster_admin_context}
1414

1515
exit 0
@@ -292,4 +292,15 @@ os::cmd::expect_success 'oc delete all --all'
292292
echo "delete istag: ok"
293293
os::test::junit::declare_suite_end
294294

295+
os::test::junit::declare_suite_start "cmd/images${IMAGES_TESTS_POSTFIX:-}/merge-tags-on-apply"
296+
os::cmd::expect_success 'oc new-project merge-tags'
297+
os::cmd::expect_success 'oc create -f examples/image-streams/image-streams-centos7.json'
298+
os::cmd::expect_success_and_text 'oc get is ruby -o jsonpath={.spec.tags[*].name}' '2.0 2.2 2.3 2.4 latest'
299+
os::cmd::expect_success 'oc apply -f test/testdata/images/modified-ruby-imagestream.json'
300+
os::cmd::expect_success_and_text 'oc get is ruby -o jsonpath={.spec.tags[*].name}' '2.0 2.2 2.3 2.4 latest newtag'
301+
os::cmd::expect_success_and_text 'oc get is ruby -o jsonpath={.spec.tags[3].annotations.version}' '2.4 patched'
302+
os::cmd::expect_success 'oc delete project merge-tags'
303+
echo "apply new imagestream tags: ok"
304+
os::test::junit::declare_suite_end
305+
295306
os::test::junit::declare_suite_end

Diff for: test/testdata/images/modified-ruby-imagestream.json

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"kind": "ImageStream",
3+
"apiVersion": "v1",
4+
"metadata": {
5+
"name": "ruby",
6+
"annotations": {
7+
"openshift.io/display-name": "Ruby"
8+
}
9+
},
10+
"spec": {
11+
"tags": [
12+
{
13+
"name": "2.4",
14+
"annotations": {
15+
"openshift.io/display-name": "Ruby Patched",
16+
"openshift.io/provider-display-name": "Red Hat, Inc.",
17+
"description": "Build and run Ruby 2.4 applications on CentOS 7. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-ruby-container/blob/master/2.4/README.md.",
18+
"iconClass": "icon-ruby",
19+
"tags": "builder,ruby",
20+
"supports": "ruby:2.4,ruby",
21+
"version": "2.4 patched",
22+
"sampleRepo": "https://github.com/openshift/ruby-ex.git"
23+
},
24+
"from": {
25+
"kind": "DockerImage",
26+
"name": "centos/ruby-24-centos7:latest"
27+
}
28+
},
29+
{
30+
"name": "newtag",
31+
"from": {
32+
"kind": "DockerImage",
33+
"name": "centos/ruby-24-centos7:latest"
34+
}
35+
}
36+
]
37+
}
38+
}

0 commit comments

Comments
 (0)