Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tailscale: update state after modification functions for resources #362

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tailscale/resource_device_authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func resourceDeviceAuthorizationCreate(ctx context.Context, d *schema.ResourceDa
}

d.SetId(deviceID)
return nil
return resourceDeviceAuthorizationRead(ctx, d, m)
}

func resourceDeviceAuthorizationUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
Expand Down Expand Up @@ -109,7 +109,7 @@ func resourceDeviceAuthorizationUpdate(ctx context.Context, d *schema.ResourceDa
}

d.Set("authorized", true)
return nil
return resourceDeviceAuthorizationRead(ctx, d, m)
}

func resourceDeviceAuthorizationDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
Expand Down
4 changes: 2 additions & 2 deletions tailscale/resource_device_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func resourceDeviceKeyCreate(ctx context.Context, d *schema.ResourceData, m inte
}

d.SetId(deviceID)
return nil
return resourceDeviceKeyRead(ctx, d, m)
}

func resourceDeviceKeyDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
Expand Down Expand Up @@ -106,5 +106,5 @@ func resourceDeviceKeyUpdate(ctx context.Context, d *schema.ResourceData, m inte
return diagnosticsError(err, "failed to update device key")
}

return nil
return resourceDeviceKeyRead(ctx, d, m)
}
4 changes: 2 additions & 2 deletions tailscale/resource_device_subnet_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func resourceDeviceSubnetRoutesCreate(ctx context.Context, d *schema.ResourceDat
}

d.SetId(createUUID())
return nil
return resourceDeviceSubnetRoutesRead(ctx, d, m)
}

func resourceDeviceSubnetRoutesUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
Expand All @@ -82,7 +82,7 @@ func resourceDeviceSubnetRoutesUpdate(ctx context.Context, d *schema.ResourceDat
return diagnosticsError(err, "Failed to set device subnet routes")
}

return nil
return resourceDeviceSubnetRoutesRead(ctx, d, m)
}

func resourceDeviceSubnetRoutesDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
Expand Down
4 changes: 2 additions & 2 deletions tailscale/resource_device_tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func resourceDeviceTagsCreate(ctx context.Context, d *schema.ResourceData, m int
}

d.SetId(deviceID)
return nil
return resourceDeviceTagsRead(ctx, d, m)
}

func resourceDeviceTagsUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
Expand All @@ -95,7 +95,7 @@ func resourceDeviceTagsUpdate(ctx context.Context, d *schema.ResourceData, m int
}

d.SetId(deviceID)
return nil
return resourceDeviceTagsRead(ctx, d, m)
}

func resourceDeviceTagsDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
Expand Down
4 changes: 2 additions & 2 deletions tailscale/resource_dns_nameservers.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func resourceDNSNameserversCreate(ctx context.Context, d *schema.ResourceData, m
}

d.SetId(createUUID())
return nil
return resourceDNSNameserversRead(ctx, d, m)
}

func resourceDNSNameserversUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
Expand All @@ -78,7 +78,7 @@ func resourceDNSNameserversUpdate(ctx context.Context, d *schema.ResourceData, m
return diagnosticsError(err, "Failed to set dns nameservers")
}

return nil
return resourceDNSNameserversRead(ctx, d, m)
}

func resourceDNSNameserversDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
Expand Down
4 changes: 2 additions & 2 deletions tailscale/resource_dns_preferences.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func resourceDNSPreferencesCreate(ctx context.Context, d *schema.ResourceData, m
}

d.SetId(createUUID())
return nil
return resourceDNSPreferencesRead(ctx, d, m)
}

func resourceDNSPreferencesUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
Expand All @@ -75,7 +75,7 @@ func resourceDNSPreferencesUpdate(ctx context.Context, d *schema.ResourceData, m
return diagnosticsError(err, "Failed to set dns preferences")
}

return nil
return resourceDNSPreferencesRead(ctx, d, m)
}

func resourceDNSPreferencesDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
Expand Down
4 changes: 2 additions & 2 deletions tailscale/resource_dns_search_paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func resourceDNSSearchPathsCreate(ctx context.Context, d *schema.ResourceData, m
}

d.SetId(createUUID())
return nil
return resourceDNSSearchPathsRead(ctx, d, m)
}

func resourceDNSSearchPathsUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
Expand All @@ -77,7 +77,7 @@ func resourceDNSSearchPathsUpdate(ctx context.Context, d *schema.ResourceData, m
return diagnosticsError(err, "Failed to fetch set search paths")
}

return nil
return resourceDNSSearchPathsRead(ctx, d, m)
}

func resourceDNSSearchPathsDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
Expand Down
2 changes: 1 addition & 1 deletion tailscale/resource_dns_split_nameservers.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func resourceSplitDNSNameserversCreate(ctx context.Context, d *schema.ResourceDa
}

d.SetId(domain)
return nil
return resourceSplitDNSNameserversRead(ctx, d, m)
}

func resourceSplitDNSNameserversUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
Expand Down
2 changes: 1 addition & 1 deletion tailscale/resource_tailnet_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func resourceTailnetKeyCreate(ctx context.Context, d *schema.ResourceData, m int
return diagnosticsError(err, "Failed to set 'invalid'")
}

return nil
return resourceTailnetKeyRead(ctx, d, m)
}

func resourceTailnetKeyDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_tailnet_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ func testTailnetKeyStruct(reusable bool) tailscale.Key {

func setKeyStep(reusable bool, recreateIfInvalid string) resource.TestStep {
return resource.TestStep{
PreConfig: func() {
testServer.ResponseBody = testTailnetKeyStruct(reusable)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change just makes sure the server is ready to respond with the expected data immediately since we now do a Read after the Create.

},
ResourceName: "tailscale_tailnet_key.example_key",
Config: fmt.Sprintf(`
resource "tailscale_tailnet_key" "example_key" {
Expand Down
Loading