mirror of
https://github.com/hashicorp/packer.git
synced 2026-02-24 02:10:31 -05:00
Add a clean_ami_name template function which will translate illegal
characters in an AMI name to '-'. Example usage would be:
"ami_name": "Ubuntu 12.04 {{isotime | clean_ami_name}}"
16 lines
309 B
Go
16 lines
309 B
Go
package common
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestAMITemplatePrepare_clean(t *testing.T) {
|
|
origName := "AMZamz09(),/-_:&^$%"
|
|
expected := "AMZamz09(),/-_-----"
|
|
|
|
name := templateCleanAMIName(origName)
|
|
|
|
if name != expected {
|
|
t.Fatalf("template names do not match: expected %s got %s\n", expected, name)
|
|
}
|
|
}
|