-
Notifications
You must be signed in to change notification settings - Fork 10
/
cluster.go
76 lines (61 loc) · 1.58 KB
/
cluster.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
package types
import (
"strings"
"time"
"github.com/AliyunContainerService/ack-ram-tool/pkg/utils"
)
type ClusterType string
type ClusterState string
type ClusterTaskState string
var ClusterStateRunning ClusterState = "running"
var ClusterTypeManagedKubernetes ClusterType = "ManagedKubernetes"
var (
ClusterTaskStateSuccess ClusterTaskState = "success"
ClusterTaskStateFail ClusterTaskState = "fail"
ClusterTaskStateTimeout ClusterTaskState = "timeout"
ClusterTaskStateCanceled ClusterTaskState = "canceled"
)
type Cluster struct {
ClusterId string
ClusterType ClusterType
MetaData ClusterMetaData
Name string
RegionId string
State ClusterState
}
type ClusterMetaData struct {
RRSAConfig RRSAConfig `json:"RRSAConfig"`
}
type RRSAConfig struct {
Enabled bool `json:"enabled"`
Issuer string `json:"issuer"`
Audience string `json:"audience"`
OIDCName string `json:"oidc_name"`
OIDCArn string `json:"oidc_arn"`
}
func (c RRSAConfig) TokenIssuer() string {
issuers := strings.Split(c.Issuer, ",")
if len(issuers) > 1 {
return issuers[0]
}
return c.Issuer
}
type ClusterTask struct {
TaskId string
State ClusterTaskState
Error interface{}
Result interface{}
}
func (t ClusterTask) Err() string {
return utils.ReplaceNewLine(string(utils.JSONValue(t.Error)))
}
func (s ClusterTaskState) IsNotSuccess() bool {
return s == ClusterTaskStateFail || s == ClusterTaskStateTimeout || s == ClusterTaskStateCanceled
}
func (s ClusterState) IsRunning() bool {
return s == ClusterStateRunning
}
type ClusterLog struct {
Log string
Created time.Time
}