Skip to content
This repository was archived by the owner on Mar 24, 2021. It is now read-only.

Commit 6b236ad

Browse files
committed
fix:context
1 parent cf092e4 commit 6b236ad

File tree

7 files changed

+39
-13
lines changed

7 files changed

+39
-13
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
main
22
/deploy
33
.idea
4+
./release-app/release_app

Makefile

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
BUILDX_BUILD_PUSH=docker buildx build --platform linux/amd64,linux/arm64 --output=type=registry --push
2-
3-
build-push-image-%: ## build docker image
1+
build-image-%: ## build docker image
42
if [ "$*" = "latest" ];then \
5-
$(BUILDX_BUILD_PUSH) -t openpitrix/release-app:latest . && \
3+
docker build -t openpitrix/release-app:latest . ;\
64
elif [ "`echo "$*" | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+"`" != "" ];then \
7-
$(BUILDX_BUILD_PUSH) -t openpitrix/release-app:$* . && \
5+
docker build -t openpitrix/release-app:$* . ;\
86
fi
97

8+
push-image-%: ## push docker image
9+
@if [ "$*" = "latest" ];then \
10+
docker push openpitrix/release-app:latest; \
11+
elif [ "`echo "$*" | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+"`" != "" ];then \
12+
docker push openpitrix/release-app:$*; \
13+
fi
14+
15+
1016
.PHONY: build
1117
build:
1218
docker build -t openpitrix/release-app:latest .

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ require (
1313
openpitrix.io/openpitrix v0.4.1
1414
)
1515

16-
replace openpitrix.io/openpitrix => openpitrix.io/openpitrix v0.4.1-0.20191016075209-5d9de76b4fea
16+
replace openpitrix.io/openpitrix => openpitrix.io/openpitrix v0.4.2

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,5 @@ openpitrix.io/openpitrix v0.4.1-0.20191015160942-0202761f0f49/go.mod h1:8rZSFeUp
111111
openpitrix.io/openpitrix v0.4.1-0.20191016075209-5d9de76b4fea/go.mod h1:8rZSFeUp2Np5kfKAXfRL/1HSh6BYywNCALt+ZnxFQ/4=
112112
openpitrix.io/openpitrix v0.4.1 h1:Hzcw143qia7QJVfA7qE/nQCgOag9+0XrIiw1oLxSxos=
113113
openpitrix.io/openpitrix v0.4.1/go.mod h1:8rZSFeUp2Np5kfKAXfRL/1HSh6BYywNCALt+ZnxFQ/4=
114+
openpitrix.io/openpitrix v0.4.2 h1:VpPfB703BTAH3vnNLElypz5UgxOAXAL03V0JIr7Dg0o=
115+
openpitrix.io/openpitrix v0.4.2/go.mod h1:8rZSFeUp2Np5kfKAXfRL/1HSh6BYywNCALt+ZnxFQ/4=

release-app-job.yaml

+10-1
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,20 @@ spec:
1919
version: v0.0.1
2020
name: hyperpitrix-release-app-job
2121
spec:
22+
initContainers:
23+
- name: wait-app-manager
24+
image: busybox:1.28.4
25+
imagePullPolicy: IfNotPresent
26+
command: ['sh', '-c', 'until nc -z openpitrix-app-manager.${NAMESPACE}.svc 9102; do echo "waiting for app-manager"; sleep 2; done;']
27+
- name: wait-attachment-manager
28+
image: busybox:1.28.4
29+
imagePullPolicy: IfNotPresent
30+
command: ['sh', '-c', 'until nc -z openpitrix-attachment-manager.${NAMESPACE}.svc 9122; do echo "waiting for attachment-manager"; sleep 2; done;']
2231
containers:
2332
- command: ["release-app","-path","/data/helm-pkg/"]
2433
name: hyperpitrix-release-app-job
2534
imagePullPolicy: IfNotPresent
26-
image: openpitrix/release-app
35+
image: openpitrix/release-app:v0.4.2
2736
restartPolicy: OnFailure
2837
dnsPolicy: ClusterFirst
2938
schedulerName: default-scheduler

release-app/release_app

17.8 MB
Binary file not shown.

release-app/release_app.go

+14-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"openpitrix.io/openpitrix/pkg/client/app"
99
"openpitrix.io/openpitrix/pkg/logger"
1010
"openpitrix.io/openpitrix/pkg/pb"
11+
"openpitrix.io/openpitrix/pkg/sender"
12+
"openpitrix.io/openpitrix/pkg/util/ctxutil"
1113
"openpitrix.io/openpitrix/pkg/util/pbutil"
1214
"strings"
1315
)
@@ -19,7 +21,7 @@ func main() {
1921

2022
fileInfoList, err := ioutil.ReadDir(path)
2123
if err != nil {
22-
logger.Error(nil, "read dir path error: %s",err.Error())
24+
logger.Error(nil, "read dir path error: %s", err.Error())
2325
}
2426

2527
for _, f := range fileInfoList {
@@ -42,34 +44,40 @@ func main() {
4244

4345
createReq := &pb.CreateAppRequest{
4446
VersionPackage: pbutil.ToProtoBytes(pkg),
45-
Name: pbutil.ToProtoString(appName),
47+
Name: pbutil.ToProtoString(appName),
4648
VersionType: pbutil.ToProtoString("helm"),
4749
}
4850

49-
res, err := client.CreateApp(context.Background(), createReq)
51+
ctxFunc := func() (ctx context.Context){
52+
ctx = context.Background()
53+
ctx = ctxutil.ContextWithSender(ctx, sender.GetSystemSender())
54+
return
55+
}
56+
res, err := client.CreateApp(ctxFunc(), createReq)
5057
if err != nil {
5158
logger.Error(nil, "create app error: %s", err.Error())
5259
} else {
5360
submitReq := &pb.SubmitAppVersionRequest{
5461
VersionId: res.VersionId,
5562
}
56-
_, err = client.SubmitAppVersion(context.Background(), submitReq)
63+
64+
_, err = client.SubmitAppVersion(ctxFunc(), submitReq)
5765
if err != nil {
5866
logger.Error(nil, "submit app error: %s", err.Error())
5967
}
6068

6169
passReq := &pb.PassAppVersionRequest{
6270
VersionId: res.VersionId,
6371
}
64-
_, err = client.AdminPassAppVersion(context.Background(), passReq)
72+
_, err = client.AdminPassAppVersion(ctxFunc(), passReq)
6573
if err != nil {
6674
logger.Error(nil, "pass app error: %s", err.Error())
6775
}
6876

6977
releaseReq := &pb.ReleaseAppVersionRequest{
7078
VersionId: res.VersionId,
7179
}
72-
_, err = client.ReleaseAppVersion(context.Background(), releaseReq)
80+
_, err = client.ReleaseAppVersion(ctxFunc(), releaseReq)
7381
if err != nil {
7482
logger.Error(nil, "release app error: %s", err.Error())
7583
}

0 commit comments

Comments
 (0)