Skip to content

Commit 2b73b6f

Browse files
authored
Merge pull request koderover#52 from koderover/release/v1.2.0
zadig team push release 1.2.0
2 parents 2a0f244 + 5a4dc56 commit 2b73b6f

File tree

393 files changed

+27076
-5489
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

393 files changed

+27076
-5489
lines changed

.dockerignore

-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,3 @@
44
!/go.mod
55
!/go.sum
66
!/zadig-portal
7-
!/third_party
8-

GOVERNANCE.md

+2
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,5 @@ The council will make a decision for the nomination. The candidate has to have d
5656
- [piao100101](https://github.com/piao100101)
5757
- [nanzm](https://github.com/nanzm)
5858
- [solomon-cc](https://github.com/solomon-cc)
59+
60+

cmd/hubagent/main.go

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Copyright 2021 The KodeRover Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package main
18+
19+
import (
20+
"log"
21+
22+
"github.com/koderover/zadig/pkg/microservice/hubagent/server"
23+
)
24+
25+
func main() {
26+
if err := server.Serve(); err != nil {
27+
log.Fatal(err)
28+
}
29+
}

pkg/tool/gitlab/client.go renamed to cmd/hubserver/main.go

+17-17
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,27 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package gitlab
17+
package main
1818

1919
import (
20-
"fmt"
20+
"context"
21+
"log"
22+
"os/signal"
23+
"syscall"
2124

22-
"github.com/xanzy/go-gitlab"
25+
"github.com/koderover/zadig/pkg/microservice/hubserver/server"
2326
)
2427

25-
type Client struct {
26-
*gitlab.Client
27-
}
28-
29-
func NewGitlabClient(address, accessToken string) (*Client, error) {
30-
cli, err := gitlab.NewOAuthClient(accessToken, gitlab.WithBaseURL(address))
31-
if err != nil {
32-
return nil, fmt.Errorf("set base url failed, err:%v", err)
28+
func main() {
29+
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGTERM, syscall.SIGINT)
30+
go func() {
31+
select {
32+
case <-ctx.Done():
33+
stop()
34+
}
35+
}()
36+
37+
if err := server.Serve(ctx); err != nil {
38+
log.Fatal(err)
3339
}
34-
35-
client := &Client{
36-
Client: cli,
37-
}
38-
39-
return client, nil
4040
}

docker/hub-agent.Dockerfile.template

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#golang-deps.Dockerfile.inc
2+
3+
RUN go build -v -o /hubagent ./cmd/hubagent/main.go
4+
5+
#alpine-base.Dockerfile.inc
6+
7+
WORKDIR /app
8+
9+
COPY --from=build /hubagent .
10+
11+
ENTRYPOINT ["/app/hubagent"]

docker/hub-server.Dockerfile.template

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#golang-deps.Dockerfile.inc
2+
3+
RUN go build -v -o /hubserver ./cmd/hubserver/main.go
4+
5+
#alpine-base.Dockerfile.inc
6+
7+
WORKDIR /app
8+
9+
COPY --from=build /hubserver .
10+
11+
ENTRYPOINT ["/app/hubserver"]

examples/website/yaml/website-example.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ spec:
1111
- port: 80
1212
selector:
1313
app: website-example
14-
tier: frontend
1514
---
1615
apiVersion: apps/v1
1716
kind: Deployment

go.mod

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ require (
1010
github.com/bshuster-repo/logrus-logstash-hook v1.0.0 // indirect
1111
github.com/bugsnag/bugsnag-go v2.1.0+incompatible // indirect
1212
github.com/bugsnag/panicwrap v1.3.1 // indirect
13+
github.com/cenkalti/backoff/v3 v3.0.0
1314
github.com/coocood/freecache v1.1.0
1415
github.com/docker/distribution v2.7.1+incompatible
1516
github.com/docker/docker v1.4.2-0.20200204220554-5f6d6f3f2203
@@ -24,14 +25,14 @@ require (
2425
github.com/go-openapi/spec v0.19.5 // indirect
2526
github.com/go-resty/resty/v2 v2.6.0
2627
github.com/gofrs/uuid v4.0.0+incompatible // indirect
27-
github.com/google/go-github/v35 v35.1.0
28+
github.com/google/go-github/v35 v35.3.0
2829
github.com/google/uuid v1.2.0
2930
github.com/gorilla/handlers v1.5.1 // indirect
3031
github.com/gorilla/mux v1.7.3
3132
github.com/gorilla/websocket v1.4.2
3233
github.com/gotestyourself/gotestyourself v2.2.0+incompatible // indirect
3334
github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f
34-
github.com/hashicorp/go-multierror v1.0.0
35+
github.com/hashicorp/go-multierror v1.1.1
3536
github.com/jasonlvhit/gocron v0.0.0-20171226191223-3c914c8681c3
3637
github.com/jinzhu/now v1.1.2
3738
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
@@ -55,7 +56,7 @@ require (
5556
github.com/swaggo/gin-swagger v1.3.0
5657
github.com/swaggo/swag v1.5.1
5758
github.com/ugorji/go v1.2.0 // indirect
58-
github.com/xanzy/go-gitlab v0.44.0
59+
github.com/xanzy/go-gitlab v0.50.0
5960
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
6061
github.com/yvasiyarov/go-metrics v0.0.0-20150112132944-c25f46c4b940 // indirect
6162
github.com/yvasiyarov/gorelic v0.0.7 // indirect

go.sum

+14-9
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ github.com/bugsnag/bugsnag-go v2.1.0+incompatible/go.mod h1:2oa8nejYd4cQ/b0hMIop
113113
github.com/bugsnag/panicwrap v1.3.1 h1:pmuhHlhbUV4OOrGDvoiMjHSZzwRcL+I9cIzYKiW4lII=
114114
github.com/bugsnag/panicwrap v1.3.1/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE=
115115
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
116+
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
116117
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
118+
github.com/cenkalti/backoff/v3 v3.0.0 h1:ske+9nBpD9qZsTBoF41nW5L+AIuFBKMeze18XQ3eG1c=
119+
github.com/cenkalti/backoff/v3 v3.0.0/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4rc0ij+ULvLYs=
117120
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
118121
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
119122
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
@@ -382,12 +385,13 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
382385
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
383386
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
384387
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
385-
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
386388
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
389+
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
390+
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
387391
github.com/google/go-github/v29 v29.0.2 h1:opYN6Wc7DOz7Ku3Oh4l7prmkOMwEcQxpFtxdU8N8Pts=
388392
github.com/google/go-github/v29 v29.0.2/go.mod h1:CHKiKKPHJ0REzfwc14QMklvtHwCveD0PxlMjLlzAM5E=
389-
github.com/google/go-github/v35 v35.1.0 h1:KkwZnKWQ/0YryvXjZlCN/3EGRJNp6VCZPKo+RG9mG28=
390-
github.com/google/go-github/v35 v35.1.0/go.mod h1:s0515YVTI+IMrDoy9Y4pHt9ShGpzHvHO8rZ7L7acgvs=
393+
github.com/google/go-github/v35 v35.3.0 h1:fU+WBzuukn0VssbayTT+Zo3/ESKX9JYWjbZTLOTEyho=
394+
github.com/google/go-github/v35 v35.3.0/go.mod h1:yWB7uCcVWaUbUP74Aq3whuMySRMatyRmq5U9FTNlbio=
391395
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
392396
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
393397
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
@@ -451,10 +455,11 @@ github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxC
451455
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
452456
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
453457
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
454-
github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o=
455458
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
456-
github.com/hashicorp/go-retryablehttp v0.6.4 h1:BbgctKO892xEyOXnGiaAwIoSq1QZ/SS4AhjoAh9DnfY=
457-
github.com/hashicorp/go-retryablehttp v0.6.4/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
459+
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
460+
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
461+
github.com/hashicorp/go-retryablehttp v0.6.8 h1:92lWxgpa+fF3FozM4B3UZtHZMJX8T5XT+TFdCxsPyWs=
462+
github.com/hashicorp/go-retryablehttp v0.6.8/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
458463
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
459464
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
460465
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
@@ -614,6 +619,7 @@ github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7P
614619
github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
615620
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
616621
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
622+
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus=
617623
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
618624
github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
619625
github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU=
@@ -830,8 +836,8 @@ github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX
830836
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
831837
github.com/willf/bitset v1.1.11-0.20200630133818-d5bec3311243 h1:R43TdZy32XXSXjJn7M/HhALJ9imq6ztLnChfYJpVDnM=
832838
github.com/willf/bitset v1.1.11-0.20200630133818-d5bec3311243/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
833-
github.com/xanzy/go-gitlab v0.44.0 h1:cEiGhqu7EpFGuei2a2etAwB+x6403E5CvpLn35y+GPs=
834-
github.com/xanzy/go-gitlab v0.44.0/go.mod h1:sPLojNBn68fMUWSxIJtdVVIP8uSBYqesTfDUseX11Ug=
839+
github.com/xanzy/go-gitlab v0.50.0 h1:t7IoYTrnLSbdEZN7d8X/5zcr+ZM4TZQ2mXa8MqWlAZQ=
840+
github.com/xanzy/go-gitlab v0.50.0/go.mod h1:Q+hQhV508bDPoBijv7YjK/Lvlb4PhVhJdKqXVQrUoAE=
835841
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c h1:u40Z8hqBAAQyv+vATcGgV0YCnDjqSL7/q/JyPhhJSPk=
836842
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I=
837843
github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc h1:n+nNi93yXLkJvKwXNP9d55HC7lGK4H/SRcwB5IaUZLo=
@@ -947,7 +953,6 @@ golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73r
947953
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
948954
golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
949955
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
950-
golang.org/x/net v0.0.0-20181108082009-03003ca0c849/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
951956
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
952957
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
953958
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=

image.Makefile

+1-9
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,7 @@ IMAGE_TAG:=$(shell ./docker/image-tag)
1212
VCS_REF:=$(shell git rev-parse HEAD)
1313
TAG ?= ${DATE}-${IMAGE_TAG}
1414

15-
BASE_TARGETS = aslan warpdrive cron podexec jenkins-plugin predator-plugin
16-
17-
18-
TARGETS =
19-
ifndef ENTERPRISE_TARGETS
20-
TARGETS = $(BASE_TARGETS)
21-
else
22-
TARGETS = $(ENTERPRISE_TARGETS)
23-
endif
15+
TARGETS = aslan warpdrive cron podexec jenkins-plugin predator-plugin hub-server hub-agent
2416

2517
ALL_IMAGES=$(TARGETS:=.image)
2618
ALL_PUSHES=$(TARGETS:=.push)

pkg/config/config.go

+12
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,15 @@ func LogFile() string {
6060
func RequestLogFile() string {
6161
return LogPath() + RequestLogName()
6262
}
63+
64+
func AslanURL() string {
65+
return viper.GetString(setting.ENVAslanURL)
66+
}
67+
68+
func PoetryAPIServer() string {
69+
return viper.GetString(setting.ENVPoetryAPIServer)
70+
}
71+
72+
func PoetryAPIRootKey() string {
73+
return viper.GetString(setting.ENVPoetryAPIRootKey)
74+
}

pkg/microservice/aslan/config/config.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package config
1818

1919
import (
2020
"errors"
21+
"fmt"
2122
"strconv"
2223
"strings"
2324

@@ -125,7 +126,7 @@ func S3StoragePath() string {
125126
}
126127

127128
func EnableGitCheck() bool {
128-
return viper.GetString(setting.EnableGitCheck) == "true"
129+
return true
129130
}
130131

131132
func S3StorageAK() string {
@@ -253,3 +254,7 @@ func SonarRootToken() string {
253254
func SonarInternalAddr() string {
254255
return viper.GetString(setting.EnvSonarInternalAddr)
255256
}
257+
258+
func WebHookURL() string {
259+
return fmt.Sprintf("%s/api/aslan/webhook", AslanURL())
260+
}

pkg/microservice/aslan/core/build/handler/build.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525

2626
buildservice "github.com/koderover/zadig/pkg/microservice/aslan/core/build/service"
2727
commonmodels "github.com/koderover/zadig/pkg/microservice/aslan/core/common/repository/models"
28-
internalhandler "github.com/koderover/zadig/pkg/microservice/aslan/internal/handler"
28+
internalhandler "github.com/koderover/zadig/pkg/shared/handler"
2929
e "github.com/koderover/zadig/pkg/tool/errors"
3030
"github.com/koderover/zadig/pkg/tool/log"
3131
"github.com/koderover/zadig/pkg/types/permission"

pkg/microservice/aslan/core/build/handler/router.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ package handler
1919
import (
2020
"github.com/gin-gonic/gin"
2121

22-
"github.com/koderover/zadig/pkg/microservice/aslan/middleware"
22+
gin2 "github.com/koderover/zadig/pkg/middleware/gin"
2323
"github.com/koderover/zadig/pkg/types/permission"
2424
)
2525

2626
type Router struct{}
2727

2828
func (*Router) Inject(router *gin.RouterGroup) {
29-
router.Use(middleware.Auth())
29+
router.Use(gin2.Auth())
3030

3131
build := router.Group("build")
3232
{
3333
build.GET("/:name/:version", FindBuildModule)
3434
build.GET("", ListBuildModules)
35-
build.POST("", middleware.StoreProductName, middleware.IsHavePermission([]string{permission.BuildManageUUID}, permission.ContextKeyType), middleware.UpdateOperationLogStatus, CreateBuildModule)
36-
build.PUT("", middleware.StoreProductName, middleware.IsHavePermission([]string{permission.BuildManageUUID}, permission.ContextKeyType), middleware.UpdateOperationLogStatus, UpdateBuildModule)
37-
build.DELETE("", middleware.IsHavePermission([]string{permission.BuildDeleteUUID}, permission.QueryType), middleware.UpdateOperationLogStatus, DeleteBuildModule)
38-
build.POST("/targets", middleware.IsHavePermission([]string{permission.BuildManageUUID}, permission.QueryType), middleware.UpdateOperationLogStatus, UpdateBuildTargets)
35+
build.POST("", gin2.StoreProductName, gin2.IsHavePermission([]string{permission.BuildManageUUID}, permission.ContextKeyType), gin2.UpdateOperationLogStatus, CreateBuildModule)
36+
build.PUT("", gin2.StoreProductName, gin2.IsHavePermission([]string{permission.BuildManageUUID}, permission.ContextKeyType), gin2.UpdateOperationLogStatus, UpdateBuildModule)
37+
build.DELETE("", gin2.IsHavePermission([]string{permission.BuildDeleteUUID}, permission.QueryType), gin2.UpdateOperationLogStatus, DeleteBuildModule)
38+
build.POST("/targets", gin2.IsHavePermission([]string{permission.BuildManageUUID}, permission.QueryType), gin2.UpdateOperationLogStatus, UpdateBuildTargets)
3939
}
4040

4141
target := router.Group("targets")

pkg/microservice/aslan/core/build/handler/target.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"github.com/gin-gonic/gin"
2121

2222
buildservice "github.com/koderover/zadig/pkg/microservice/aslan/core/build/service"
23-
internalhandler "github.com/koderover/zadig/pkg/microservice/aslan/internal/handler"
23+
internalhandler "github.com/koderover/zadig/pkg/shared/handler"
2424
)
2525

2626
func ListDeployTarget(c *gin.Context) {

pkg/microservice/aslan/core/build/service/build.go

+3
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ func UpdateBuildTargets(name, productName string, targets []*commonmodels.Servic
318318
return e.ErrUpdateBuildParam.AddErr(err)
319319
}
320320

321+
//处理云主机服务组件逻辑
322+
handleServiceTargets(name, productName, targets)
323+
321324
err := commonrepo.NewBuildColl().UpdateTargets(name, productName, targets)
322325
if err != nil {
323326
log.Errorf("[Build.UpdateServices] %s error: %v", name, err)

pkg/microservice/aslan/core/build/service/target.go

+19
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,19 @@ func ListDeployTarget(productName string, log *zap.SugaredLogger) ([]*commonmode
8686
}
8787
}
8888
}
89+
case setting.PMDeployType:
90+
target := fmt.Sprintf("%s-%s-%s", serviceTmpl.ProductName, serviceTmpl.ServiceName, serviceTmpl.ServiceName)
91+
if _, ok := targetMap[target]; !ok {
92+
targetMap[target] = true
93+
ServiceObject := &commonmodels.ServiceModuleTarget{
94+
ProductName: serviceTmpl.ProductName,
95+
ServiceName: serviceTmpl.ServiceName,
96+
ServiceModule: serviceTmpl.ServiceName,
97+
}
98+
if !buildTargets.Has(target) {
99+
serviceObjects = append(serviceObjects, ServiceObject)
100+
}
101+
}
89102
}
90103
}
91104
return serviceObjects, nil
@@ -121,6 +134,12 @@ func ListContainers(productName string, log *zap.SugaredLogger) ([]*commonmodels
121134
ServiceModule: container.Name,
122135
})
123136
}
137+
} else if service.Type == setting.PMDeployType {
138+
containerList = append(containerList, &commonmodels.ServiceModuleTarget{
139+
ProductName: service.ProductName,
140+
ServiceName: service.ServiceName,
141+
ServiceModule: service.ServiceName,
142+
})
124143
}
125144
}
126145
return containerList, nil

0 commit comments

Comments
 (0)