Skip to content

Commit

Permalink
merge imagestreamtag list on patch
Browse files Browse the repository at this point in the history
  • Loading branch information
bparees committed Oct 30, 2017
1 parent ce78d7a commit e4fd2ca
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 5 deletions.

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"`
}

// 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
// +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
12 changes: 11 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,14 @@ 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_test '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_test 'oc get is ruby -o jsonpath={.spec.tags[*].name}' '2.0 2.2 2.3 2.4 latest newtag'
os::cmd::expect_success 'oc delete project mergetags'
echo "apply new imagestream tags: ok"
os::test::junit::declare_suite_end

os::test::junit::declare_suite_end

0 comments on commit e4fd2ca

Please sign in to comment.