Skip to content

Commit

Permalink
Merge pull request #80 from rigup/add-gcloud-ssh-tunneling-support
Browse files Browse the repository at this point in the history
Add support for positional args i.e. after --
  • Loading branch information
DoKan3 authored Jun 14, 2021
2 parents 564ce09 + 29c246a commit d1ca7ec
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions cmd/eiam/gcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ func newCmdGcloud() *cobra.Command {
return err
}



if !options.YesOption {
util.Confirm(map[string]string{
"Project": gcloudCmdConfig.Project,
Expand Down Expand Up @@ -98,11 +100,21 @@ func runGcloudCommand() error {

// There has to be a better way to do this...
util.Logger.Infof("Running: [gcloud %s]\n\n", strings.Join(gcloudCmdArgs, " "))
cmdArgs := append(
gcloudCmdArgs,
"--impersonate-service-account", gcloudCmdConfig.ServiceAccountEmail,
"--verbosity=error",
)

gcloudOpts := gcloudCmdArgs
positionalArgs := []string{}
for i, v := range gcloudCmdArgs {
if v == "--" {
gcloudOpts = gcloudCmdArgs[:i]
positionalArgs = gcloudCmdArgs[i:]
break
}
}

cmdArgs := append([]string(nil), gcloudOpts...)
cmdArgs = append(cmdArgs, "--impersonate-service-account", gcloudCmdConfig.ServiceAccountEmail, "--verbosity=error")
cmdArgs = append(cmdArgs, positionalArgs...)

gcloud := viper.GetString("binarypaths.gcloud")
c := exec.Command(gcloud, cmdArgs...)
c.Stdout = os.Stdout
Expand Down

0 comments on commit d1ca7ec

Please sign in to comment.