forked from hashicorp/terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.go
44 lines (35 loc) · 847 Bytes
/
util.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
package rancher
import (
"strings"
"github.com/rancher/go-rancher/client"
)
const (
stateRemoved = "removed"
statePurged = "purged"
)
// GetActiveOrchestration get the name of the active orchestration for a environment
func getActiveOrchestration(project *client.Project) string {
orch := "cattle"
switch {
case project.Swarm:
orch = "swarm"
case project.Mesos:
orch = "mesos"
case project.Kubernetes:
orch = "kubernetes"
}
return orch
}
func removed(state string) bool {
return state == stateRemoved || state == statePurged
}
func splitID(id string) (envID, resourceID string) {
if strings.Contains(id, "/") {
return id[0:strings.Index(id, "/")], id[strings.Index(id, "/")+1:]
}
return "", id
}
// NewListOpts wraps around client.NewListOpts()
func NewListOpts() *client.ListOpts {
return client.NewListOpts()
}