Skip to content

Commit

Permalink
Merge pull request #1086 from Sonlis/refactor/use-updated-get-method
Browse files Browse the repository at this point in the history
Refactor/use updated get method
  • Loading branch information
Tinyblargon authored Sep 1, 2024
2 parents 356b2e8 + ebb0196 commit f027071
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
12 changes: 12 additions & 0 deletions docs/resources/pool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Pool Resource

This resource creates and manages a VM / LXC pool.

## Example Usage

```hcl
resource "proxmox_pool" "example" {
poolid = "example-pool"
comment = "Example of a pool"
}
```
8 changes: 5 additions & 3 deletions proxmox/resource_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,21 @@ func _resourcePoolRead(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("unexpected error when trying to read and parse resource id: %v", err)
}

pool := pxapi.PoolName(poolID)

logger, _ := CreateSubLogger("resource_pool_read")
logger.Info().Str("poolid", poolID).Msg("Reading configuration for poolid")

poolInfo, err := client.GetPoolInfo(poolID)
poolInfo, err := pool.Get(client)
if err != nil {
d.SetId("")
return nil
}

d.SetId(clusterResourceId("pools", poolID))
d.Set("comment", "")
if poolInfo["comment"] != nil {
d.Set("comment", poolInfo["comment"].(string))
if poolInfo.Comment != nil {
d.Set("comment", poolInfo.Comment)
}

// DEBUG print the read result
Expand Down

0 comments on commit f027071

Please sign in to comment.