Skip to content

Commit ed8dd80

Browse files
Merge pull request #2 from netfoundry/debug_logs
Added debug logs and updated README.md
2 parents abc2340 + e74339c commit ed8dd80

9 files changed

+52
-1
lines changed

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ provider "ziti" {
5959

6060
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (see [Requirements](#requirements)).
6161

62+
For local plugin development see [Local Plugin Development](#local-plugin-development) before building the provider.
63+
6264
To compile the provider, run `go install`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.
6365

6466

@@ -88,4 +90,23 @@ To add a new dependency `github.com/author/dependency` to your Terraform provide
8890
```
8991
go get github.com/author/dependency
9092
go mod tidy
91-
```
93+
```
94+
95+
## Local Plugin Development
96+
Add the below snippet at ~/.terraformrc on your machine.
97+
98+
```
99+
provider_installation {
100+
101+
dev_overrides {
102+
# point to local go path for compiled binaries
103+
"netfoundry/ziti" = "/path/to/go/bin"
104+
}
105+
106+
# For all other providers, install them directly from their origin provider
107+
# registries as normal. If you omit this, Terraform will _only_ use
108+
# the dev_overrides block, and so no other providers will be available.
109+
direct {}
110+
}
111+
```
112+
#### NOTE: Do not run terraform init during local development

internal/provider/config_host_v1_resource.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ func (r *hostV1ConfigResource) Create(ctx context.Context, req resource.CreateRe
735735
func (r *hostV1ConfigResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
736736
// Get current state
737737
var state hostV1ConfigResourceModel
738+
tflog.Debug(ctx, "Reading Host Config")
738739
diags := req.State.Get(ctx, &state)
739740
resp.Diagnostics.Append(diags...)
740741
if resp.Diagnostics.HasError() {
@@ -803,6 +804,7 @@ func (r *hostV1ConfigResource) Read(ctx context.Context, req resource.ReadReques
803804
func (r *hostV1ConfigResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
804805
// Retrieve values from plan
805806
var eplan hostV1ConfigResourceModel
807+
tflog.Debug(ctx, "Updating Host Config")
806808
diags := req.Plan.Get(ctx, &eplan)
807809
resp.Diagnostics.Append(diags...)
808810
if resp.Diagnostics.HasError() {
@@ -866,6 +868,7 @@ func (r *hostV1ConfigResource) Update(ctx context.Context, req resource.UpdateRe
866868
func (r *hostV1ConfigResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
867869
// Retrieve values from state
868870
var state hostV1ConfigResourceModel
871+
tflog.Debug(ctx, "Deleting Host Config")
869872
diags := req.State.Get(ctx, &state)
870873
resp.Diagnostics.Append(diags...)
871874
if resp.Diagnostics.HasError() {

internal/provider/config_intercept_v1_resource.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ func (r *interceptV1ConfigResource) Create(ctx context.Context, req resource.Cre
351351
func (r *interceptV1ConfigResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
352352
// Get current state
353353
var state interceptV1ConfigResourceModel
354+
tflog.Debug(ctx, "Reading Intercept Config")
354355
diags := req.State.Get(ctx, &state)
355356
resp.Diagnostics.Append(diags...)
356357
if resp.Diagnostics.HasError() {
@@ -418,6 +419,7 @@ func (r *interceptV1ConfigResource) Read(ctx context.Context, req resource.ReadR
418419
func (r *interceptV1ConfigResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
419420
// Retrieve values from plan
420421
var eplan interceptV1ConfigResourceModel
422+
tflog.Debug(ctx, "Updating Intercept Config")
421423
diags := req.Plan.Get(ctx, &eplan)
422424
resp.Diagnostics.Append(diags...)
423425
if resp.Diagnostics.HasError() {
@@ -481,6 +483,7 @@ func (r *interceptV1ConfigResource) Update(ctx context.Context, req resource.Upd
481483
func (r *interceptV1ConfigResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
482484
// Retrieve values from state
483485
var state interceptV1ConfigResourceModel
486+
tflog.Debug(ctx, "Deleting Intercept Config")
484487
diags := req.State.Get(ctx, &state)
485488
resp.Diagnostics.Append(diags...)
486489
if resp.Diagnostics.HasError() {

internal/provider/edge_router_policy_resource.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
1818
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
1919
"github.com/hashicorp/terraform-plugin-framework/types"
20+
"github.com/hashicorp/terraform-plugin-log/tflog"
2021
"github.com/openziti/edge-api/rest_model"
2122
"github.com/rs/zerolog/log"
2223
"github.com/tidwall/gjson"
@@ -195,6 +196,7 @@ func (r *edgeRouterPolicyResource) Create(ctx context.Context, req resource.Crea
195196
func (r *edgeRouterPolicyResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
196197
// Get current state
197198
var state edgeRouterPolicyResourceModel
199+
tflog.Debug(ctx, "Reading Edge Router Policy")
198200
diags := req.State.Get(ctx, &state)
199201
resp.Diagnostics.Append(diags...)
200202
if resp.Diagnostics.HasError() {
@@ -276,6 +278,7 @@ func (r *edgeRouterPolicyResource) Read(ctx context.Context, req resource.ReadRe
276278
func (r *edgeRouterPolicyResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
277279
// Retrieve values from plan
278280
var eplan edgeRouterPolicyResourceModel
281+
tflog.Debug(ctx, "Updating Edge Router Policy")
279282
diags := req.Plan.Get(ctx, &eplan)
280283
resp.Diagnostics.Append(diags...)
281284
if resp.Diagnostics.HasError() {
@@ -344,6 +347,7 @@ func (r *edgeRouterPolicyResource) Update(ctx context.Context, req resource.Upda
344347
func (r *edgeRouterPolicyResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
345348
// Retrieve values from state
346349
var state edgeRouterPolicyResourceModel
350+
tflog.Debug(ctx, "Deleting Edge Router Policy")
347351
diags := req.State.Get(ctx, &state)
348352
resp.Diagnostics.Append(diags...)
349353
if resp.Diagnostics.HasError() {

internal/provider/edge_router_resource.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
1919
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
2020
"github.com/hashicorp/terraform-plugin-framework/types"
21+
"github.com/hashicorp/terraform-plugin-log/tflog"
2122
"github.com/openziti/edge-api/rest_model"
2223
"github.com/rs/zerolog/log"
2324
"github.com/tidwall/gjson"
@@ -209,6 +210,7 @@ func (r *edgeRouterResource) Create(ctx context.Context, req resource.CreateRequ
209210
func (r *edgeRouterResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
210211
// Get current state
211212
var state edgeRouterResourceModel
213+
tflog.Debug(ctx, "Reading Edge Router")
212214
diags := req.State.Get(ctx, &state)
213215
resp.Diagnostics.Append(diags...)
214216
if resp.Diagnostics.HasError() {
@@ -300,6 +302,7 @@ func (r *edgeRouterResource) Read(ctx context.Context, req resource.ReadRequest,
300302
func (r *edgeRouterResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
301303
// Retrieve values from plan
302304
var eplan edgeRouterResourceModel
305+
tflog.Debug(ctx, "Updating Edge Router")
303306
diags := req.Plan.Get(ctx, &eplan)
304307
resp.Diagnostics.Append(diags...)
305308
if resp.Diagnostics.HasError() {
@@ -366,6 +369,7 @@ func (r *edgeRouterResource) Update(ctx context.Context, req resource.UpdateRequ
366369
func (r *edgeRouterResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
367370
// Retrieve values from state
368371
var state edgeRouterResourceModel
372+
tflog.Debug(ctx, "Deleting Edge Router")
369373
diags := req.State.Get(ctx, &state)
370374
resp.Diagnostics.Append(diags...)
371375
if resp.Diagnostics.HasError() {

internal/provider/identity_resource.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
2121
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
2222
"github.com/hashicorp/terraform-plugin-framework/types"
23+
"github.com/hashicorp/terraform-plugin-log/tflog"
2324
"github.com/openziti/edge-api/rest_model"
2425
"github.com/rs/zerolog/log"
2526
"github.com/tidwall/gjson"
@@ -272,6 +273,7 @@ func (r *identityResource) Create(ctx context.Context, req resource.CreateReques
272273
func (r *identityResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
273274
// Get current state
274275
var state identityResourceModel
276+
tflog.Debug(ctx, "Reading Identity")
275277
diags := req.State.Get(ctx, &state)
276278
resp.Diagnostics.Append(diags...)
277279
if resp.Diagnostics.HasError() {
@@ -396,6 +398,7 @@ func (r *identityResource) Read(ctx context.Context, req resource.ReadRequest, r
396398
func (r *identityResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
397399
// Retrieve values from plan
398400
var eplan identityResourceModel
401+
tflog.Debug(ctx, "Updating Identity")
399402
diags := req.Plan.Get(ctx, &eplan)
400403
resp.Diagnostics.Append(diags...)
401404
if resp.Diagnostics.HasError() {
@@ -477,6 +480,7 @@ func (r *identityResource) Update(ctx context.Context, req resource.UpdateReques
477480
func (r *identityResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
478481
// Retrieve values from state
479482
var state identityResourceModel
483+
tflog.Debug(ctx, "Deleting Identity")
480484
diags := req.State.Get(ctx, &state)
481485
resp.Diagnostics.Append(diags...)
482486
if resp.Diagnostics.HasError() {

internal/provider/service_edge_router_policy_resource.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
1818
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
1919
"github.com/hashicorp/terraform-plugin-framework/types"
20+
"github.com/hashicorp/terraform-plugin-log/tflog"
2021
"github.com/openziti/edge-api/rest_model"
2122
"github.com/rs/zerolog/log"
2223
"github.com/tidwall/gjson"
@@ -196,6 +197,7 @@ func (r *serviceEdgeRouterPolicyResource) Create(ctx context.Context, req resour
196197
func (r *serviceEdgeRouterPolicyResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
197198
// Get current state
198199
var state serviceEdgeRouterPolicyResourceModel
200+
tflog.Debug(ctx, "Reading Service Edge Router Policy")
199201
diags := req.State.Get(ctx, &state)
200202
resp.Diagnostics.Append(diags...)
201203
if resp.Diagnostics.HasError() {
@@ -277,6 +279,7 @@ func (r *serviceEdgeRouterPolicyResource) Read(ctx context.Context, req resource
277279
func (r *serviceEdgeRouterPolicyResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
278280
// Retrieve values from plan
279281
var eplan serviceEdgeRouterPolicyResourceModel
282+
tflog.Debug(ctx, "Updating Service Edge Router Policy")
280283
diags := req.Plan.Get(ctx, &eplan)
281284
resp.Diagnostics.Append(diags...)
282285
if resp.Diagnostics.HasError() {
@@ -345,6 +348,7 @@ func (r *serviceEdgeRouterPolicyResource) Update(ctx context.Context, req resour
345348
func (r *serviceEdgeRouterPolicyResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
346349
// Retrieve values from state
347350
var state serviceEdgeRouterPolicyResourceModel
351+
tflog.Debug(ctx, "Deleting Service Edge Router Policy")
348352
diags := req.State.Get(ctx, &state)
349353
resp.Diagnostics.Append(diags...)
350354
if resp.Diagnostics.HasError() {

internal/provider/service_policy_resource.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
1818
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
1919
"github.com/hashicorp/terraform-plugin-framework/types"
20+
"github.com/hashicorp/terraform-plugin-log/tflog"
2021
"github.com/openziti/edge-api/rest_model"
2122
"github.com/rs/zerolog/log"
2223
"github.com/tidwall/gjson"
@@ -224,6 +225,7 @@ func (r *servicePolicyResource) Create(ctx context.Context, req resource.CreateR
224225
func (r *servicePolicyResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
225226
// Get current state
226227
var state servicePolicyResourceModel
228+
tflog.Debug(ctx, "Reading Service Policy")
227229
diags := req.State.Get(ctx, &state)
228230
resp.Diagnostics.Append(diags...)
229231
if resp.Diagnostics.HasError() {
@@ -317,6 +319,7 @@ func (r *servicePolicyResource) Read(ctx context.Context, req resource.ReadReque
317319
func (r *servicePolicyResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
318320
// Retrieve values from plan
319321
var eplan servicePolicyResourceModel
322+
tflog.Debug(ctx, "Updating Service Policy")
320323
diags := req.Plan.Get(ctx, &eplan)
321324
resp.Diagnostics.Append(diags...)
322325
if resp.Diagnostics.HasError() {
@@ -395,6 +398,7 @@ func (r *servicePolicyResource) Update(ctx context.Context, req resource.UpdateR
395398
func (r *servicePolicyResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
396399
// Retrieve values from state
397400
var state servicePolicyResourceModel
401+
tflog.Debug(ctx, "Deleting Service Policy")
398402
diags := req.State.Get(ctx, &state)
399403
resp.Diagnostics.Append(diags...)
400404
if resp.Diagnostics.HasError() {

internal/provider/service_resource.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
2020
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
2121
"github.com/hashicorp/terraform-plugin-framework/types"
22+
"github.com/hashicorp/terraform-plugin-log/tflog"
2223
"github.com/openziti/edge-api/rest_model"
2324
"github.com/rs/zerolog/log"
2425
"github.com/tidwall/gjson"
@@ -215,6 +216,7 @@ func (r *serviceResource) Create(ctx context.Context, req resource.CreateRequest
215216
func (r *serviceResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
216217
// Get current state
217218
var state serviceResourceModel
219+
tflog.Debug(ctx, "Reading Service")
218220
diags := req.State.Get(ctx, &state)
219221
resp.Diagnostics.Append(diags...)
220222
if resp.Diagnostics.HasError() {
@@ -304,6 +306,7 @@ func (r *serviceResource) Read(ctx context.Context, req resource.ReadRequest, re
304306
func (r *serviceResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
305307
// Retrieve values from plan
306308
var eplan serviceResourceModel
309+
tflog.Debug(ctx, "Updating Service")
307310
diags := req.Plan.Get(ctx, &eplan)
308311
resp.Diagnostics.Append(diags...)
309312
if resp.Diagnostics.HasError() {
@@ -376,6 +379,7 @@ func (r *serviceResource) Update(ctx context.Context, req resource.UpdateRequest
376379
func (r *serviceResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
377380
// Retrieve values from state
378381
var state serviceResourceModel
382+
tflog.Debug(ctx, "Deleting Service")
379383
diags := req.State.Get(ctx, &state)
380384
resp.Diagnostics.Append(diags...)
381385
if resp.Diagnostics.HasError() {

0 commit comments

Comments
 (0)