-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
131 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
internal/services/storage/validate/storage_account_tags.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package validate | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
func StorageAccountTags(v interface{}, _ string) (warnings []string, errors []error) { | ||
tagsMap := v.(map[string]interface{}) | ||
|
||
if len(tagsMap) > 50 { | ||
errors = append(errors, fmt.Errorf("a maximum of 50 tags can be applied to storage account ARM resource")) | ||
} | ||
|
||
for k, v := range tagsMap { | ||
if len(k) > 128 { | ||
errors = append(errors, fmt.Errorf("the maximum length for a tag key is 128 characters: %q is %d characters", k, len(k))) | ||
} | ||
|
||
value, err := TagValueToString(v) | ||
if err != nil { | ||
errors = append(errors, err) | ||
} else if len(value) > 256 { | ||
errors = append(errors, fmt.Errorf("the maximum length for a tag value is 256 characters: the value for %q is %d characters", k, len(value))) | ||
} | ||
} | ||
|
||
return warnings, errors | ||
} | ||
|
||
func TagValueToString(v interface{}) (string, error) { | ||
switch value := v.(type) { | ||
case string: | ||
return value, nil | ||
case int: | ||
return fmt.Sprintf("%d", value), nil | ||
default: | ||
return "", fmt.Errorf("unknown tag type %T in tag value", value) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters