Skip to content

Commit

Permalink
Allow override of websocket url
Browse files Browse the repository at this point in the history
  • Loading branch information
erebe committed Aug 16, 2024
1 parent c7c45f3 commit e575538
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pkg/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ func ExecLog(req *LogRequest) {

func createLogWebsocket(req *LogRequest) (*websocket.Conn, error) {
wsURL, err := url.Parse(fmt.Sprintf(
"wss://ws.qovery.com/service/logs?service=%s&cluster=%s&environment=%s&organization=%s&project=%s",
"%s/service/logs?service=%s&cluster=%s&environment=%s&organization=%s&project=%s",
utils.WebsocketUrl(),
req.ServiceID,
req.ClusterID,
req.EnvironmentID,
Expand Down
2 changes: 1 addition & 1 deletion pkg/port-forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func mkWebsocketConn(req *PortForwardRequest) (*WebsocketPortForward, error) {
return nil, err
}

wsURL, err := url.Parse("wss://ws.qovery.com/shell/portforward")
wsURL, err := url.Parse(fmt.Sprintf("%s/shell/portforward", utils.WebsocketUrl()))
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/service_list_pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package pkg
import (
"encoding/json"
"errors"
"fmt"
"github.com/appscode/go-querystring/query"
"github.com/gorilla/websocket"
"github.com/qovery/qovery-cli/utils"
Expand All @@ -25,7 +26,7 @@ func ExecListPods(req *PortForwardRequest) (*ListPodResponse, error) {
return nil, err
}

wsURL, err := url.Parse("wss://ws.qovery.com/service/pods")
wsURL, err := url.Parse(fmt.Sprintf("%s/service/pods", utils.WebsocketUrl()))
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package pkg

import (
"errors"
"fmt"
"github.com/appscode/go-querystring/query"
"net/http"
"net/url"
Expand Down Expand Up @@ -80,7 +81,7 @@ func createWebsocketConn(req *ShellRequest) (*websocket.Conn, error) {
return nil, err
}

wsURL, err := url.Parse("wss://ws.qovery.com/shell/exec")
wsURL, err := url.Parse(fmt.Sprintf("%s/shell/exec", utils.WebsocketUrl()))
if err != nil {
return nil, err
}
Expand Down
7 changes: 7 additions & 0 deletions utils/qovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ type Role struct {

const AdminUrl = "https://api-admin.qovery.com"

func WebsocketUrl() string {
if url := os.Getenv("QOVERY_WS_URL"); url != "" {
return url
}
return "wss://ws.qovery.com"
}

func GetQoveryClient(tokenType AccessTokenType, token AccessToken) *qovery.APIClient {
conf := qovery.NewConfiguration()
conf.UserAgent = "CLI " + Version
Expand Down

0 comments on commit e575538

Please sign in to comment.