1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 07:49:41 +02:00

feat(system/upgrade): add upgrade banner [EE-4564] (#8046)

This commit is contained in:
Chaim Lev-Ari 2022-11-16 18:38:39 +02:00 committed by GitHub
parent c21921a08d
commit eccc8131dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 366 additions and 33 deletions

44
api/platform/platform.go Normal file
View file

@ -0,0 +1,44 @@
package platform
import "os"
const (
PodmanMode = "PODMAN"
KubernetesServiceHost = "KUBERNETES_SERVICE_HOST"
NomadJobName = "NOMAD_JOB_NAME"
)
// ContainerPlatform represent the platform on which the container is running (Docker, Kubernetes, Nomad)
type ContainerPlatform string
const (
// PlatformDocker represent the Docker platform (Standalone/Swarm)
PlatformDocker = ContainerPlatform("Docker")
// PlatformKubernetes represent the Kubernetes platform
PlatformKubernetes = ContainerPlatform("Kubernetes")
// PlatformPodman represent the Podman platform (Standalone)
PlatformPodman = ContainerPlatform("Podman")
// PlatformNomad represent the Nomad platform (Standalone)
PlatformNomad = ContainerPlatform("Nomad")
)
// DetermineContainerPlatform will check for the existence of the PODMAN_MODE
// or KUBERNETES_SERVICE_HOST environment variable to determine if
// the container is running on Podman or inside the Kubernetes platform.
// Defaults to Docker otherwise.
func DetermineContainerPlatform() ContainerPlatform {
podmanModeEnvVar := os.Getenv(PodmanMode)
if podmanModeEnvVar == "1" {
return PlatformPodman
}
serviceHostKubernetesEnvVar := os.Getenv(KubernetesServiceHost)
if serviceHostKubernetesEnvVar != "" {
return PlatformKubernetes
}
nomadJobName := os.Getenv(NomadJobName)
if nomadJobName != "" {
return PlatformNomad
}
return PlatformDocker
}