-
Notifications
You must be signed in to change notification settings - Fork 43
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
1 parent
76a4771
commit 539863d
Showing
14 changed files
with
469 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "maas_resource_pool Data Source - terraform-provider-maas" | ||
subcategory: "" | ||
description: |- | ||
Provides details about an existing MAAS resource pool. | ||
--- | ||
|
||
# maas_resource_pool (Data Source) | ||
|
||
Provides details about an existing MAAS resource pool. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "maas_resource_pool" "test_resource_pool" { | ||
description = "Test description" | ||
name = "test-resource-pool" | ||
} | ||
data "maas_resource_pool" "test_resource_pool" { | ||
name = maas_resource_pool.test_resource_pool.name | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) The name of the resource pool. | ||
|
||
### Read-Only | ||
|
||
- `description` (String) The description of the resource pool. | ||
- `id` (String) The ID of this resource. |
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,44 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "maas_resource_pool Resource - terraform-provider-maas" | ||
subcategory: "" | ||
description: |- | ||
Provides a resource to manage MAAS resource pools. | ||
--- | ||
|
||
# maas_resource_pool (Resource) | ||
|
||
Provides a resource to manage MAAS resource pools. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "maas_resource_pool" "test_resource_pool" { | ||
description = "Test description" | ||
name = "test-resource-pool" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) The name of the resource pool. | ||
|
||
### Optional | ||
|
||
- `description` (String) The description of the resource pool. | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
# Resource pools can be imported using their ID or name. e.g. | ||
$ terraform import maas_resource_pool.test_resource_pool test-resource-pool | ||
``` |
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,8 @@ | ||
resource "maas_resource_pool" "test_resource_pool" { | ||
description = "Test description" | ||
name = "test-resource-pool" | ||
} | ||
|
||
data "maas_resource_pool" "test_resource_pool" { | ||
name = maas_resource_pool.test_resource_pool.name | ||
} |
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,2 @@ | ||
# Resource pools can be imported using their ID or name. e.g. | ||
$ terraform import maas_resource_pool.test_resource_pool test-resource-pool |
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,4 @@ | ||
resource "maas_resource_pool" "test_resource_pool" { | ||
description = "Test description" | ||
name = "test-resource-pool" | ||
} |
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
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,46 @@ | ||
package maas | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
"github.com/maas/gomaasclient/client" | ||
) | ||
|
||
func dataSourceMaasResourcePool() *schema.Resource { | ||
return &schema.Resource{ | ||
Description: "Provides details about an existing MAAS resource pool.", | ||
ReadContext: dataSourceResourcePoolRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"description": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The description of the resource pool.", | ||
}, | ||
"name": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The name of the resource pool.", | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceResourcePoolRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { | ||
client := meta.(*client.Client) | ||
|
||
resourcePool, err := getResourcePool(client, d.Get("name").(string)) | ||
if err != nil { | ||
return diag.FromErr(err) | ||
} | ||
|
||
d.SetId(fmt.Sprintf("%v", resourcePool.ID)) | ||
|
||
d.Set("description", resourcePool.Description) | ||
d.Set("name", resourcePool.Name) | ||
|
||
return nil | ||
} |
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,47 @@ | ||
package maas_test | ||
|
||
import ( | ||
"fmt" | ||
"terraform-provider-maas/maas/testutils" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/maas/gomaasclient/entity" | ||
) | ||
|
||
func TestAccDataSourceMaasResourcePool_basic(t *testing.T) { | ||
|
||
var resourcePool entity.ResourcePool | ||
description := "Test description" | ||
name := acctest.RandomWithPrefix("tf-resource-pool-") | ||
|
||
checks := []resource.TestCheckFunc{ | ||
testAccMaasResourcePoolCheckExists("data.maas_resource_pool.test", &resourcePool), | ||
resource.TestCheckResourceAttr("data.maas_resource_pool.test", "description", description), | ||
resource.TestCheckResourceAttr("data.maas_resource_pool.test", "name", name), | ||
} | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testutils.PreCheck(t) }, | ||
Providers: testutils.TestAccProviders, | ||
CheckDestroy: testAccCheckMaasResourcePoolDestroy, | ||
ErrorCheck: func(err error) error { return err }, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDataSourceMaasResourcePool(description, name), | ||
Check: resource.ComposeTestCheckFunc(checks...), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccDataSourceMaasResourcePool(description string, name string) string { | ||
return fmt.Sprintf(` | ||
%s | ||
data "maas_resource_pool" "test" { | ||
name = maas_resource_pool.test.name | ||
} | ||
`, testAccMaasResourcePool(description, name)) | ||
} |
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
Oops, something went wrong.