Skip to content

Commit b1aa30e

Browse files
authored
Merge pull request #2 from solsson/check-command
Add a subcommand to check credentials and exit
2 parents a587531 + f3a99e1 commit b1aa30e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

cmd/git-remote-https+iap/main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,18 @@ var (
5151
Short: "Configure IAP for a given repository",
5252
Run: configureIAP,
5353
}
54+
55+
checkCmd = &cobra.Command{
56+
Use: "check remote url",
57+
Short: "Refresh token for remote url if needed, then exit",
58+
Run: check,
59+
}
5460
)
5561

5662
func init() {
5763
rootCmd.AddCommand(versionCmd)
5864
rootCmd.AddCommand(installProtocolCmd)
65+
rootCmd.AddCommand(checkCmd)
5966

6067
configureCmd.Flags().StringVar(&repoURL, "repoURL", "", "URL of the git repository to configure (required)")
6168
configureCmd.MarkFlagRequired("repoURL")
@@ -89,6 +96,13 @@ func execute(cmd *cobra.Command, args []string) {
8996
git.PassThruRemoteHTTPSHelper(remote, url)
9097
}
9198

99+
func check(cmd *cobra.Command, args []string) {
100+
remote, url := args[0], args[1]
101+
log.Debug().Msgf("%s check %s %s", binaryName, remote, url)
102+
103+
handleIAPAuthCookieFor(url)
104+
}
105+
92106
func printVersion(cmd *cobra.Command, args []string) {
93107
fmt.Printf("%s %s\n", binaryName, version)
94108
}

0 commit comments

Comments
 (0)