Skip to content

Commit 404edd9

Browse files
author
olegs-codefresh
committed
Add support to pass codefresh base url to local dev
1 parent 83c0b0c commit 404edd9

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

create-clusters.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"io/ioutil"
88
"net/http"
9+
"os"
910
"strings"
1011

1112
"github.com/urfave/cli"
@@ -16,6 +17,17 @@ import (
1617
"k8s.io/client-go/tools/clientcmd/api"
1718
)
1819

20+
var baseCodefreshURL = "https://g.codefresh.io/"
21+
22+
func init() {
23+
// used to debug
24+
url := os.Getenv("CODEFRESH_URL")
25+
if url != "" {
26+
fmt.Printf("Using other url %s\n", url)
27+
baseCodefreshURL = url
28+
}
29+
}
30+
1931
func create(cli *cli.Context) {
2032
pathToKubeConfig := cli.String("config")
2133
jwt := cli.String("token")
@@ -82,7 +94,7 @@ func create(cli *cli.Context) {
8294
}
8395

8496
func addCluser(host string, contextName string, token []byte, crt []byte, jwt string) ([]byte, error) {
85-
url := "http://g.codefresh.io/api/clusters/local/cluster"
97+
url := baseCodefreshURL + "api/clusters/local/cluster"
8698
payload := &requestPayload{
8799
Type: "sat",
88100
ProviderAgent: "custom",
@@ -116,7 +128,7 @@ func addCluser(host string, contextName string, token []byte, crt []byte, jwt st
116128
}
117129

118130
func testConnection(payload *requestPayload, jwt string) error {
119-
url := "http://g.codefresh.io/api/kubernetes/test"
131+
url := baseCodefreshURL + "api/kubernetes/test"
120132
mar, _ := json.Marshal(payload)
121133
p := strings.NewReader(string(mar))
122134
req, err := http.NewRequest("POST", url, p)

0 commit comments

Comments
 (0)