2021-03-24 18:27:32 +00:00
|
|
|
package endpointutils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
portainer "github.com/portainer/portainer/api"
|
|
|
|
)
|
|
|
|
|
2021-09-20 00:14:22 +00:00
|
|
|
// IsLocalEndpoint returns true if this is a local environment(endpoint)
|
2021-03-24 18:27:32 +00:00
|
|
|
func IsLocalEndpoint(endpoint *portainer.Endpoint) bool {
|
|
|
|
return strings.HasPrefix(endpoint.URL, "unix://") || strings.HasPrefix(endpoint.URL, "npipe://") || endpoint.Type == 5
|
|
|
|
}
|
2021-06-16 05:28:44 +00:00
|
|
|
|
2021-09-29 23:58:10 +00:00
|
|
|
// IsKubernetesEndpoint returns true if this is a kubernetes endpoint
|
2021-06-16 05:28:44 +00:00
|
|
|
func IsKubernetesEndpoint(endpoint *portainer.Endpoint) bool {
|
|
|
|
return endpoint.Type == portainer.KubernetesLocalEnvironment ||
|
|
|
|
endpoint.Type == portainer.AgentOnKubernetesEnvironment ||
|
|
|
|
endpoint.Type == portainer.EdgeAgentOnKubernetesEnvironment
|
|
|
|
}
|
|
|
|
|
2021-09-20 00:14:22 +00:00
|
|
|
// IsDockerEndpoint returns true if this is a docker environment(endpoint)
|
2021-06-16 05:28:44 +00:00
|
|
|
func IsDockerEndpoint(endpoint *portainer.Endpoint) bool {
|
|
|
|
return endpoint.Type == portainer.DockerEnvironment ||
|
|
|
|
endpoint.Type == portainer.AgentOnDockerEnvironment ||
|
|
|
|
endpoint.Type == portainer.EdgeAgentOnDockerEnvironment
|
|
|
|
}
|
2021-09-24 04:56:22 +00:00
|
|
|
|
2021-09-29 23:58:10 +00:00
|
|
|
// IsEdgeEndpoint returns true if this is an Edge endpoint
|
2021-09-24 04:56:22 +00:00
|
|
|
func IsEdgeEndpoint(endpoint *portainer.Endpoint) bool {
|
|
|
|
return endpoint.Type == portainer.EdgeAgentOnDockerEnvironment || endpoint.Type == portainer.EdgeAgentOnKubernetesEnvironment
|
|
|
|
}
|