Skip to content

Commit c0472c8

Browse files
authored
Merge pull request #375 from APIParkLab/feature/liujian-1.9
Feature/liujian 1.9
2 parents 55f09f7 + 5f40d50 commit c0472c8

File tree

2 files changed

+39
-27
lines changed

2 files changed

+39
-27
lines changed

module/publish/iml.go

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,41 @@ func (i *imlPublishModule) getProjectRelease(ctx context.Context, projectID stri
185185
Id: projectID,
186186
Version: version,
187187
}
188+
upstreamProxyHeaders := make([]*gateway.ProxyHeader, 0)
189+
var upstreamRelease *gateway.UpstreamRelease
190+
if len(upstreamCommitIds) > 0 {
191+
upstreamCommits, err := i.upstreamService.ListCommit(ctx, upstreamCommitIds...)
192+
if err != nil {
193+
return nil, err
194+
}
195+
for _, c := range upstreamCommits {
196+
upstreamRelease = &gateway.UpstreamRelease{
197+
BasicItem: &gateway.BasicItem{
198+
ID: c.Target,
199+
Version: version,
200+
MatchLabels: map[string]string{
201+
"serviceId": projectID,
202+
},
203+
},
204+
PassHost: c.Data.PassHost,
205+
Scheme: c.Data.Scheme,
206+
Balance: c.Data.Balance,
207+
Timeout: c.Data.Timeout,
208+
Nodes: utils.SliceToSlice(c.Data.Nodes, func(n *upstream.NodeConfig) string {
209+
return fmt.Sprintf("%s weight=%d", n.Address, n.Weight)
210+
}),
211+
}
212+
213+
upstreamProxyHeaders = utils.SliceToSlice(c.Data.ProxyHeaders, func(n *upstream.ProxyHeader) *gateway.ProxyHeader {
214+
return &gateway.ProxyHeader{
215+
Key: n.Key,
216+
Value: n.Value,
217+
Opt: n.OptType,
218+
}
219+
})
220+
}
221+
r.Upstream = upstreamRelease
222+
}
188223
apis := make([]*gateway.ApiRelease, 0, len(apiInfos))
189224
hasUpstream := len(upstreamCommitIds) > 0
190225
for _, a := range apiInfos {
@@ -221,38 +256,15 @@ func (i *imlPublishModule) getProjectRelease(ctx context.Context, projectID stri
221256
Opt: h.OptType,
222257
}
223258
})
259+
apiInfo.ProxyHeaders = append(apiInfo.ProxyHeaders, upstreamProxyHeaders...)
260+
224261
apiInfo.Retry = proxy.Retry
225262
apiInfo.Timeout = proxy.Timeout
226263
}
227264
apis = append(apis, apiInfo)
228265
}
229266
r.Apis = apis
230-
var upstreamRelease *gateway.UpstreamRelease
231-
if len(upstreamCommitIds) > 0 {
232-
upstreamCommits, err := i.upstreamService.ListCommit(ctx, upstreamCommitIds...)
233-
if err != nil {
234-
return nil, err
235-
}
236-
for _, c := range upstreamCommits {
237-
upstreamRelease = &gateway.UpstreamRelease{
238-
BasicItem: &gateway.BasicItem{
239-
ID: c.Target,
240-
Version: version,
241-
MatchLabels: map[string]string{
242-
"serviceId": projectID,
243-
},
244-
},
245-
PassHost: c.Data.PassHost,
246-
Scheme: c.Data.Scheme,
247-
Balance: c.Data.Balance,
248-
Timeout: c.Data.Timeout,
249-
Nodes: utils.SliceToSlice(c.Data.Nodes, func(n *upstream.NodeConfig) string {
250-
return fmt.Sprintf("%s weight=%d", n.Address, n.Weight)
251-
}),
252-
}
253-
}
254-
r.Upstream = upstreamRelease
255-
}
267+
256268
if len(strategyCommitIds) > 0 {
257269
strategyCommits, err := i.strategyService.ListStrategyCommit(ctx, strategyCommitIds...)
258270
if err != nil {

scripts/qiniu_publish.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ echo "login qiniu..."
2222
qshell account ${AccessKey} ${SecretKey} ${QINIU_NAME}
2323

2424
echo "qshell rput ${QINIU_BUCKET} \"${APP}/images/${Tar}\" ${Tar}"
25-
qshell rput ${QINIU_BUCKET} "${APP}/images/${Tar}" ${Tar}
25+
qshell rput --overwrite ${QINIU_BUCKET} "${APP}/images/${Tar}" ${Tar}
2626

2727
rm -f ${Tar}
2828
docker rmi -f ${ImageName}:${Version}

0 commit comments

Comments
 (0)