mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-03-13 01:00:50 -04:00
* Add rancher_host resource type This adds a rancher_host resource type. For now, the goal is to detect if the host already exists, so that it can be purged cleanly when the host is deprovisioned. The typical use is to create both an instance (e.g. aws_instance) and a rancher_host resources with the same hostname. The rancher_host resource will detect when the agent has registered itself. When removing the host, both the instance and the rancher_host resources can be removed, ensuring the host is purged from Rancher. In future versions, this could support creating hosts as well. * Use ro_labels to avoid removing internal Rancher labels As reported in https://github.com/rancher/rancher/issues/8165 * Do not ForceNew on environment_id
45 lines
847 B
Go
45 lines
847 B
Go
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()
|
|
}
|