-
Notifications
You must be signed in to change notification settings - Fork 810
/
info.go
79 lines (67 loc) · 1.75 KB
/
info.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package info
import (
"strconv"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/duration"
"github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1"
"github.com/argoproj/argo-rollouts/utils/annotations"
timeutil "github.com/argoproj/argo-rollouts/utils/time"
)
const (
IconWaiting = "◷"
IconProgressing = "◌"
IconWarning = "⚠"
IconUnknown = "?"
IconOK = "✔"
IconBad = "✖"
IconPaused = "॥"
IconNeutral = "•"
)
const (
InfoTagCanary = "canary"
InfoTagStable = "stable"
InfoTagActive = "active"
InfoTagPreview = "preview"
InfoTagPing = "ping"
InfoTagPong = "pong"
)
type Metadata v1.ObjectMeta
type ImageInfo struct {
Image string
Tags []string
}
func Age(m v1.ObjectMeta) string {
return duration.HumanDuration(timeutil.MetaNow().Sub(m.CreationTimestamp.Time))
}
func ownerRef(ownerRefs []metav1.OwnerReference, uids []types.UID) *metav1.OwnerReference {
for _, ownerRef := range ownerRefs {
for _, uid := range uids {
if ownerRef.UID == uid {
return &ownerRef
}
}
}
return nil
}
func parseRevision(annotations_ map[string]string) int {
if annotations_ != nil {
if revision, err := strconv.Atoi(annotations_[annotations.RevisionAnnotation]); err == nil {
return revision
}
}
return 0
}
func parseExperimentTemplateName(annotations_ map[string]string) string {
if annotations_ != nil {
return annotations_[v1alpha1.ExperimentTemplateNameAnnotationKey]
}
return ""
}
func parseScaleDownDeadline(annotations_ map[string]string) string {
if annotations_ != nil {
return annotations_[v1alpha1.DefaultReplicaSetScaleDownDeadlineAnnotationKey]
}
return ""
}