Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Datree
Commits
7f6c8916
Unverified
Commit
7f6c8916
authored
2 years ago
by
TzlilSwimmer123
Committed by
GitHub
2 years ago
Browse files
Options
Download
Email Patches
Plain Diff
feat: add octupos to the list of ci (#818)
Co-authored-by:
teselil
<
tzlil@datree.com
>
parent
4cb0e38c
release/1.8.1
DAT-4427-cli-add-save-rendered-flag
release/1.6.42
release/1.6.44
release/1.6.46
release/1.6.48
release/1.7.1
release/1.7.3
release/1.8.0
1.8.2-rc
1.8.1
1.8.1-rc
1.8.0
1.8.0-rc
1.7.3
1.7.3-rc
1.7.2-rc
1.7.1
1.7.1-rc
1.7.0-rc
1.6.49-rc
1.6.48
1.6.48-rc
1.6.47-rc
1.6.46
1.6.46-rc
1.6.45-rc
1.6.44
1.6.44-rc
1.6.43-rc
1.6.42
1.6.42-rc
1.6.41-rc
v1.8.2-rc
v1.8.1
v1.8.1-rc
v1.8.0
v1.8.0-rc
v1.7.3
v1.7.3-rc
v1.7.2-rc
v1.7.1
v1.7.1-rc
v1.7.0-rc
v1.6.49-rc
v1.6.48
v1.6.48-rc
v1.6.47-rc
v1.6.46
v1.6.46-rc
v1.6.45-rc
v1.6.44
v1.6.44-rc
v1.6.43-rc
v1.6.42
v1.6.42-rc
v1.6.41-rc
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pkg/ciContext/ciContext.go
+17
-7
pkg/ciContext/ciContext.go
with
17 additions
and
7 deletions
+17
-7
pkg/ciContext/ciContext.go
+
17
-
7
View file @
7f6c8916
...
...
@@ -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
:=
getCI
Name
()
ciName
,
ciMetadata
:=
getCI
Data
()
isCI
:=
len
(
ciName
)
>
0
if
isCI
{
return
&
CIContext
{
IsCI
:
isCI
,
CIMetadata
:
ciM
ap
[
ciName
]
,
CIMetadata
:
ciM
etadata
,
}
}
else
{
return
&
CIContext
{
...
...
@@ -70,22 +74,28 @@ func Extract() *CIContext {
}
}
func
getCI
Name
()
string
{
func
getCI
Data
()
(
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
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help