Skip to content

Commit

Permalink
export
Browse files Browse the repository at this point in the history
  • Loading branch information
nopg committed Mar 23, 2023
1 parent 13e5115 commit 47fa491
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package main

import (
"bufio"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
"strings"
Expand Down Expand Up @@ -59,6 +61,27 @@ func cleanup(c *cli.Context) error {
return nil
}

// Export ConfigletBuilder
func export(c *cli.Context) error {
cvpClient := c.App.Metadata["client"].(*client.CvpClient)
reader := bufio.NewReader(os.Stdin)
fmt.Print("Builder Name: ")
response, err := reader.ReadString('\n')
if err != nil {
log.Fatal(err)
}
response = strings.TrimSpace(response)
builder, err := cvpClient.API.GetConfigletBuilderByName(response)
if err != nil {
log.Fatal(err)
}
fmt.Println(builder)
fout, _ := json.MarshalIndent(builder, "", " ")
_ = ioutil.WriteFile("test.json", fout, 0644)

return nil
}

// Login to CVP
func login(c *cli.Context) error {
ip := c.String("ip")
Expand Down Expand Up @@ -123,6 +146,12 @@ func main() {
Usage: "Cleanup unused configlets in CloudVision",
Action: cleanup,
},
{
Before: login,
Name: "export",
Usage: "Export ConfigletBuilder",
Action: export,
},
},
}
if err := app.Run(os.Args); err != nil {
Expand Down

0 comments on commit 47fa491

Please sign in to comment.