Skip to content

Commit

Permalink
Add a CLI flag to get dependencies via HTTPS (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
ackintosh authored Nov 15, 2020
1 parent b02c9ba commit 2c239ba
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions cmd/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,35 @@ var upCmd = &cobra.Command{
logger.Info("password = %s", strings.Repeat("x", len(password))) // Do not display the password.
}

pwd, err := os.Getwd()
useHttps, err := cmd.Flags().GetBool("use-https")
if err != nil {
return err
}
logger.Info("use https = %t", useHttps)

homeDir, err := homedir.Dir()
pwd, err := os.Getwd()
if err != nil {
return err
}

identifyPath := filepath.Join(homeDir, ".ssh", identityFile)
isSSH, err := helper.IsAvailableSSH(identifyPath)
homeDir, err := homedir.Dir()
if err != nil {
return err
}
if isSSH {
authProvider = helper.NewAuthProvider(identifyPath, password)
} else {

if useHttps {
authProvider = helper.NewAuthProvider("", "")
} else {
identifyPath := filepath.Join(homeDir, ".ssh", identityFile)
isSSH, err := helper.IsAvailableSSH(identifyPath)
if err != nil {
return err
}
if isSSH {
authProvider = helper.NewAuthProvider(identifyPath, password)
} else {
authProvider = helper.NewAuthProvider("", "")
}
}

updateService := service.NewSync(authProvider, homeDir, pwd, pwd)
Expand All @@ -83,4 +93,5 @@ func initDepCmd() {
upCmd.PersistentFlags().StringP("identity-file", "i", "id_rsa", "set the identity file for SSH")
upCmd.PersistentFlags().StringP("password", "p", "", "set the password for SSH")
upCmd.PersistentFlags().BoolP("cleanup", "c", false, "cleanup cache before exec.")
upCmd.PersistentFlags().BoolP("use-https", "u", false, "use HTTPS to get dependencies.")
}

0 comments on commit 2c239ba

Please sign in to comment.