-
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.
Merge pull request #3 from chroju/0.2.0
0.2.0
- Loading branch information
Showing
11 changed files
with
303 additions
and
130 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# CHANGELOG | ||
|
||
## 0.2.0 (2021/02/15) | ||
|
||
* Add `version` subcommand | ||
* Improve `keys` subcommand | ||
* Display the parameter types. | ||
* Improve `get` subcommand | ||
* Instead of displaying encrypted values as they are, display them as `(encrypted)` string. | ||
* For multi-line values, display the line feed code as a string of `\n`. | ||
* Improve `set` subcommand | ||
* Add confirmation prompt before overwriting existing value. | ||
* Add `--force` option. | ||
* Improve `del` subcommand | ||
* Add confirmation prompt before deleting. | ||
* Add `--force` option. | ||
* Support `AWS_DEFAULT_REGION` environment variable | ||
* Add `--region` option | ||
* Add `--profile` option | ||
* Fix some bugs. | ||
|
||
## 0.1.0 (2019/10/13) | ||
|
||
* Initial version |
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 |
---|---|---|
@@ -1,41 +1,61 @@ | ||
package cmd | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/chroju/parade/ssmctl" | ||
"github.com/fatih/color" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
isForceDelete bool | ||
// DelCommand is the command to delete key value | ||
DelCommand = &cobra.Command{ | ||
Use: "del", | ||
Short: "Delete key value", | ||
Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
del(args) | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return del(args) | ||
}, | ||
} | ||
) | ||
|
||
func del(args []string) { | ||
func del(args []string) error { | ||
key := args[0] | ||
|
||
ssmManager, err := ssmctl.New() | ||
param, err := ssmManager.GetParameter(key, false) | ||
if err != nil { | ||
fmt.Fprintln(ErrWriter, err) | ||
os.Exit(1) | ||
fmt.Fprintln(ErrWriter, color.YellowString(fmt.Sprintf("WARN: `%s` is not found. Nothing to do.", key))) | ||
return nil | ||
} | ||
|
||
if !isForceDelete { | ||
fmt.Fprintf(ErrWriter, "Delete `%s` (value: %s) ? (Y/n)\n", key, param.Value) | ||
scanner := bufio.NewScanner(os.Stdin) | ||
for scanner.Scan() { | ||
yn := scanner.Text() | ||
|
||
if yn == "Y" || yn == "y" { | ||
break | ||
} else if yn == "N" || yn == "n" { | ||
return nil | ||
} else { | ||
fmt.Fprint(ErrWriter, "(Y/n) ?") | ||
} | ||
} | ||
} | ||
|
||
if err = ssmManager.DeleteParameter(key); err != nil { | ||
if err := ssmManager.DeleteParameter(key); err != nil { | ||
fmt.Fprintln(ErrWriter, color.RedString(ErrMsgDeleteParameter)) | ||
fmt.Fprintln(ErrWriter, err) | ||
os.Exit(1) | ||
return err | ||
} | ||
|
||
fmt.Fprintln(ErrWriter, "done.") | ||
return nil | ||
} | ||
|
||
func init() { | ||
DelCommand.PersistentFlags().BoolVarP(&isForceDelete, "force", "f", false, "Force deletion of key and 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
Oops, something went wrong.