-
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 show command to print out decrypted parameters. Update README.md for show command and bump to 1.4.0. Refactor packaging to use one 'param' package.
- Loading branch information
Showing
14 changed files
with
183 additions
and
107 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
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
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
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
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,20 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/willjcj/param/pkg/param" | ||
) | ||
|
||
var showCmd = &cobra.Command{ | ||
Use: "show parameter_name", | ||
Short: "Show a decrypted parameter in the console.", | ||
Long: "Show the specified decrypted SSM Parameter from Paramter Store in your console.", | ||
Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
param.Show(args[0]) | ||
}, | ||
} | ||
|
||
func init() { | ||
RootCmd.AddCommand(showCmd) | ||
} |
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
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,29 @@ | ||
## param show | ||
|
||
Show a decrypted parameter in the console. | ||
|
||
### Synopsis | ||
|
||
Show the specified decrypted SSM Parameter from Paramter Store in your console. | ||
|
||
``` | ||
param show parameter_name [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for show | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--config string config file (default is $HOME/.param.yaml) | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [param](param.md) - Tools to improve Parameter Store on the command line. | ||
|
||
###### Auto generated by spf13/cobra on 14-Jul-2018 |
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,17 @@ | ||
package param | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/atotto/clipboard" | ||
) | ||
|
||
func Copy(name string, verbose bool) { | ||
value := getDecryptedParameter(name) | ||
|
||
clipboard.WriteAll(value) | ||
|
||
if verbose { | ||
fmt.Println(value) | ||
} | ||
} |
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,17 @@ | ||
package param | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/ssm" | ||
) | ||
|
||
func getDecryptedParameter(name string) string { | ||
output, err := service.GetParameter(&ssm.GetParameterInput{ | ||
Name: aws.String(name), | ||
WithDecryption: aws.Bool(true), | ||
}) | ||
if err != nil { | ||
exitErrorf("Unable to describe parameters, %v", err) | ||
} | ||
return *output.Parameter.Value | ||
} |
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
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,11 @@ | ||
package param | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
func Show(name string) { | ||
value := getDecryptedParameter(name) | ||
|
||
fmt.Println(value) | ||
} |
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,22 @@ | ||
package param | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/ssm" | ||
) | ||
|
||
var service = createSSMService() | ||
|
||
func createSSMService() *ssm.SSM { | ||
sess, err := session.NewSession(&aws.Config{ | ||
Region: aws.String("eu-west-1")}, | ||
) | ||
|
||
if err != nil { | ||
exitErrorf("Unable to describe parameters, %v", err) | ||
} | ||
|
||
// Create SSM service client | ||
return ssm.New(sess) | ||
} |
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,20 @@ | ||
package param | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
func exitErrorf(msg string, args ...interface{}) { | ||
fmt.Fprintf(os.Stderr, msg+"\n", args...) | ||
os.Exit(1) | ||
} | ||
|
||
func appendIfMissing(slice []string, s string) []string { | ||
for _, ele := range slice { | ||
if ele == s { | ||
return slice | ||
} | ||
} | ||
return append(slice, s) | ||
} |
Oops, something went wrong.