diff --git a/README.md b/README.md index 568e60c..145fb5f 100644 --- a/README.md +++ b/README.md @@ -78,20 +78,24 @@ database 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b created ### get secure connection bundle ``` -./bin/astra-cli db secBundle 3c577e51-4ff5-4551-86a4-41d475c61822 -file secureBundle.zip saved 12072 bytes written +./bin/astra-cli db secBundle 3c577e51-4ff5-4551-86a4-41d475c61822 -d external -l external.zip +file external.zip saved 12072 bytes written +./bin/astra-cli db secBundle 3c577e51-4ff5-4551-86a4-41d475c61822 -d internal -l internal.zip +file internal.zip saved 12066 bytes written +./bin/astra-cli db secBundle 3c577e51-4ff5-4551-86a4-41d475c61822 -d proxy-internal -l proxy-internal.zip +file proxy-internal.zip saved 348 bytes written +./bin/astra-cli db secBundle 3c577e51-4ff5-4551-86a4-41d475c61822 -d proxy-external -l proxy-external.zip +file proxy-external.zip saved 339 bytes written ``` -### get secure connection bundle url +### get secure connection bundle URLs ``` -./bin/astra-cli db secBundle 3c577e51-4ff5-4551-86a4-41d475c61822 -o json -{ - "downloadURL": "changed", - "downloadURLInternal": "changed", - "downloadURLMigrationProxy": "changed", - "downloadURLMigrationProxyInternal": "changed" -} +./bin/astra-cli db secBundle 3c577e51-4ff5-4551-86a4-41d475c61822 -o list + external bundle: changed + internal bundle: changed + external proxy: changed + internal proxy: changed ``` ### listing databases diff --git a/cmd/db/secBundle.go b/cmd/db/secBundle.go index 5b4142e..6301cc0 100644 --- a/cmd/db/secBundle.go +++ b/cmd/db/secBundle.go @@ -28,9 +28,11 @@ import ( var secBundleFmt string var secBundleLoc string +var secBundleDownloadType string func init() { SecBundleCmd.Flags().StringVarP(&secBundleFmt, "output", "o", "zip", "Output format for report default is zip") + SecBundleCmd.Flags().StringVarP(&secBundleDownloadType, "download-type", "d", "external", "Bundle type to download external, internal, proxy-external and proxy-internal available. Only works with -o zip") SecBundleCmd.Flags().StringVarP(&secBundleLoc, "location", "l", "secureBundle.zip", "location of bundle to download to if using zip format. ignore if using json") } @@ -63,7 +65,20 @@ func executeSecBundle(args []string, login func() (pkg.Client, error)) (string, } switch secBundleFmt { case "zip": - bytesWritten, err := httputils.DownloadZip(secBundle.DownloadURL, secBundleLoc) + var urlToDownload string + switch secBundleDownloadType { + case "external": + urlToDownload = secBundle.DownloadURL + case "internal": + urlToDownload = secBundle.DownloadURLInternal + case "proxy-external": + urlToDownload = secBundle.DownloadURLMigrationProxy + case "proxy-internal": + urlToDownload = secBundle.DownloadURLMigrationProxyInternal + default: + return "", fmt.Errorf("invalid download type %s passed. valid options are 'external', 'internal', 'proxy-external', 'proxy-internal'", secBundleDownloadType) + } + bytesWritten, err := httputils.DownloadZip(urlToDownload, secBundleLoc) if err != nil { return "", fmt.Errorf("error outputing zip format '%v'", err) } @@ -74,6 +89,13 @@ func executeSecBundle(args []string, login func() (pkg.Client, error)) (string, return "", fmt.Errorf("unexpected error marshaling to json: '%v', Try -output text instead", err) } return string(b), nil + case "list": + return fmt.Sprintf(` + external bundle: %s + internal bundle: %s + external proxy: %s + internal proxy: %s + `, secBundle.DownloadURL, secBundle.DownloadURLInternal, secBundle.DownloadURLMigrationProxy, secBundle.DownloadURLMigrationProxyInternal), nil default: return "", fmt.Errorf("-o %q is not valid option", secBundleFmt) }