github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/builtin/providers/rancher/util.go (about)

     1  package rancher
     2  
     3  import (
     4  	"strings"
     5  
     6  	"github.com/rancher/go-rancher/client"
     7  )
     8  
     9  const (
    10  	stateRemoved = "removed"
    11  	statePurged  = "purged"
    12  )
    13  
    14  // GetActiveOrchestration get the name of the active orchestration for a environment
    15  func getActiveOrchestration(project *client.Project) string {
    16  	orch := "cattle"
    17  
    18  	switch {
    19  	case project.Swarm:
    20  		orch = "swarm"
    21  	case project.Mesos:
    22  		orch = "mesos"
    23  	case project.Kubernetes:
    24  		orch = "kubernetes"
    25  	}
    26  
    27  	return orch
    28  }
    29  
    30  func removed(state string) bool {
    31  	return state == stateRemoved || state == statePurged
    32  }
    33  
    34  func splitID(id string) (envID, resourceID string) {
    35  	if strings.Contains(id, "/") {
    36  		return id[0:strings.Index(id, "/")], id[strings.Index(id, "/")+1:]
    37  	}
    38  	return "", id
    39  }