Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(spec): Default apiServer URL to https #289

Merged
merged 1 commit into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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