Skip to content

Commit a61d852

Browse files
authored
fix(spec): Default apiServer URL to https (#289)
Defaults the apiServer URL scheme to `https://` if unset. Also fixes the message printed by `tk init` to include the scheme
1 parent 247e2be commit a61d852

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

cmd/tk/init.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func initCmd() *cli.Command {
6060
}
6161
}
6262

63-
fmt.Println("Directory structure set up! Remember to configure the API endpoint:\n`tk env set environments/default --server=127.0.0.1:6443`")
63+
fmt.Println("Directory structure set up! Remember to configure the API endpoint:\n`tk env set environments/default --server=https://127.0.0.1:6443`")
6464
if failed {
6565
log.Println("Errors occured while initializing the project. Check the above logs for details.")
6666
}

pkg/spec/spec.go

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io/ioutil"
66
"os"
77
"path/filepath"
8+
"regexp"
89

910
"github.com/pkg/errors"
1011

@@ -55,6 +56,12 @@ func Parse(data []byte, name string) (*v1alpha1.Config, error) {
5556
if err := handleDeprecated(config, data); err != nil {
5657
return config, err
5758
}
59+
60+
// default apiServer URL to https
61+
if !regexp.MustCompile("^.+://").MatchString(config.Spec.APIServer) {
62+
config.Spec.APIServer = "https://" + config.Spec.APIServer
63+
}
64+
5865
return config, nil
5966
}
6067

0 commit comments

Comments
 (0)