Skip to content
Snippets Groups Projects
Commit a55548de authored by Vipul Newaskar's avatar Vipul Newaskar
Browse files

allow http git repos connections while bootstrap


This change will allow user to bootstrap with http git urls
But user must explicitely set --allow-insecure-http=true

Signed-off-by: default avatarVipul Newaskar <vipulnewaskar7@gmail.com>
parent b84e613b
No related branches found
No related tags found
No related merge requests found
...@@ -67,12 +67,13 @@ command will perform an upgrade if needed.`, ...@@ -67,12 +67,13 @@ command will perform an upgrade if needed.`,
} }
type gitFlags struct { type gitFlags struct {
url string url string
interval time.Duration interval time.Duration
path flags.SafeRelativePath path flags.SafeRelativePath
username string username string
password string password string
silent bool silent bool
insecureHttpAllowed bool
} }
const ( const (
...@@ -88,6 +89,7 @@ func init() { ...@@ -88,6 +89,7 @@ func init() {
bootstrapGitCmd.Flags().StringVarP(&gitArgs.username, "username", "u", "git", "basic authentication username") bootstrapGitCmd.Flags().StringVarP(&gitArgs.username, "username", "u", "git", "basic authentication username")
bootstrapGitCmd.Flags().StringVarP(&gitArgs.password, "password", "p", "", "basic authentication password") bootstrapGitCmd.Flags().StringVarP(&gitArgs.password, "password", "p", "", "basic authentication password")
bootstrapGitCmd.Flags().BoolVarP(&gitArgs.silent, "silent", "s", false, "assumes the deploy key is already setup, skips confirmation") bootstrapGitCmd.Flags().BoolVarP(&gitArgs.silent, "silent", "s", false, "assumes the deploy key is already setup, skips confirmation")
bootstrapGitCmd.Flags().BoolVar(&gitArgs.insecureHttpAllowed, "allow-insecure-http", false, "allows http git url connections")
bootstrapCmd.AddCommand(bootstrapGitCmd) bootstrapCmd.AddCommand(bootstrapGitCmd)
} }
...@@ -269,6 +271,14 @@ func bootstrapGitCmdRun(cmd *cobra.Command, args []string) error { ...@@ -269,6 +271,14 @@ func bootstrapGitCmdRun(cmd *cobra.Command, args []string) error {
// SSH-agent is attempted. // SSH-agent is attempted.
func transportForURL(u *url.URL) (transport.AuthMethod, error) { func transportForURL(u *url.URL) (transport.AuthMethod, error) {
switch u.Scheme { switch u.Scheme {
case "http":
if !gitArgs.insecureHttpAllowed {
return nil, fmt.Errorf("scheme http is not supported")
}
return &http.BasicAuth{
Username: gitArgs.username,
Password: gitArgs.password,
}, nil
case "https": case "https":
return &http.BasicAuth{ return &http.BasicAuth{
Username: gitArgs.username, Username: gitArgs.username,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment