grim/tagpull
Clone
Summary
Browse
Changes
Graph
Look for the annotation on the deployment itself and not in it's template
draft
2020-07-05, Gary Kramlich
b23e8d5837de
Look for the annotation on the deployment itself and not in it's template
package
main
import
(
"strings"
)
// create a comma separate string of labels to match based on a map
func
createLabelString
(
labelMap
map
[
string
]
string
)
string
{
labels
:=
make
([]
string
,
len
(
labelMap
))
i
:=
0
for
k
,
v
:=
range
labelMap
{
labels
[
i
]
=
k
+
"="
+
v
i
++
}
return
strings
.
Join
(
labels
,
","
)
}
// takes a repository like rwgrim/tagops or rwgrim/tagops:1.0 and returns the
// repo name and tag. Ie: rwgrim/tagops, latest and rwgrim/tagops, 1.0.
func
parseRepositoryAndTag
(
repository
string
)
(
string
,
string
)
{
parts
:=
strings
.
SplitN
(
repository
,
":"
,
2
)
if
len
(
parts
)
==
2
{
return
parts
[
0
],
parts
[
1
]
}
return
parts
[
0
],
"latest"
}