Skip to content

Commit 8bc0344

Browse files
WodansSonkatbyte
andauthored
* Initial check-in * Add ovmss sku spilt func * update recoveryservices and add documentation * update vendor * go mod vendor * update test case to remove depricated field * Remove support for extensions * Add note to documentation about extension support * Split Capacity out of sku_name * Update sku parsing due to spliting out capacity * Fix comment format * Add retry logic * Update error message for create retry * Added case for unretryable in retry else case * Update website/docs/r/orchestrated_virtual_machine_scale_set.html.markdown Co-authored-by: kt <kt@katbyte.me> * Update website/docs/r/orchestrated_virtual_machine_scale_set.html.markdown Co-authored-by: kt <kt@katbyte.me> * Make instances optional and computed * Update err msg to match main * Change field name to termination_notification * Add TODO note for 3.0 Co-authored-by: kt <kt@katbyte.me>
1 parent 7266d2d commit 8bc0344

8 files changed

+6904
-138
lines changed

helpers/azure/sku.go

+50
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import (
44
"fmt"
55
"strconv"
66
"strings"
7+
8+
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2021-07-01/compute"
9+
"github.com/hashicorp/terraform-provider-azurerm/utils"
710
)
811

912
func SplitSku(sku string) (string, int32, error) {
@@ -20,3 +23,50 @@ func SplitSku(sku string) (string, int32, error) {
2023

2124
return skuParts[0], int32(capacity), nil
2225
}
26+
27+
func ExpandOrchestratedVirtualMachineScaleSetSku(input string, capacity int) (*compute.Sku, error) {
28+
skuParts := strings.Split(input, "_")
29+
30+
if len(skuParts) < 2 || strings.Contains(input, "__") || strings.Contains(input, " ") {
31+
return nil, fmt.Errorf("'sku_name'(%q) is not formatted properly.", input)
32+
}
33+
34+
sku := &compute.Sku{
35+
Name: utils.String(input),
36+
Capacity: utils.Int64(int64(capacity)),
37+
Tier: utils.String("Standard"),
38+
}
39+
40+
return sku, nil
41+
}
42+
43+
func FlattenOrchestratedVirtualMachineScaleSetSku(input *compute.Sku) (*string, error) {
44+
var skuName string
45+
if input != nil && input.Name != nil {
46+
if strings.HasPrefix(strings.ToLower(*input.Name), "standard") {
47+
skuName = *input.Name
48+
} else {
49+
skuName = fmt.Sprintf("Standard_%s", *input.Name)
50+
}
51+
52+
return &skuName, nil
53+
}
54+
55+
return nil, fmt.Errorf("Sku struct 'name' is nil")
56+
}
57+
58+
func ValidateOrchestratedVirtualMachineScaleSetSku(input interface{}, key string) (warnings []string, errors []error) {
59+
v, ok := input.(string)
60+
if !ok {
61+
errors = append(errors, fmt.Errorf("expected %q to be a string", key))
62+
return
63+
}
64+
65+
skuParts := strings.Split(v, "_")
66+
67+
if len(skuParts) < 2 || strings.Contains(v, "__") || strings.Contains(v, " ") {
68+
errors = append(errors, fmt.Errorf("%q(%q) is not formatted properly.", key, v))
69+
}
70+
71+
return
72+
}

0 commit comments

Comments
 (0)