This repository has been archived by the owner on Jan 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add possibility to execute arbitrary request
- Loading branch information
1 parent
e828198
commit b5e8b53
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"github.com/spf13/cobra" | ||
"github.com/floriankammermann/vcloud-cli/vcdapi" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
var path string | ||
|
||
var requestCmd = &cobra.Command{ | ||
Use: "request", | ||
Short: "execute requests", | ||
Long: "execute requests", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
|
||
if len(path) > 0 { | ||
url := viper.GetString("url") | ||
user := viper.GetString("user") | ||
password := viper.GetString("password") | ||
org := viper.GetString("org") | ||
vcdapi.GetAuthToken(url, user, password, org) | ||
vcdapi.ExecRequest(url, path, nil) | ||
} else { | ||
fmt.Println("you have to provide the path") | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
requestCmd.Flags().StringVarP(&path, "path", "n", "", "url to request") | ||
RootCmd.AddCommand(requestCmd) | ||
} |