Skip to content

Commit

Permalink
1.19 version ioUtil updates
Browse files Browse the repository at this point in the history
  • Loading branch information
fdevans committed Oct 6, 2023
1 parent 7871834 commit 0bc1abc
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 43 deletions.
43 changes: 12 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,33 @@ Terraform Provider

<img src="https://cdn.rawgit.com/hashicorp/terraform-website/master/content/source/assets/images/logo-hashicorp.svg" width="600px">

Requirements
------------
## Requirements

- [Terraform](https://www.terraform.io/downloads.html) 0.10.x
- [Go](https://golang.org/doc/install) 1.11 (to build the provider plugin)
- [Terraform](https://www.terraform.io/downloads.html) >= 0.13.x
- [Go](https://golang.org/doc/install) >= 1.18

Building The Provider
---------------------

Clone repository to: `$GOPATH/src/github.com/terraform-providers/terraform-provider-rundeck`

```sh
$ mkdir -p $GOPATH/src/github.com/terraform-providers; cd $GOPATH/src/github.com/terraform-providers
$ git clone [email protected]:terraform-providers/terraform-provider-rundeck
```

Enter the provider directory and build the provider
## Building The Provider

1. Clone the repository
1. Enter the repository directory
1. Build the provider using the Go `install` command:
```sh
$ cd $GOPATH/src/github.com/terraform-providers/terraform-provider-rundeck
$ make build
$ go install
```

Using the provider
----------------------
## Fill in for each provider
See Docs Section

Developing the Provider
---------------------------

If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (version 1.11+ is *required*). You'll also need to correctly setup a [GOPATH](http://golang.org/doc/code.html#GOPATH), as well as adding `$GOPATH/bin` to your `$PATH`.

To compile the provider, run `make build`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (see [Requirements](#requirements) above).

```sh
$ make build
...
$ $GOPATH/bin/terraform-provider-rundeck
...
```

In order to test the provider, you can simply run `make test`.
To compile the provider, run `go install`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.

```sh
$ make test
```
To generate or update documentation, run `go generate`.

In order to run the full suite of Acceptance tests, run `make testacc`.

Expand Down
7 changes: 3 additions & 4 deletions rundeck/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"encoding/xml"
"fmt"
"io"
"io/ioutil"
"strings"

"github.com/rundeck/go-rundeck/rundeck"
Expand Down Expand Up @@ -386,7 +385,7 @@ func GetJob(c *rundeck.BaseClient, id string) (*JobDetail, error) {
return nil, fmt.Errorf("error getting job: (%v)", err)
}

respBytes, err := ioutil.ReadAll(resp.Body)
respBytes, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -427,12 +426,12 @@ func importJob(c *rundeck.BaseClient, job *JobDetail, dupeOption string) (*JobSu
}

ctx := context.Background()
resp, err := c.ProjectJobsImport(ctx, job.ProjectName, ioutil.NopCloser(bytes.NewReader(jobBytes)), "", "", "", dupeOption, "preserve")
resp, err := c.ProjectJobsImport(ctx, job.ProjectName, io.NopCloser(bytes.NewReader(jobBytes)), "", "", "", dupeOption, "preserve")
if err != nil {
return nil, err
}

respBytes, err := ioutil.ReadAll(resp.Body)
respBytes, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions rundeck/resource_private_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"crypto/sha1"
"encoding/hex"
"fmt"
"io/ioutil"
"io"
"strings"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
Expand Down Expand Up @@ -57,7 +57,7 @@ func CreateOrUpdatePrivateKey(d *schema.ResourceData, meta interface{}) error {

ctx := context.Background()

keyMaterialReader := ioutil.NopCloser(strings.NewReader(keyMaterial))
keyMaterialReader := io.NopCloser(strings.NewReader(keyMaterial))

if d.Id() != "" {
resp, err := client.StorageKeyUpdate(ctx, path, keyMaterialReader, "application/octect-stream")
Expand Down
8 changes: 4 additions & 4 deletions rundeck/resource_public_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package rundeck
import (
"context"
"fmt"
"io/ioutil"
"io"
"strings"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
Expand Down Expand Up @@ -56,7 +56,7 @@ func CreatePublicKey(d *schema.ResourceData, meta interface{}) error {
path := d.Get("path").(string)
keyMaterial := d.Get("key_material").(string)

keyMaterialReader := ioutil.NopCloser(strings.NewReader(keyMaterial))
keyMaterialReader := io.NopCloser(strings.NewReader(keyMaterial))

if keyMaterial != "" {
resp, err := client.StorageKeyCreate(ctx, path, keyMaterialReader, "application/pgp-keys")
Expand Down Expand Up @@ -86,7 +86,7 @@ func UpdatePublicKey(d *schema.ResourceData, meta interface{}) error {
path := d.Get("path").(string)
keyMaterial := d.Get("key_material").(string)

keyMaterialReader := ioutil.NopCloser(strings.NewReader(keyMaterial))
keyMaterialReader := io.NopCloser(strings.NewReader(keyMaterial))

resp, err := client.StorageKeyUpdate(ctx, path, keyMaterialReader, "application/pgp-keys")
if resp.StatusCode == 409 || err != nil {
Expand Down Expand Up @@ -145,7 +145,7 @@ func ReadPublicKey(d *schema.ResourceData, meta interface{}) error {
return err
}

keyMaterial, err := ioutil.ReadAll(resp.Body)
keyMaterial, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions rundeck/resource_public_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package rundeck
import (
"context"
"fmt"
"io/ioutil"
"io"
"strings"
"testing"

Expand Down Expand Up @@ -93,7 +93,7 @@ func testAccPublicKeyCheckExists(rn string, key *rundeck.StorageKeyListResponse,
return fmt.Errorf("error getting key contents: %s", err)
}

respMaterial, err2 := ioutil.ReadAll(resp.Body)
respMaterial, err2 := io.ReadAll(resp.Body)
if err2 != nil {
return fmt.Errorf("error getting key contents: %s", err)
}
Expand Down

0 comments on commit 0bc1abc

Please sign in to comment.