Skip to content

Commit acfb6a1

Browse files
authored
chore: Common constants for ci-runner and orchestrator (#132)
* ci-runner common constants * clean DestinationKey filepath for blobstorage response
1 parent 437dc00 commit acfb6a1

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

blob-storage/BlobStorageService.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"go.uber.org/zap"
2424
"log"
2525
"os"
26+
"path/filepath"
2627
)
2728

2829
type BlobStorageService interface {
@@ -70,7 +71,7 @@ func (impl *BlobStorageServiceImpl) Get(request *BlobStorageRequest) (bool, int6
7071

7172
downloadSuccess := false
7273
numBytes := int64(0)
73-
file, err := os.Create("/" + request.DestinationKey)
74+
file, err := os.Create(filepath.Clean("/" + request.DestinationKey))
7475
defer file.Close()
7576
if err != nil {
7677
log.Println(err)

utils/workFlow/CiCdStage.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package workFlow
2+
3+
import "path"
4+
5+
type CiFailReason string
6+
7+
type CdFailReason string
8+
9+
func (r CiFailReason) String() string {
10+
return string(r)
11+
}
12+
13+
func (r CdFailReason) String() string {
14+
return string(r)
15+
}
16+
17+
const (
18+
PreCiFailed CiFailReason = "Pre-CI task failed: %s"
19+
PostCiFailed CiFailReason = "Post-CI task failed: %s"
20+
BuildFailed CiFailReason = "Docker build failed"
21+
PushFailed CiFailReason = "Docker push failed"
22+
ScanFailed CiFailReason = "Image scan failed"
23+
CiFailed CiFailReason = "CI failed"
24+
25+
CdStageTaskFailed CdFailReason = "%s task failed: %s"
26+
CdStageFailed CdFailReason = "%s failed. Reason: %s"
27+
)
28+
29+
const (
30+
TerminalLogDir = "/dev"
31+
TerminalLogFile = "/termination-log"
32+
)
33+
34+
func GetTerminalLogFilePath() string {
35+
return path.Join(TerminalLogDir, TerminalLogFile)
36+
}
37+
38+
const (
39+
DefaultErrorCode = 1
40+
AbortErrorCode = 143
41+
CiStageFailErrorCode = 2
42+
)

0 commit comments

Comments
 (0)