Change func name

This commit is contained in:
Atsushi Ishibashi 2017-10-16 11:45:18 +09:00
parent caa6c9bf22
commit 2da4e4c31d
2 changed files with 4 additions and 4 deletions

View File

@ -18,7 +18,7 @@ func isalphanumeric(b byte) bool {
// Clean up image name by replacing invalid characters with "-"
// truncate up to 63 length, convert to a lower case
func templateCleanAMIName(s string) string {
func templateCleanImageName(s string) string {
re := regexp.MustCompile(`^[a-z][-a-z0-9]{0,61}[a-z0-9]$`)
if re.MatchString(s) {
return s
@ -40,5 +40,5 @@ func templateCleanAMIName(s string) string {
}
var TemplateFuncs = template.FuncMap{
"clean_ami_name": templateCleanAMIName,
"clean_image_name": templateCleanImageName,
}

View File

@ -2,7 +2,7 @@ package googlecompute
import "testing"
func Test_templateCleanAMIName(t *testing.T) {
func Test_templateCleanImageName(t *testing.T) {
vals := []struct {
origName string
expected string
@ -26,7 +26,7 @@ func Test_templateCleanAMIName(t *testing.T) {
}
for _, v := range vals {
name := templateCleanAMIName(v.origName)
name := templateCleanImageName(v.origName)
if name != v.expected {
t.Fatalf("template names do not match: expected %s got %s\n", v.expected, name)
}