Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Only enable if tech preview is on
Browse files Browse the repository at this point in the history
  • Loading branch information
nwmac committed Jun 24, 2020
1 parent 3ec9362 commit 16326d5
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/jetstream/plugins/kubernetes/terminal/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,45 @@ import (
"fmt"
"io/ioutil"

"github.com/cloudfoundry-incubator/stratos/src/jetstream/repository/interfaces"
"github.com/cloudfoundry-incubator/stratos/src/jetstream/plugins/kubernetes/api"
"github.com/cloudfoundry-incubator/stratos/src/jetstream/repository/interfaces"
"github.com/cloudfoundry-incubator/stratos/src/jetstream/repository/interfaces/config"

log "github.com/sirupsen/logrus"
)

const (
serviceAccountTokenFile = "/var/run/secrets/kubernetes.io/serviceaccount/token"
serviceHostEnvVar = "KUBERNETES_SERVICE_HOST"
servicePortEnvVar = "KUBERNETES_SERVICE_PORT"
serviceHostEnvVar = "KUBERNETES_SERVICE_HOST"
servicePortEnvVar = "KUBERNETES_SERVICE_PORT"
// For dev - read token from env var
serviceTokenEnvVar = "KUBE_TERMINAL_SERVICE_ACCOUNT_TOKEN"

stratosRoleLabel = "stratos-role"
stratosKubeTerminalRole = "kube-terminal"
stratosRoleLabel = "stratos-role"
stratosKubeTerminalRole = "kube-terminal"
stratosSessionAnnotation = "stratos-session"

consoleContainerName = "kube-terminal"
)

// KubeTerminal supports spawning pods to provide a CLI environment to the user
type KubeTerminal struct {
PortalProxy interfaces.PortalProxy
Namespace string `configName:"STRATOS_KUBERNETES_NAMESPACE"`
Image string `configName:"STRATOS_KUBERNETES_TERMINAL_IMAGE"`
Token []byte
APIServer string
Kube api.Kubernetes
PortalProxy interfaces.PortalProxy
Namespace string `configName:"STRATOS_KUBERNETES_NAMESPACE"`
Image string `configName:"STRATOS_KUBERNETES_TERMINAL_IMAGE"`
Token []byte
APIServer string
Kube api.Kubernetes
}

// NewKubeTerminal checks that the environment is set up to support the Kube Terminal
func NewKubeTerminal(p interfaces.PortalProxy) *KubeTerminal {
// Only enabled in tech preview
if !p.GetConfig().EnableTechPreview {
log.Info("Kube Terminal not enabled - requires tech preview")
return nil
}

kt := &KubeTerminal{
PortalProxy: p,
}
Expand Down

0 comments on commit 16326d5

Please sign in to comment.