Unverified Commit 7f6c8916 authored by TzlilSwimmer123's avatar TzlilSwimmer123 Committed by GitHub
Browse files

feat: add octupos to the list of ci (#818)

Co-authored-by: default avatarteselil <tzlil@datree.com>
Showing with 17 additions and 7 deletions
+17 -7
......@@ -43,21 +43,25 @@ var ciMap = map[string]*CIMetadata{
"SAIL_CI": {CIEnvValue: "sail", ShouldHideEmojis: false},
}
var ciMapPrefix = map[string]CIMetadata{
var ciMapPrefix = map[string]*CIMetadata{
"ATLANTIS_": {CIEnvValue: "atlantis", ShouldHideEmojis: false},
"BITBUCKET_": {CIEnvValue: "bitbucket", ShouldHideEmojis: false},
"CONCOURSE_": {CIEnvValue: "concourse", ShouldHideEmojis: false},
"SPACELIFT_": {CIEnvValue: "spacelift", ShouldHideEmojis: false},
"HARNESS_": {CIEnvValue: "harness", ShouldHideEmojis: false},
"Octopus": {CIEnvValue: "octopus-deploy", ShouldHideEmojis: false},
}
var ciFallbackEnvVar = map[string]*CIMetadata{"CI": {CIEnvValue: "unrecognized-ci", ShouldHideEmojis: false}}
func Extract() *CIContext {
ciName := getCIName()
ciName, ciMetadata := getCIData()
isCI := len(ciName) > 0
if isCI {
return &CIContext{
IsCI: isCI,
CIMetadata: ciMap[ciName],
CIMetadata: ciMetadata,
}
} else {
return &CIContext{
......@@ -70,22 +74,28 @@ func Extract() *CIContext {
}
}
func getCIName() string {
func getCIData() (string, *CIMetadata) {
for env := range ciMap {
if isKeyInEnv(env) {
return env
return env, ciMap[env]
}
}
for _, key := range os.Environ() {
for prefix := range ciMapPrefix {
if strings.HasPrefix(key, prefix) {
return prefix
return prefix, ciMapPrefix[prefix]
}
}
}
return ""
for env := range ciFallbackEnvVar {
if isKeyInEnv(env) {
return env, ciFallbackEnvVar[env]
}
}
return "", nil
}
func isKeyInEnv(key string) bool {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment