Skip to content

Commit

Permalink
fix(spec): Default apiServer URL to https (#289)
Browse files Browse the repository at this point in the history
Defaults the apiServer URL scheme to `https://` if unset.

Also fixes the message printed by `tk init` to include the scheme
  • Loading branch information
sh0rez authored Jun 30, 2020
1 parent 247e2be commit a61d852
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/tk/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func initCmd() *cli.Command {
}
}

fmt.Println("Directory structure set up! Remember to configure the API endpoint:\n`tk env set environments/default --server=127.0.0.1:6443`")
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`")
if failed {
log.Println("Errors occured while initializing the project. Check the above logs for details.")
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"regexp"

"github.com/pkg/errors"

Expand Down Expand Up @@ -55,6 +56,12 @@ func Parse(data []byte, name string) (*v1alpha1.Config, error) {
if err := handleDeprecated(config, data); err != nil {
return config, err
}

// default apiServer URL to https
if !regexp.MustCompile("^.+://").MatchString(config.Spec.APIServer) {
config.Spec.APIServer = "https://" + config.Spec.APIServer
}

return config, nil
}

Expand Down

0 comments on commit a61d852

Please sign in to comment.