Skip to content

Commit e4fd2ca

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

File tree

6 files changed

+43
-5
lines changed

6 files changed

+43
-5
lines changed

api/protobuf-spec/github.com_openshift_origin_pkg_image_apis_image_v1.proto

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/swagger-spec/openshift-openapi-spec.json

Lines changed: 6 additions & 2 deletions
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
},

pkg/image/apis/image/v1/generated.proto

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/image/apis/image/v1/types.go

Lines changed: 6 additions & 2 deletions
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.

pkg/openapi/zz_generated.openapi.go

Lines changed: 12 additions & 0 deletions
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"},

test/cmd/images.sh

Lines changed: 11 additions & 1 deletion
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,14 @@ 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_test '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_test 'oc get is ruby -o jsonpath={.spec.tags[*].name}' '2.0 2.2 2.3 2.4 latest newtag'
301+
os::cmd::expect_success 'oc delete project mergetags'
302+
echo "apply new imagestream tags: ok"
303+
os::test::junit::declare_suite_end
304+
295305
os::test::junit::declare_suite_end

0 commit comments

Comments
 (0)