2016-12-05 16:29:41 +01:00
|
|
|
package rancher
|
|
|
|
|
2017-02-05 11:35:48 +01:00
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/rancher/go-rancher/client"
|
|
|
|
)
|
2016-12-05 16:29:41 +01:00
|
|
|
|
2017-02-01 20:49:17 +01:00
|
|
|
const (
|
2017-02-05 11:35:48 +01:00
|
|
|
stateRemoved = "removed"
|
|
|
|
statePurged = "purged"
|
2017-02-01 20:49:17 +01:00
|
|
|
)
|
|
|
|
|
2016-12-05 16:29:41 +01:00
|
|
|
// GetActiveOrchestration get the name of the active orchestration for a environment
|
2017-02-05 11:35:48 +01:00
|
|
|
func getActiveOrchestration(project *client.Project) string {
|
2016-12-05 16:29:41 +01:00
|
|
|
orch := "cattle"
|
|
|
|
|
|
|
|
switch {
|
|
|
|
case project.Swarm:
|
|
|
|
orch = "swarm"
|
|
|
|
case project.Mesos:
|
|
|
|
orch = "mesos"
|
|
|
|
case project.Kubernetes:
|
|
|
|
orch = "kubernetes"
|
|
|
|
}
|
|
|
|
|
|
|
|
return orch
|
|
|
|
}
|
2017-02-01 20:49:17 +01:00
|
|
|
|
|
|
|
func removed(state string) bool {
|
2017-02-05 11:35:48 +01:00
|
|
|
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
|
2017-02-01 20:49:17 +01:00
|
|
|
}
|
2017-03-14 18:17:09 +01:00
|
|
|
|
|
|
|
// NewListOpts wraps around client.NewListOpts()
|
|
|
|
func NewListOpts() *client.ListOpts {
|
|
|
|
return client.NewListOpts()
|
|
|
|
}
|