Skip to content

Commit

Permalink
Allow - in disk snapshot names (#1574)
Browse files Browse the repository at this point in the history
It appears that - was omitted from the possible character in snapshot
names.
It doesn't seem like there is any issue when using - in the name, as
I was able to create snapshots with dashes both from the portal and
through this plugin (with this patch applied).
  • Loading branch information
CoRfr authored and tombuildsstuff committed Jul 15, 2018
1 parent ae2afa1 commit f3eaec9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions azurerm/resource_arm_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ func resourceArmSnapshotDelete(d *schema.ResourceData, meta interface{}) error {
}

func validateSnapshotName(v interface{}, k string) (ws []string, errors []error) {
// a-z, A-Z, 0-9 and _. The max name length is 80
// a-z, A-Z, 0-9, _ and -. The max name length is 80
value := v.(string)

r, _ := regexp.Compile("^[A-Za-z0-9_]+$")
r, _ := regexp.Compile("^[A-Za-z0-9_-]+$")
if !r.MatchString(value) {
errors = append(errors, fmt.Errorf("Snapshot Names can only contain alphanumeric characters and underscores."))
}
Expand Down
6 changes: 5 additions & 1 deletion azurerm/resource_arm_snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ func TestSnapshotName_validation(t *testing.T) {
},
{
Value: "hello-world",
ErrCount: 1,
ErrCount: 0,
},
{
Value: "hello_world",
ErrCount: 0,
},
{
Value: "hello+world",
ErrCount: 1,
},
{
Value: str,
ErrCount: 0,
Expand Down

0 comments on commit f3eaec9

Please sign in to comment.