Merge pull request #8193 from hashicorp/do_7471

remove clean_ami_name and clean_image_name; complete the deprecation …
This commit is contained in:
Megan Marsh 2019-10-04 09:38:12 -07:00 committed by GitHub
commit c581e88581
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 21 deletions

View File

@ -3,8 +3,6 @@ package common
import ( import (
"bytes" "bytes"
"text/template" "text/template"
packertpl "github.com/hashicorp/packer/common/template"
) )
func isalphanumeric(b byte) bool { func isalphanumeric(b byte) bool {
@ -39,5 +37,4 @@ func templateCleanAMIName(s string) string {
var TemplateFuncs = template.FuncMap{ var TemplateFuncs = template.FuncMap{
"clean_resource_name": templateCleanAMIName, "clean_resource_name": templateCleanAMIName,
"clean_ami_name": packertpl.DeprecatedTemplateFunc("clean_ami_name", "clean_resource_name", templateCleanAMIName),
} }

View File

@ -3,8 +3,6 @@ package common
import ( import (
"bytes" "bytes"
"text/template" "text/template"
packertpl "github.com/hashicorp/packer/common/template"
) )
func isValidByteValue(b byte) bool { func isValidByteValue(b byte) bool {
@ -39,5 +37,4 @@ func templateCleanImageName(s string) string {
var TemplateFuncs = template.FuncMap{ var TemplateFuncs = template.FuncMap{
"clean_resource_name": templateCleanImageName, "clean_resource_name": templateCleanImageName,
"clean_image_name": packertpl.DeprecatedTemplateFunc("clean_image_name", "clean_resource_name", templateCleanImageName),
} }

View File

@ -3,8 +3,6 @@ package googlecompute
import ( import (
"strings" "strings"
"text/template" "text/template"
packertpl "github.com/hashicorp/packer/common/template"
) )
func isalphanumeric(b byte) bool { func isalphanumeric(b byte) bool {
@ -37,5 +35,4 @@ func templateCleanImageName(s string) string {
var TemplateFuncs = template.FuncMap{ var TemplateFuncs = template.FuncMap{
"clean_resource_name": templateCleanImageName, "clean_resource_name": templateCleanImageName,
"clean_image_name": packertpl.DeprecatedTemplateFunc("clean_image_name", "clean_resource_name", templateCleanImageName),
} }

View File

@ -1,7 +1,9 @@
package yandex package yandex
import "strings" import (
import "text/template" "strings"
"text/template"
)
func isalphanumeric(b byte) bool { func isalphanumeric(b byte) bool {
if '0' <= b && b <= '9' { if '0' <= b && b <= '9' {
@ -13,9 +15,9 @@ func isalphanumeric(b byte) bool {
return false return false
} }
// Clean up image name by replacing invalid characters with "-" // Clean up resource name by replacing invalid characters with "-"
// and converting upper cases to lower cases // and converting upper cases to lower cases
func templateCleanImageName(s string) string { func templateCleanResourceName(s string) string {
if reImageFamily.MatchString(s) { if reImageFamily.MatchString(s) {
return s return s
} }
@ -32,5 +34,5 @@ func templateCleanImageName(s string) string {
} }
var TemplateFuncs = template.FuncMap{ var TemplateFuncs = template.FuncMap{
"clean_image_name": templateCleanImageName, "clean_resource_name": templateCleanResourceName,
} }

View File

@ -41,7 +41,7 @@ Here is a full list of the available functions for reference.
will convert upper cases to lower cases and replace illegal characters with will convert upper cases to lower cases and replace illegal characters with
a "-" character. Example: a "-" character. Example:
`"mybuild-{{isotime | clean_image_name}}"` will become `"mybuild-{{isotime | clean_resource_name}}"` will become
`mybuild-2017-10-18t02-06-30z`. `mybuild-2017-10-18t02-06-30z`.
Note: Valid Azure image names must match the regex Note: Valid Azure image names must match the regex
@ -57,6 +57,9 @@ Here is a full list of the available functions for reference.
clean_resource_name}}"` will cause your build to fail because the image clean_resource_name}}"` will cause your build to fail because the image
name will start with a number, which is why in the above example we prepend name will start with a number, which is why in the above example we prepend
the isotime with "mybuild". the isotime with "mybuild".
Exact behavior of `clean_resource_name` will depend on which builder it is
being applied to; refer to build-specific docs below for more detail on how
each function will behave.
- `env` - Returns environment variables. See example in [using home - `env` - Returns environment variables. See example in [using home
variable](/docs/templates/user-variables.html#using-home-variable) variable](/docs/templates/user-variables.html#using-home-variable)
- `isotime [FORMAT]` - UTC time, which can be - `isotime [FORMAT]` - UTC time, which can be
@ -80,19 +83,19 @@ Here is a full list of the available functions for reference.
#### Specific to Amazon builders: #### Specific to Amazon builders:
- `clean_ami_name` - DEPRECATED use `clean_resource_name` instead - AMI names - `clean_resource_name` - AMI names
can only contain certain characters. This function will replace illegal can only contain certain characters. This function will replace illegal
characters with a '-" character. Example usage since ":" is not a legal AMI characters with a '-" character. Example usage since ":" is not a legal AMI
name is: `{{isotime | clean_ami_name}}`. name is: `{{isotime | clean_resource_name}}`.
#### Specific to Google Compute builders: #### Specific to Google Compute builders:
- `clean_image_name` - DEPRECATED use `clean_resource_name` instead - GCE - `clean_resource_name` - GCE
image names can only contain certain characters and the maximum length is image names can only contain certain characters and the maximum length is
63. This function will convert upper cases to lower cases and replace 63. This function will convert upper cases to lower cases and replace
illegal characters with a "-" character. Example: illegal characters with a "-" character. Example:
`"mybuild-{{isotime | clean_image_name}}"` will become `"mybuild-{{isotime | clean_resource_name}}"` will become
`mybuild-2017-10-18t02-06-30z`. `mybuild-2017-10-18t02-06-30z`.
Note: Valid GCE image names must match the regex Note: Valid GCE image names must match the regex
@ -107,12 +110,12 @@ Here is a full list of the available functions for reference.
#### Specific to Azure builders: #### Specific to Azure builders:
- `clean_image_name` - DEPRECATED use `clean_resource_name` instead - Azure - `clean_resource_name` - Azure
managed image names can only contain certain characters and the maximum managed image names can only contain certain characters and the maximum
length is 80. This function will replace illegal characters with a "-" length is 80. This function will replace illegal characters with a "-"
character. Example: character. Example:
`"mybuild-{{isotime | clean_image_name}}"` will become `"mybuild-{{isotime | clean_resource_name}}"` will become
`mybuild-2017-10-18t02-06-30z`. `mybuild-2017-10-18t02-06-30z`.
Note: Valid Azure image names must match the regex Note: Valid Azure image names must match the regex