From 25e2ff7b85a6d4a7cfc4aa0e24239f2eed703826 Mon Sep 17 00:00:00 2001 From: Denis Bardadym Date: Mon, 19 Oct 2015 13:41:30 +0300 Subject: [PATCH] Fix not allowed comma, add all allowed special characters --- builder/amazon/common/template_funcs.go | 4 +++- builder/amazon/common/template_funcs_test.go | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/builder/amazon/common/template_funcs.go b/builder/amazon/common/template_funcs.go index 30d49fdb4..7a0998b34 100644 --- a/builder/amazon/common/template_funcs.go +++ b/builder/amazon/common/template_funcs.go @@ -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 { diff --git a/builder/amazon/common/template_funcs_test.go b/builder/amazon/common/template_funcs_test.go index e4126bf61..11ad70aac 100644 --- a/builder/amazon/common/template_funcs_test.go +++ b/builder/amazon/common/template_funcs_test.go @@ -5,8 +5,8 @@ import ( ) func TestAMITemplatePrepare_clean(t *testing.T) { - origName := "AMZamz09(),/-_:&^ $%" - expected := "AMZamz09(),/-_--- --" + origName := "AMZamz09()./-_:&^ $%[]#'@" + expected := "AMZamz09()./-_--- --[]-'@" name := templateCleanAMIName(origName)