Skip to content

Commit

Permalink
chore: Uppercase flavors when searching for savings plans in resource…
Browse files Browse the repository at this point in the history
… ovh_savings_plan
  • Loading branch information
Arthur Amstutz committed Jan 10, 2025
1 parent 4d78720 commit 683c902
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion ovh/resource_savings_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func resourceSavingsPlanImport(d *schema.ResourceData, meta interface{}) ([]*sch

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

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

if d.Get("flavor").(string) == resp.Flavor &&
if flavor == strings.ToUpper(resp.Flavor) &&
d.Get("period").(string) == resp.Period &&
d.Get("size").(int) == resp.Size {
// We found the right savings plan, execute subscription
Expand Down
4 changes: 2 additions & 2 deletions ovh/resource_savings_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestAccResourceSavingsPlan_basic(t *testing.T) {
config := fmt.Sprintf(
`resource "ovh_savings_plan" "sp" {
service_name = "%s"
flavor = "Rancher"
flavor = "b3-8"
period = "P1M"
size = 1
display_name = "%s"
Expand All @@ -36,7 +36,7 @@ func TestAccResourceSavingsPlan_basic(t *testing.T) {
Config: config,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("ovh_savings_plan.sp", "display_name", displayName),
resource.TestCheckResourceAttr("ovh_savings_plan.sp", "flavor", "Rancher"),
resource.TestCheckResourceAttr("ovh_savings_plan.sp", "flavor", "b3-8"),
resource.TestCheckResourceAttr("ovh_savings_plan.sp", "size", "1"),
resource.TestCheckResourceAttr("ovh_savings_plan.sp", "end_date", endDate),
resource.TestCheckResourceAttr("ovh_savings_plan.sp", "period_end_date", endDate),
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/savings_plan.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ resource "ovh_savings_plan" "plan" {
The following arguments are supported:

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

0 comments on commit 683c902

Please sign in to comment.