Skip to content

Commit

Permalink
fix(service): Consumes and Produces of descriptor should affect curre…
Browse files Browse the repository at this point in the history
…nt definitions (#201)

Automatic merge from submit-queue.

fix(service): Consumes and Produces of descriptor should affect current definitions

**What this PR does / why we need it**:

Descriptor's Consumes and Produces can't impact its definitions.

**Which issue(s) this PR fixes** *(optional, close the issue(s) when PR gets merged)*:

Fixes #

**Special notes for your reviewer**:

/cc @yejiayu 

**Release note**:


```release-note
NONE
```

<!--  Thanks for sending a pull request! Here are some tips:

1. https://github.com/caicloud/engineering/blob/master/docs/review_conventions.md  <-- what is the review process looks like
2. https://github.com/caicloud/engineering/blob/master/docs/commit_conventions.md  <-- how to structure your git commit
3. https://github.com/caicloud/engineering/blob/master/docs/caicloud_bot.md        <-- how to work with caicloud bot

Other tips from Kubernetes cmomunity:

1. If this is your first time, read our contributor guidelines https://git.k8s.io/community/contributors/devel/pull-requests.md#the-pr-submit-process and developer guide https://git.k8s.io/community/contributors/devel/development.md#development-guide
2. If you want *faster* PR reviews, read how: https://git.k8s.io/community/contributors/devel/pull-requests.md#best-practices-for-faster-reviews
3. Follow the instructions for writing a release note: https://git.k8s.io/community/contributors/devel/pull-requests.md#write-release-notes-if-needed
4. If the PR is unfinished, see how to mark it: https://github.com/kubernetes/community/blob/master/contributors/devel/pull-requests.md#marking-unfinished-pull-requests
-->
  • Loading branch information
kdada authored and caicloud-bot committed Apr 11, 2018
1 parent 21dc908 commit 6472fdd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions service/builder.go
Expand Up @@ -89,6 +89,12 @@ func (b *builder) AddDescriptor(descriptors ...definition.Descriptor) error {

func (b *builder) addDescriptor(prefix string, consumes []string, produces []string, descriptor definition.Descriptor) {
path := strings.Join([]string{prefix, strings.Trim(descriptor.Path, "/")}, "/")
if descriptor.Consumes != nil {
consumes = descriptor.Consumes
}
if descriptor.Produces != nil {
produces = descriptor.Produces
}
if len(descriptor.Middlewares) > 0 || len(descriptor.Definitions) > 0 {
bd, ok := b.bindings[path]
if !ok {
Expand All @@ -110,12 +116,6 @@ func (b *builder) addDescriptor(prefix string, consumes []string, produces []str
}
}
}
if descriptor.Consumes != nil {
consumes = descriptor.Consumes
}
if descriptor.Produces != nil {
produces = descriptor.Produces
}
for _, child := range descriptor.Children {
b.addDescriptor(strings.TrimRight(path, "/"), consumes, produces, child)
}
Expand Down

0 comments on commit 6472fdd

Please sign in to comment.