diff --git a/go.mod b/go.mod index 6c0962f5..f92d95da 100644 --- a/go.mod +++ b/go.mod @@ -9,8 +9,13 @@ require ( github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 github.com/stretchr/testify v1.9.0 github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a +<<<<<<< HEAD github.com/tailscale/tailscale-client-go v1.17.1-0.20240729175651-90a1e935cc19 github.com/tailscale/tailscale-client-go/v2 v2.0.0-20240801195603-6096900af9df +======= + github.com/tailscale/tailscale-client-go v1.17.0 + github.com/tailscale/tailscale-client-go/v2 v2.0.0-20240801205641-d930be734670 +>>>>>>> bfc4a29 (tailscale: use V2 client for device authorization) golang.org/x/tools v0.23.0 tailscale.com v1.70.0 ) diff --git a/go.sum b/go.sum index 083c5ff5..43fdc05c 100644 --- a/go.sum +++ b/go.sum @@ -188,10 +188,17 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a h1:SJy1Pu0eH1C29XwJucQo73FrleVK6t4kYz4NVhp34Yw= github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a/go.mod h1:DFSS3NAGHthKo1gTlmEcSBiZrRJXi28rLNd/1udP1c8= +<<<<<<< HEAD github.com/tailscale/tailscale-client-go v1.17.1-0.20240729175651-90a1e935cc19 h1:fRLv1yZH1ueL1cnpLhOnOymoBfMCIviCn0e0VkAjkK4= github.com/tailscale/tailscale-client-go v1.17.1-0.20240729175651-90a1e935cc19/go.mod h1:jbwJyHniK3nyLttwcDTXnfdDQEnADvc4VMOP8hZWnR0= github.com/tailscale/tailscale-client-go/v2 v2.0.0-20240801195603-6096900af9df h1:XjHI0pFxhttM1nEn/WNGOO3wrJYEJSZarJm0i5WFXgY= github.com/tailscale/tailscale-client-go/v2 v2.0.0-20240801195603-6096900af9df/go.mod h1:i/MSgQ71kdyh1Wdp50XxrIgtsyO4uZ2SZSPd83lGKHM= +======= +github.com/tailscale/tailscale-client-go v1.17.0 h1:4ZTsfB2hiiiIcx7prcXapZHO5K+TXB5fTdhGxdKGR88= +github.com/tailscale/tailscale-client-go v1.17.0/go.mod h1:Zxz9AWl4cNX8F+jE7iIeo6Me7dGPXNdCFIoVeovH6eI= +github.com/tailscale/tailscale-client-go/v2 v2.0.0-20240801205641-d930be734670 h1:Gh7C7H9uAmjeCMxDtYTP3GCY2OtMDzPLVQlTJQOGSL4= +github.com/tailscale/tailscale-client-go/v2 v2.0.0-20240801205641-d930be734670/go.mod h1:i/MSgQ71kdyh1Wdp50XxrIgtsyO4uZ2SZSPd83lGKHM= +>>>>>>> bfc4a29 (tailscale: use V2 client for device authorization) github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= diff --git a/tailscale/resource_device_authorization.go b/tailscale/resource_device_authorization.go index cf0d2c40..17c0064a 100644 --- a/tailscale/resource_device_authorization.go +++ b/tailscale/resource_device_authorization.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/tailscale/tailscale-client-go/tailscale" + "github.com/tailscale/tailscale-client-go/v2" ) func resourceDeviceAuthorization() *schema.Resource { @@ -32,10 +32,10 @@ func resourceDeviceAuthorization() *schema.Resource { } func resourceDeviceAuthorizationRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - client := m.(*Clients).V1 + client := m.(*Clients).V2 deviceID := d.Get("device_id").(string) - devices, err := client.Devices(ctx) + devices, err := client.Devices().List(ctx) if err != nil { return diagnosticsError(err, "Failed to fetch devices") } @@ -75,10 +75,10 @@ func resourceDeviceAuthorizationCreate(ctx context.Context, d *schema.ResourceDa } func resourceDeviceAuthorizationUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - client := m.(*Clients).V1 + client := m.(*Clients).V2 deviceID := d.Get("device_id").(string) - devices, err := client.Devices(ctx) + devices, err := client.Devices().List(ctx) if err != nil { return diagnosticsError(err, "Failed to fetch devices") } @@ -104,7 +104,7 @@ func resourceDeviceAuthorizationUpdate(ctx context.Context, d *schema.ResourceDa return nil } - if err = client.AuthorizeDevice(ctx, deviceID); err != nil { + if err = client.Devices().SetAuthorized(ctx, deviceID, true); err != nil { return diagnosticsError(err, "Failed to authorize device") }