From 8fdd881918fae4951e672a4bc51ce41141c87827 Mon Sep 17 00:00:00 2001 From: Kim Oliver Drechsel Date: Sat, 25 May 2024 09:46:39 +0200 Subject: [PATCH 1/3] Replace deprecated package ioutils with io Signed-off-by: Kim Oliver Drechsel --- hetznerdns/api/client.go | 7 +++---- hetznerdns/api/client_test.go | 11 +++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/hetznerdns/api/client.go b/hetznerdns/api/client.go index 8cefd9a..357eafa 100644 --- a/hetznerdns/api/client.go +++ b/hetznerdns/api/client.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "io" - "io/ioutil" "log" "net/http" "strings" @@ -96,11 +95,11 @@ func (c *Client) doHTTPRequest(apiToken string, method string, url string, body } func parseUnprocessableEntityError(resp *http.Response) (*UnprocessableEntityError, error) { - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) defer resp.Body.Close() if err != nil { - return nil, fmt.Errorf("Error reading HTTP response body: %e", err) + return nil, fmt.Errorf("error reading HTTP response body: %e", err) } var unprocessableEntityError UnprocessableEntityError err = parseJSON(body, &unprocessableEntityError) @@ -160,7 +159,7 @@ func (c *Client) doPutRequest(url string, bodyJSON interface{}) (*http.Response, } func readAndParseJSONBody(resp *http.Response, respType interface{}) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) defer resp.Body.Close() if err != nil { diff --git a/hetznerdns/api/client_test.go b/hetznerdns/api/client_test.go index 0974470..4449415 100644 --- a/hetznerdns/api/client_test.go +++ b/hetznerdns/api/client_test.go @@ -3,7 +3,6 @@ package api import ( "bytes" "io" - "io/ioutil" "net/http" "testing" @@ -22,7 +21,7 @@ func TestClientCreateZoneSuccess(t *testing.T) { assert.NoError(t, err) assert.Equal(t, Zone{ID: "12345", Name: "mydomain.com", TTL: 3600}, *zone) assert.NotNil(t, requestBodyReader, "The request body should not be nil") - jsonRequestBody, _ := ioutil.ReadAll(requestBodyReader) + jsonRequestBody, _ := io.ReadAll(requestBodyReader) assert.Equal(t, `{"name":"mydomain.com","ttl":3600}`, string(jsonRequestBody)) } @@ -61,7 +60,7 @@ func TestClientUpdateZoneSuccess(t *testing.T) { assert.NoError(t, err) assert.Equal(t, zoneWithUpdates, *updatedZone) assert.NotNil(t, requestBodyReader, "The request body should not be nil") - jsonRequestBody, _ := ioutil.ReadAll(requestBodyReader) + jsonRequestBody, _ := io.ReadAll(requestBodyReader) assert.Equal(t, zoneWithUpdatesJSON, string(jsonRequestBody)) } @@ -162,7 +161,7 @@ func TestClientCreateRecordSuccess(t *testing.T) { assert.NoError(t, err) assert.Equal(t, Record{ZoneID: "wwwlsksjjenm", ID: "12345678", Name: "zone1.online", TTL: &aTTL, Type: "A", Value: "192.168.1.1"}, *record) assert.NotNil(t, requestBodyReader, "The request body should not be nil") - jsonRequestBody, _ := ioutil.ReadAll(requestBodyReader) + jsonRequestBody, _ := io.ReadAll(requestBodyReader) assert.Equal(t, `{"zone_id":"wwwlsksjjenm","type":"A","name":"zone1.online","value":"192.168.1.1","ttl":3600}`, string(jsonRequestBody)) } @@ -189,7 +188,7 @@ func TestClientUpdateRecordSuccess(t *testing.T) { assert.NoError(t, err) assert.Equal(t, recordWithUpdates, *updatedRecord) assert.NotNil(t, requestBodyReader, "The request body should not be nil") - jsonRequestBody, _ := ioutil.ReadAll(requestBodyReader) + jsonRequestBody, _ := io.ReadAll(requestBodyReader) assert.Equal(t, recordWithUpdatesJSON, string(jsonRequestBody)) } @@ -231,7 +230,7 @@ func (f TestClient) RoundTrip(req *http.Request) (*http.Response, error) { var jsonBody io.ReadCloser = nil if f.config.responseBodyJSON != nil { - jsonBody = ioutil.NopCloser(bytes.NewReader(f.config.responseBodyJSON)) + jsonBody = io.NopCloser(bytes.NewReader(f.config.responseBodyJSON)) } resp := http.Response{StatusCode: f.config.responseHTTPStatus, Body: jsonBody} return &resp, nil From 232377f70c08257db228c2b32566b213e536e486 Mon Sep 17 00:00:00 2001 From: Kim Oliver Drechsel Date: Sat, 25 May 2024 09:58:26 +0200 Subject: [PATCH 2/3] Adjust links to new location Signed-off-by: Kim Oliver Drechsel --- INSTALL.md | 8 ++++---- README.md | 18 ++++++++++-------- RELEASING.md | 2 +- go.mod | 2 +- hetznerdns/data_source_zone.go | 2 +- hetznerdns/primary_server.go | 5 +++-- hetznerdns/provider.go | 3 ++- hetznerdns/resource_record.go | 5 +++-- hetznerdns/resource_zone.go | 5 +++-- main.go | 2 +- 10 files changed, 29 insertions(+), 23 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index e898692..8d5533a 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -2,7 +2,7 @@ This is a third-party provier, which is not maintained by Hashicorp. You have to download and install it on your own. Pick the binary for the target operating -system from the [releases list](https://github.com/timohirt/terraform-provider-hetznerdns/releases) +system from the [releases list](https://github.com/germanbrew/terraform-provider-hetznerdns/releases) and download the archive. ## Installing the Provider @@ -14,9 +14,9 @@ nicly with the Terraform Registry. This means that you have to create or migrate to a slighly different directory structure where you put the provide binaries. ```bash -$ mkdir -p ~/.terraform.d/plugins/github.com/timohirt/hetznerdns/1.0.5/linux_amd64 +$ mkdir -p ~/.terraform.d/plugins/github.com/germanbrew/hetznerdns/1.0.5/linux_amd64 $ tar xzf terraform-provider-hetznerdns_1.0.5_linux_amd64.tar.gz -$ mv ./terraform-provider-hetznerdns ~/.terraform.d/plugins/github.com/timohirt/hetznerdns/1.0.5/linux_amd64/terraform-provider-hetznerdns_v1.0.5 +$ mv ./terraform-provider-hetznerdns ~/.terraform.d/plugins/github.com/germanbrew/hetznerdns/1.0.5/linux_amd64/terraform-provider-hetznerdns_v1.0.5 ``` As you can see above, the version as well as the operating system is now included in @@ -31,7 +31,7 @@ Add the following to your `terraform.tf`. terraform { required_providers { hetznerdns = { - source = "github.com/timohirt/hetznerdns" + source = "github.com/germanbrew/hetznerdns" } } required_version = ">= 1.0" diff --git a/README.md b/README.md index 1e5100c..9665018 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,17 @@ # Terraform Provider for Hetzner DNS -![CI Build](https://github.com/timohirt/terraform-provider-hetznerdns/workflows/CI%20Build/badge.svg?branch=master) -![GitHub release (latest by date)](https://img.shields.io/github/v/release/timohirt/terraform-provider-hetznerdns) -![GitHub](https://img.shields.io/github/license/timohirt/terraform-provider-hetznerdns) - -Read about what I learnt while [implementing this Terraform Provider](http://www.timohirt.de/blog/implementing-a-terraform-provider/). +![CI Build](https://github.com/germanbrew/terraform-provider-hetznerdns/workflows/CI%20Build/badge.svg?branch=master) +![GitHub release (latest by date)](https://img.shields.io/github/v/release/germanbrew/terraform-provider-hetznerdns) +![GitHub](https://img.shields.io/github/license/germanbrew/terraform-provider-hetznerdns) **This provider is on published on the Terraform registry**. +This project has been forked from +[germanbrew/terraform-provider-hetznerdns](https://github.com/germanbrew/terraform-provider-hetznerdns) +which is unfortunately no longer maintained. + You can find resources and data sources -[documentation](https://registry.terraform.io/providers/timohirt/hetznerdns/latest/docs) +[documentation](https://registry.terraform.io/providers/germanbrew/hetznerdns/latest/docs) there or [here](docs). ## Requirements @@ -20,7 +22,7 @@ there or [here](docs). ## Installing and Using this Plugin You most likely want to download the provider from [Terraform -Registry](https://registry.terraform.io/providers/timohirt/hetznerdns/latest/docs). +Registry](https://registry.terraform.io/providers/germanbrew/hetznerdns/latest/docs). If you want or need to install the provider locally, take a look at [INSTALL](./INSTALL.md). @@ -33,7 +35,7 @@ add the following to your `terraform.tf`: terraform { required_providers { hetznerdns = { - source = "timohirt/hetznerdns" + source = "germanbrew/hetznerdns" version = "2.1.0" } } diff --git a/RELEASING.md b/RELEASING.md index e32a9c8..52a3b6a 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -12,7 +12,7 @@ $ git tag v1.0.17 $ git push --tags ``` -Then navigate your browser to the GitHub [releases page of this repository](https://github.com/timohirt/terraform-provider-hetznerdns/releases). +Then navigate your browser to the GitHub [releases page of this repository](https://github.com/germanbrew/terraform-provider-hetznerdns/releases). Download `terraform-provider-hetznerdns_1.0.17_SHA256SUMS` from the list of assets associated with this release. The version might by diff --git a/go.mod b/go.mod index 38e8da4..37c3b3f 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/timohirt/terraform-provider-hetznerdns +module github.com/germanbrew/terraform-provider-hetznerdns go 1.16 diff --git a/hetznerdns/data_source_zone.go b/hetznerdns/data_source_zone.go index db88a4b..d97588a 100644 --- a/hetznerdns/data_source_zone.go +++ b/hetznerdns/data_source_zone.go @@ -3,7 +3,7 @@ package hetznerdns import ( "fmt" - "github.com/timohirt/terraform-provider-hetznerdns/hetznerdns/api" + "github.com/germanbrew/terraform-provider-hetznerdns/hetznerdns/api" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/hetznerdns/primary_server.go b/hetznerdns/primary_server.go index 2b51e16..16d5d4c 100644 --- a/hetznerdns/primary_server.go +++ b/hetznerdns/primary_server.go @@ -2,10 +2,11 @@ package hetznerdns import ( "context" + "log" + + "github.com/germanbrew/terraform-provider-hetznerdns/hetznerdns/api" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/timohirt/terraform-provider-hetznerdns/hetznerdns/api" - "log" ) func resourcePrimaryServer() *schema.Resource { diff --git a/hetznerdns/provider.go b/hetznerdns/provider.go index 3000d05..75036f4 100644 --- a/hetznerdns/provider.go +++ b/hetznerdns/provider.go @@ -2,9 +2,10 @@ package hetznerdns import ( "context" + + "github.com/germanbrew/terraform-provider-hetznerdns/hetznerdns/api" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/timohirt/terraform-provider-hetznerdns/hetznerdns/api" ) // Provider creates and return a Terraform resource provider diff --git a/hetznerdns/resource_record.go b/hetznerdns/resource_record.go index a2bca17..631d0e9 100644 --- a/hetznerdns/resource_record.go +++ b/hetznerdns/resource_record.go @@ -2,10 +2,11 @@ package hetznerdns import ( "context" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "log" - "github.com/timohirt/terraform-provider-hetznerdns/hetznerdns/api" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + + "github.com/germanbrew/terraform-provider-hetznerdns/hetznerdns/api" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/hetznerdns/resource_zone.go b/hetznerdns/resource_zone.go index 9dd15a6..ede0928 100644 --- a/hetznerdns/resource_zone.go +++ b/hetznerdns/resource_zone.go @@ -2,10 +2,11 @@ package hetznerdns import ( "context" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "log" - "github.com/timohirt/terraform-provider-hetznerdns/hetznerdns/api" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + + "github.com/germanbrew/terraform-provider-hetznerdns/hetznerdns/api" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/main.go b/main.go index 00a381a..c9d55f7 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,7 @@ package main import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" plugin "github.com/hashicorp/terraform-plugin-sdk/v2/plugin" - "github.com/timohirt/terraform-provider-hetznerdns/hetznerdns" + "github.com/germanbrew/terraform-provider-hetznerdns/hetznerdns" ) func main() { From 342ee3c0e180bd207fa5c885f2216dcd26668e6a Mon Sep 17 00:00:00 2001 From: Kim Oliver Drechsel Date: Sat, 25 May 2024 10:04:13 +0200 Subject: [PATCH 3/3] Reformat imports in main.go Signed-off-by: Kim Oliver Drechsel --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index c9d55f7..eebf918 100644 --- a/main.go +++ b/main.go @@ -1,9 +1,9 @@ package main import ( + "github.com/germanbrew/terraform-provider-hetznerdns/hetznerdns" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" plugin "github.com/hashicorp/terraform-plugin-sdk/v2/plugin" - "github.com/germanbrew/terraform-provider-hetznerdns/hetznerdns" ) func main() {