-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring cmd in download and upload.
- Loading branch information
Otávio Fernandes
committed
Mar 21, 2019
1 parent
f5c0d88
commit bf0cb94
Showing
3 changed files
with
99 additions
and
40 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,43 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
vaulthandler "github.com/otaviof/vault-handler/pkg/vault-handler" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var downloadCmd = &cobra.Command{ | ||
Use: "download", | ||
Run: runDownloadCmd, | ||
Short: "", | ||
Long: ``, | ||
} | ||
|
||
// runDownloadCmd execute the download of secrets from Vault. | ||
func runDownloadCmd(cmd *cobra.Command, args []string) { | ||
var manifest *vaulthandler.Manifest | ||
var err error | ||
|
||
handler := bootstrap() | ||
|
||
for _, manifestFile := range args { | ||
log.Printf("Handling manifest file: '%s'", manifestFile) | ||
|
||
if manifest, err = vaulthandler.NewManifest(manifestFile); err != nil { | ||
log.Fatalf("[ERROR] On parsing manifest: '%s'", err) | ||
} | ||
|
||
if err = handler.Download(manifest); err != nil { | ||
log.Fatalf("[ERROR] During realization of manifest: '%s'", err) | ||
} | ||
} | ||
} | ||
|
||
func init() { | ||
flags := downloadCmd.PersistentFlags() | ||
|
||
flags.String("output-dir", ".", "Output directory.") | ||
|
||
rootCmd.AddCommand(downloadCmd) | ||
} |
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,24 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var uploadCmd = &cobra.Command{ | ||
Use: "upload", | ||
Run: runUploadCmd, | ||
Short: "", | ||
Long: ``, | ||
} | ||
|
||
func runUploadCmd(cmd *cobra.Command, args []string) { | ||
|
||
} | ||
|
||
func init() { | ||
flags := uploadCmd.PersistentFlags() | ||
|
||
flags.String("input-dir", ".", "Input directory.") | ||
|
||
rootCmd.AddCommand(uploadCmd) | ||
} |
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