Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge imagestreamtag list on patch #17091

Merged
merged 1 commit into from
Nov 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions api/swagger-spec/openshift-openapi-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -90333,7 +90333,9 @@
"type": "array",
"items": {
"$ref": "#/definitions/com.github.openshift.origin.pkg.image.apis.image.v1.TagReference"
}
},
"x-kubernetes-patch-merge-key": "name",
"x-kubernetes-patch-strategy": "merge"
}
}
},
Expand All @@ -90356,7 +90358,9 @@
"type": "array",
"items": {
"$ref": "#/definitions/com.github.openshift.origin.pkg.image.apis.image.v1.NamedTagEventList"
}
},
"x-kubernetes-patch-merge-key": "tag",
"x-kubernetes-patch-strategy": "merge"
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions pkg/image/apis/image/v1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions pkg/image/apis/image/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ type ImageStreamSpec struct {
// Specify the source for the tags to be imported in each tag via the spec.tags.from reference instead.
DockerImageRepository string `json:"dockerImageRepository,omitempty" protobuf:"bytes,1,opt,name=dockerImageRepository"`
// tags map arbitrary string values to specific image locators
Tags []TagReference `json:"tags,omitempty" protobuf:"bytes,2,rep,name=tags"`
// +patchMergeKey=name
// +patchStrategy=merge
Tags []TagReference `json:"tags,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,2,rep,name=tags"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test to test-cmd that verifies this merges correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test to test-cmd that verifies this merges correctly?

Turns out, that was a really good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to encourage him...

}

// ImageLookupPolicy describes how an image stream can be used to override the image references
Expand Down Expand Up @@ -272,7 +274,9 @@ type ImageStreamStatus struct {
PublicDockerImageRepository string `json:"publicDockerImageRepository,omitempty" protobuf:"bytes,3,opt,name=publicDockerImageRepository"`
// Tags are a historical record of images associated with each tag. The first entry in the
// TagEvent array is the currently tagged image.
Tags []NamedTagEventList `json:"tags,omitempty" protobuf:"bytes,2,rep,name=tags"`
// +patchMergeKey=tag
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, that explains my issues. API changes after openshift/api was made :(

// +patchStrategy=merge
Tags []NamedTagEventList `json:"tags,omitempty" patchStrategy:"merge" patchMergeKey:"tag" protobuf:"bytes,2,rep,name=tags"`
}

// NamedTagEventList relates a tag to its image history.
Expand Down
12 changes: 12 additions & 0 deletions pkg/openapi/zz_generated.openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -6136,6 +6136,12 @@ func GetOpenAPIDefinitions(ref openapi.ReferenceCallback) map[string]openapi.Ope
},
},
"tags": {
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
"x-kubernetes-patch-merge-key": "name",
"x-kubernetes-patch-strategy": "merge",
},
},
SchemaProps: spec.SchemaProps{
Description: "tags map arbitrary string values to specific image locators",
Type: []string{"array"},
Expand Down Expand Up @@ -6174,6 +6180,12 @@ func GetOpenAPIDefinitions(ref openapi.ReferenceCallback) map[string]openapi.Ope
},
},
"tags": {
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
"x-kubernetes-patch-merge-key": "tag",
"x-kubernetes-patch-strategy": "merge",
},
},
SchemaProps: spec.SchemaProps{
Description: "Tags are a historical record of images associated with each tag. The first entry in the TagEvent array is the currently tagged image.",
Type: []string{"array"},
Expand Down
13 changes: 12 additions & 1 deletion test/cmd/images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trap os::test::junit::reconcile_output EXIT
os::cmd::expect_success 'oc login -u system:admin'
cluster_admin_context="$( oc config current-context )"
os::cmd::expect_success "oc config use-context '${original_context}'"
oc delete project test-cmd-images-2 --context=${cluster_admin_context}
oc delete project test-cmd-images-2 merge-tags --context=${cluster_admin_context}
oc delete all,templates --all --context=${cluster_admin_context}

exit 0
Expand Down Expand Up @@ -292,4 +292,15 @@ os::cmd::expect_success 'oc delete all --all'
echo "delete istag: ok"
os::test::junit::declare_suite_end

os::test::junit::declare_suite_start "cmd/images${IMAGES_TESTS_POSTFIX:-}/merge-tags-on-apply"
os::cmd::expect_success 'oc new-project merge-tags'
os::cmd::expect_success 'oc create -f examples/image-streams/image-streams-centos7.json'
os::cmd::expect_success_and_text 'oc get is ruby -o jsonpath={.spec.tags[*].name}' '2.0 2.2 2.3 2.4 latest'
os::cmd::expect_success 'oc apply -f test/testdata/images/modified-ruby-imagestream.json'
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'
os::cmd::expect_success_and_text 'oc get is ruby -o jsonpath={.spec.tags[3].annotations.version}' '2.4 patched'
os::cmd::expect_success 'oc delete project merge-tags'
echo "apply new imagestream tags: ok"
os::test::junit::declare_suite_end

os::test::junit::declare_suite_end
38 changes: 38 additions & 0 deletions test/testdata/images/modified-ruby-imagestream.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "ruby",
"annotations": {
"openshift.io/display-name": "Ruby"
}
},
"spec": {
"tags": [
{
"name": "2.4",
"annotations": {
"openshift.io/display-name": "Ruby Patched",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"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.",
"iconClass": "icon-ruby",
"tags": "builder,ruby",
"supports": "ruby:2.4,ruby",
"version": "2.4 patched",
"sampleRepo": "https://github.com/openshift/ruby-ex.git"
},
"from": {
"kind": "DockerImage",
"name": "centos/ruby-24-centos7:latest"
}
},
{
"name": "newtag",
"from": {
"kind": "DockerImage",
"name": "centos/ruby-24-centos7:latest"
}
}
]
}
}