Skip to content

Commit e2b9976

Browse files
authored
Merge pull request #799 from ovh/dev/aamstutz/update-savings-plans-doc
chore: Uppercase flavors when searching for savings plans in resource ovh_savings_plan
2 parents 4d78720 + 683c902 commit e2b9976

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

ovh/resource_savings_plan.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ func resourceSavingsPlanImport(d *schema.ResourceData, meta interface{}) ([]*sch
120120

121121
func resourceSavingsPlanCreate(d *schema.ResourceData, meta interface{}) error {
122122
serviceName := d.Get("service_name").(string)
123+
flavor := strings.ToUpper(d.Get("flavor").(string))
123124
config := meta.(*Config)
124125

125126
// Retrieve service ID
@@ -153,7 +154,7 @@ func resourceSavingsPlanCreate(d *schema.ResourceData, meta interface{}) error {
153154
return fmt.Errorf("error calling POST %s:\n\t %q", endpoint, err)
154155
}
155156

156-
if d.Get("flavor").(string) == resp.Flavor &&
157+
if flavor == strings.ToUpper(resp.Flavor) &&
157158
d.Get("period").(string) == resp.Period &&
158159
d.Get("size").(int) == resp.Size {
159160
// We found the right savings plan, execute subscription

ovh/resource_savings_plan_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func TestAccResourceSavingsPlan_basic(t *testing.T) {
1717
config := fmt.Sprintf(
1818
`resource "ovh_savings_plan" "sp" {
1919
service_name = "%s"
20-
flavor = "Rancher"
20+
flavor = "b3-8"
2121
period = "P1M"
2222
size = 1
2323
display_name = "%s"
@@ -36,7 +36,7 @@ func TestAccResourceSavingsPlan_basic(t *testing.T) {
3636
Config: config,
3737
Check: resource.ComposeTestCheckFunc(
3838
resource.TestCheckResourceAttr("ovh_savings_plan.sp", "display_name", displayName),
39-
resource.TestCheckResourceAttr("ovh_savings_plan.sp", "flavor", "Rancher"),
39+
resource.TestCheckResourceAttr("ovh_savings_plan.sp", "flavor", "b3-8"),
4040
resource.TestCheckResourceAttr("ovh_savings_plan.sp", "size", "1"),
4141
resource.TestCheckResourceAttr("ovh_savings_plan.sp", "end_date", endDate),
4242
resource.TestCheckResourceAttr("ovh_savings_plan.sp", "period_end_date", endDate),

website/docs/r/savings_plan.html.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ resource "ovh_savings_plan" "plan" {
2424
The following arguments are supported:
2525

2626
* `service_name` - (Required) ID of the public cloud project
27-
* `flavor` - (Required) Savings Plan flavor (e.g. Rancher, C3-4, any instance flavor, ...)
27+
* `flavor` - (Required) Savings Plan flavor (e.g. Rancher, C3-4, any instance flavor, ...).
2828
* `period` - (Required) Periodicity of the Savings Plan
2929
* `size` - (Required) Size of the Savings Plan
3030
* `display_name` - (Required) Custom display name, used in invoices

0 commit comments

Comments
 (0)