Fix not allowed comma, add all allowed special characters
This commit is contained in:
parent
813a66fc2e
commit
25e2ff7b85
|
@ -19,8 +19,10 @@ func isalphanumeric(b byte) bool {
|
|||
}
|
||||
|
||||
// Clean up AMI name by replacing invalid characters with "-"
|
||||
// For allowed characters see docs for Name parameter
|
||||
// at http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateImage.html
|
||||
func templateCleanAMIName(s string) string {
|
||||
allowed := []byte{'(', ')', ',', '/', '-', '_', ' '}
|
||||
allowed := []byte{'(', ')', '[', ']', ' ', '.', '/', '-', '\'', '@', '_'}
|
||||
b := []byte(s)
|
||||
newb := make([]byte, len(b))
|
||||
for i, c := range b {
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
)
|
||||
|
||||
func TestAMITemplatePrepare_clean(t *testing.T) {
|
||||
origName := "AMZamz09(),/-_:&^ $%"
|
||||
expected := "AMZamz09(),/-_--- --"
|
||||
origName := "AMZamz09()./-_:&^ $%[]#'@"
|
||||
expected := "AMZamz09()./-_--- --[]-'@"
|
||||
|
||||
name := templateCleanAMIName(origName)
|
||||
|
||||
|
|
Loading…
Reference in New Issue