Skip to content

Commit

Permalink
Merge pull request #680 from ovh/dev/aamstutz/fix-cloud-project-import
Browse files Browse the repository at this point in the history
fix: Retrieve service information when importing/reading ovh_cloud_project
  • Loading branch information
amstuta authored Jul 8, 2024
2 parents 2fb7ff3 + aa0edf5 commit 3b9864e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ovh/resource_cloud_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,20 @@ func resourceCloudProjectRead(d *schema.ResourceData, meta interface{}) error {
d.Set(k, v)
}

// Retrieve order information
serviceObj, err := serviceFromServiceName(config.OVHClient, "cloud/project", serviceName)
if err != nil {
return fmt.Errorf("failed to retrieve cloud project details: %w", err)
}
d.Set("plan", serviceObj.ToSDKv2PlanValue())

// Retrieve subsidiary information
var me MeResponse
if err := config.OVHClient.Get("/me", &me); err != nil {
return fmt.Errorf("error retrieving account information: %w", err)
}
d.Set("ovh_subsidiary", me.OvhSubsidiary)

return nil
}

Expand Down
2 changes: 2 additions & 0 deletions ovh/resource_cloud_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ func TestAccResourceCloudProject_basic(t *testing.T) {
"ovh_cloud_project.cloud", "project_name"),
resource.TestCheckResourceAttrSet(
"ovh_cloud_project.cloud", "urn"),
resource.TestCheckResourceAttr(
"ovh_cloud_project.cloud", "plan.0.plan_code", "project.2018"),
),
},
},
Expand Down

0 comments on commit 3b9864e

Please sign in to comment.