Fix not allowed comma, add all allowed special characters

This commit is contained in:
Denis Bardadym 2015-10-19 13:41:30 +03:00
parent 813a66fc2e
commit 25e2ff7b85
2 changed files with 5 additions and 3 deletions

View File

@ -19,8 +19,10 @@ func isalphanumeric(b byte) bool {
} }
// Clean up AMI name by replacing invalid characters with "-" // 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 { func templateCleanAMIName(s string) string {
allowed := []byte{'(', ')', ',', '/', '-', '_', ' '} allowed := []byte{'(', ')', '[', ']', ' ', '.', '/', '-', '\'', '@', '_'}
b := []byte(s) b := []byte(s)
newb := make([]byte, len(b)) newb := make([]byte, len(b))
for i, c := range b { for i, c := range b {

View File

@ -5,8 +5,8 @@ import (
) )
func TestAMITemplatePrepare_clean(t *testing.T) { func TestAMITemplatePrepare_clean(t *testing.T) {
origName := "AMZamz09(),/-_:&^ $%" origName := "AMZamz09()./-_:&^ $%[]#'@"
expected := "AMZamz09(),/-_--- --" expected := "AMZamz09()./-_--- --[]-'@"
name := templateCleanAMIName(origName) name := templateCleanAMIName(origName)