Skip to content

Commit

Permalink
Handle admin pod
Browse files Browse the repository at this point in the history
  • Loading branch information
mlejva committed May 7, 2020
1 parent 9da61c8 commit 8f1dcc2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
type FoundryConf struct {
ServiceAccPath string `yaml:"serviceAcc"`
IgnoreStrPatterns []string `yaml:"ignore"`
Admin bool `yaml:"admin"`

CurrentDir string `yaml:"-"` // Current working directory of CLI
Ignore []glob.Glob `yaml:"-"`
Expand Down Expand Up @@ -165,7 +166,7 @@ func cobraInitCallback(cmd string) {
if cmd == "go" {
// Create a new connection to the cloud env
fmt.Println("Connecting to your cloud environment...")
c, err := conn.New(authClient.IDToken)
c, err := conn.New(authClient.IDToken, foundryConf.Admin)
if err != nil {
logger.FdebuglnFatal("Connection error", err)
logger.FatalLogln(err)
Expand Down
9 changes: 5 additions & 4 deletions connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package connection

import (
"fmt"
"strconv"
"time"

"foundry/cli/connection/endpoint"
Expand All @@ -26,9 +27,9 @@ type ConnectionMessage interface {
// Gorilla's websocket.Conn can be accessed only from a single
// goroutine.

func New(token string) (*Connection, error) {
func New(token string, admin bool) (*Connection, error) {
logger.Fdebugln("WS dialing")
url := WebSocketURL(token)
url := WebSocketURL(token, admin)
c, _, err := websocket.DefaultDialer.Dial(url, nil)
if err != nil {
return nil, err
Expand Down Expand Up @@ -82,8 +83,8 @@ func (c *Connection) Ping(pm *msg.PingMsg, ticker *time.Ticker, stop <-chan stru
}
}

func WebSocketURL(token string) string {
return fmt.Sprintf("%s://%s/ws/%s", endpoint.WebSocketScheme, endpoint.WebSocketURL, token)
func WebSocketURL(token string, admin bool) string {
return fmt.Sprintf("%s://%s/ws/%s?admin=%s", endpoint.WebSocketScheme, endpoint.WebSocketURL, token, strconv.FormatBool(admin))
}

func PingURL() string {
Expand Down

0 comments on commit 8f1dcc2

Please sign in to comment.