Skip to content

Commit b38645a

Browse files
committed
short refactor
1 parent 243620f commit b38645a

File tree

4 files changed

+43
-44
lines changed

4 files changed

+43
-44
lines changed

Makefile

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2-
.PHONY: all test build build-linux-amd64 build-osx-amd64 build-windows-amd64 build-win-386
2+
.PHONY: all test build build-linux-x86_64 build-linux-x86 build-osx-x86_64 build-osx-x86 build-win-x86_64 build-win-x86
33

4-
all: test build build-linux-amd64 build-osx-amd64 build-windows-amd64 build-win-386
4+
all: test build build-linux-x86_64 build-linux-x86 build-osx-x86_64 build-osx-x86 build-win-x86_64 build-win-x86
55

66
test:
77
@echo "Running tests"
@@ -11,26 +11,26 @@ build:
1111
@echo "Building"
1212
@go build -o gtw
1313

14-
build-linux-amd64:
15-
@echo "Building linux-amd64 version"
16-
@GOOS=linux GOARCH=amd64 go build -o gtw-linux-amd64
14+
build-linux-x86_64:
15+
@echo "Building linux-x86_64 version"
16+
@GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -tags netgo -installsuffix netgo -o gtw-linux-x86_64
1717

18-
build-linux-386:
19-
@echo "Building linux-386 version"
20-
@GOOS=linux GOARCH=386 go build -o gtw-linux-386
18+
build-linux-x86:
19+
@echo "Building linux-x86 version"
20+
@GOOS=linux GOARCH=386 CGO_ENABLED=0 go build -a -tags netgo -installsuffix netgo -o gtw-linux-x86
2121

22-
build-osx-amd64:
23-
@echo "Building osx-amd64 version"
24-
@GOOS=darwin GOARCH=amd64 go build -o gtw-osx-amd64
22+
build-osx-x86_64:
23+
@echo "Building osx-x86_64 version"
24+
@GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -a -tags netgo -installsuffix netgo -o gtw-osx-x86_64
2525

26-
build-osx-386:
27-
@echo "Building osx-386 version"
28-
@GOOS=darwin GOARCH=386 go build -o gtw-osx-386
26+
build-osx-x86:
27+
@echo "Building osx-x86 version"
28+
@GOOS=darwin GOARCH=386 CGO_ENABLED=0 go build -a -tags netgo -installsuffix netgo -o gtw-osx-x86
2929

30-
build-windows-amd64:
31-
@echo "Building windows-amd64 version"
32-
@GOOS=darwin GOARCH=amd64 go build -o gtw-win-amd64.exe
30+
build-win-x86_64:
31+
@echo "Building win-x86_64 version"
32+
@GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -a -tags netgo -installsuffix netgo -o gtw-win-x86_64.exe
3333

34-
build-win-386:
35-
@echo "Building win-386 version"
36-
@GOOS=darwin GOARCH=386 go build -o gtw-win-386.exe
34+
build-win-x86:
35+
@echo "Building win-x86 version"
36+
@GOOS=darwin GOARCH=386 CGO_ENABLED=0 go build -a -tags netgo -installsuffix netgo -o gtw-win-x86.exe

main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@ import (
88
"time"
99

1010
"github.com/EGT-Ukraine/gitlab-trigger-watcher/models"
11-
1211
"github.com/EGT-Ukraine/gitlab-trigger-watcher/trigger"
1312
"github.com/urfave/cli"
1413
)
1514

1615
const (
17-
waitTimeout = 10 * time.Minute
16+
lifecycleTimeout = 10 * time.Minute
1817
thresholdTimeout = 2 * time.Second
1918
)
2019

2120
func main() {
21+
go shutdownSignalReceiver()
22+
2223
app := cli.App{
2324
Flags: []cli.Flag{
2425
cli.BoolFlag{
@@ -89,9 +90,8 @@ func main() {
8990
}
9091

9192
go func() {
92-
shutdown()
93-
time.Sleep(waitTimeout)
94-
os.Exit(1)
93+
time.Sleep(lifecycleTimeout)
94+
log.Fatalf("lifecycle time(%v) has been expired", lifecycleTimeout)
9595
}()
9696

9797
var previousPipelineStatus models.PipelineStatus
@@ -129,7 +129,7 @@ func main() {
129129
}
130130
}
131131

132-
func shutdown() {
132+
func shutdownSignalReceiver() {
133133
quit := make(chan os.Signal, 1)
134134
signal.Notify(quit, syscall.SIGTERM, syscall.SIGINT)
135135
<-quit

models/create_pipeline.go renamed to models/models.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
package models
22

3+
type PipelineStatus string
4+
5+
const (
6+
Running PipelineStatus = "running"
7+
Pending = "pending"
8+
Failed = "failed"
9+
Success = "success"
10+
)
11+
312
type CreatePipelineResponse struct {
413
BeforeSha string `json:"before_sha"`
514
CommittedAt interface{} `json:"committed_at"`
@@ -25,3 +34,11 @@ type CreatePipelineResponse struct {
2534
WebURL string `json:"web_url"`
2635
YamlErrors interface{} `json:"yaml_errors"`
2736
}
37+
38+
type PipelineStatusResponse struct {
39+
ID int64 `json:"id"`
40+
Ref string `json:"ref"`
41+
Sha string `json:"sha"`
42+
Status PipelineStatus `json:"status"`
43+
WebURL string `json:"web_url"`
44+
}

models/pipeline_status.go

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)