diff --git a/CHANGELOG.md b/CHANGELOG.md index d068cbf..663e7a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,15 @@ ... +## 0.1.1 (October 16, 2023) + +FIXES: + +- Make provider not ruin whole Terraform run + ## 0.1.0 (October 16, 2023) FEATURES: -* **New Resource:** `ipam_pool` -* **New Resource:** `ipam_allocation` +- **New Resource:** `ipam_pool` +- **New Resource:** `ipam_allocation` diff --git a/docs/index.md b/docs/index.md index dba88a4..62cb7c5 100644 --- a/docs/index.md +++ b/docs/index.md @@ -14,9 +14,7 @@ description: |- ```terraform provider "ipam" { - alias = "lan" - - file = "lan.ipam.json" + file = "default.ipam.json" } ``` diff --git a/docs/resources/allocation.md b/docs/resources/allocation.md index c1bf1ae..07f95ad 100644 --- a/docs/resources/allocation.md +++ b/docs/resources/allocation.md @@ -13,25 +13,13 @@ An IPAM Allocation represents an sub-ranges from previously defined IP Pool ## Example Usage ```terraform -resource "ipam_allocation" "foo" { - provider = ipam.lan - - pool_id = ipam_pool.lan.id - size = 16 +resource "ipam_pool" "home" { + cidr = "10.0.0.0/8" } -resource "ipam_allocation" "bar" { - provider = ipam.lan - - pool_id = ipam_pool.lan.id - size = 24 -} - -resource "ipam_allocation" "baz" { - provider = ipam.lan - - pool_id = ipam_pool.lan.id - size = 32 +resource "ipam_allocation" "foo" { + pool_id = ipam_pool.home.id + size = 16 } ``` diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 9ce9b5d..440bd3c 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -1,5 +1,3 @@ provider "ipam" { - alias = "lan" - - file = "lan.ipam.json" + file = "default.ipam.json" } diff --git a/examples/resources/ipam_allocation/resource.tf b/examples/resources/ipam_allocation/resource.tf index 5e75f49..0987d77 100644 --- a/examples/resources/ipam_allocation/resource.tf +++ b/examples/resources/ipam_allocation/resource.tf @@ -1,20 +1,8 @@ -resource "ipam_allocation" "foo" { - provider = ipam.lan - - pool_id = ipam_pool.lan.id - size = 16 +resource "ipam_pool" "home" { + cidr = "10.0.0.0/8" } -resource "ipam_allocation" "bar" { - provider = ipam.lan - - pool_id = ipam_pool.lan.id - size = 24 -} - -resource "ipam_allocation" "baz" { - provider = ipam.lan - - pool_id = ipam_pool.lan.id - size = 32 +resource "ipam_allocation" "foo" { + pool_id = ipam_pool.home.id + size = 16 } diff --git a/internal/provider/allocation_resource.go b/internal/provider/allocation_resource.go index b207bb2..a6069cf 100644 --- a/internal/provider/allocation_resource.go +++ b/internal/provider/allocation_resource.go @@ -126,7 +126,7 @@ func (r *AllocationResource) Create(ctx context.Context, req resource.CreateRequ // } prefix, err := r.ipam.AcquireChildPrefix(ctx, data.PoolId.ValueString(), uint8(data.Size.ValueInt64())) if err != nil { - panic(err) + resp.Diagnostics.AddError("API Error Creating Resource", fmt.Sprintf("... details ... %s", err)) } // For the purposes of this example code, hardcoding a response value to @@ -203,7 +203,7 @@ func (r *AllocationResource) Delete(ctx context.Context, req resource.DeleteRequ } err := r.ipam.ReleaseChildPrefix(ctx, child) if err != nil { - panic(err) + resp.Diagnostics.AddError("API Error Deleting Resource", fmt.Sprintf("... details ... %s", err)) } } diff --git a/internal/provider/pool_resource.go b/internal/provider/pool_resource.go index f25a0ca..93c1629 100644 --- a/internal/provider/pool_resource.go +++ b/internal/provider/pool_resource.go @@ -104,7 +104,7 @@ func (r *PoolResource) Create(ctx context.Context, req resource.CreateRequest, r // } _, err := r.ipam.NewPrefix(ctx, data.CIDR.ValueString()) if err != nil { - panic(err) + resp.Diagnostics.AddError("API Error Creating Resource", fmt.Sprintf("... details ... %s", err)) } // For the purposes of this example code, hardcoding a response value to @@ -173,7 +173,7 @@ func (r *PoolResource) Delete(ctx context.Context, req resource.DeleteRequest, r // provider client data and make a call using it. _, err := r.ipam.DeletePrefix(ctx, data.CIDR.ValueString()) if err != nil { - panic(err) + resp.Diagnostics.AddError("API Error Deleting Resource", fmt.Sprintf("... details ... %s", err)) } }