Skip to content

Commit

Permalink
Rename provider
Browse files Browse the repository at this point in the history
  • Loading branch information
tenstad committed Aug 28, 2021
1 parent 61b31ba commit 92ef45a
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 53 deletions.
10 changes: 5 additions & 5 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ default: testacc
.PHONY: testacc
testacc:
docker rm -f remotehost
docker network rm remotefile || true
docker network create remotefile
docker network rm remote || true
docker network create remote
docker build -t remotehost tests
docker run --rm -d --net remotefile --name remotehost remotehost
docker run --rm --net remotefile -v $(PWD):/app --workdir /app -e "TF_ACC=1" -e "TF_ACC_TERRAFORM_VERSION=0.13.4" golang:1.15 go test ./... -v $(TESTARGS) -timeout 120m
docker run --rm -d --net remote --name remotehost remotehost
docker run --rm --net remote -v $(PWD):/app --workdir /app -e "TF_ACC=1" -e "TF_ACC_TERRAFORM_VERSION=0.13.4" golang:1.15 go test ./... -v $(TESTARGS) -timeout 120m
docker rm -f remotehost
docker network rm remotefile
docker network rm remote
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Terraform Provider Remotefile
# Terraform Provider Remote

Documentation: https://registry.terraform.io/providers/tenstad/remotefile/latest/docs/resources/remotefile
Documentation: https://registry.terraform.io/providers/tenstad/remote/latest/docs/resources/file

## Requirements

Expand Down
8 changes: 4 additions & 4 deletions docs/data-sources/remotefile.md → docs/data-sources/file.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "remotefile Data Source - terraform-provider-remotefile"
page_title: "remote_file Data Source - terraform-provider-remote"
subcategory: ""
description: |-
File on remote host.
---

# remotefile (Data Source)
# remote_file (Data Source)

File on remote host.

## Example Usage

```terraform
data "remotefile" "hosts" {
data "remote_file" "hosts" {
conn {
host = "google.com"
host = "10.0.0.12"
username = "john"
password = "password"
sudo = true
Expand Down
6 changes: 3 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "remotefile Provider"
page_title: "remote Provider"
subcategory: ""
description: |-
---

# remotefile Provider
# remote Provider



## Example Usage

```terraform
provider "remotefile" {
provider "remote" {
max_sessions = 2
}
```
Expand Down
8 changes: 4 additions & 4 deletions docs/resources/remotefile.md → docs/resources/file.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "remotefile Resource - terraform-provider-remotefile"
page_title: "remote_file Resource - terraform-provider-remote"
subcategory: ""
description: |-
File on remote host.
---

# remotefile (Resource)
# remote_file (Resource)

File on remote host.

## Example Usage

```terraform
resource "remotefile" "bashrc" {
resource "remote_file" "bashrc" {
conn {
host = "google.com"
host = "10.0.0.12"
port = 22
username = "john"
private_key = "<ssh private key>"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
data "remotefile" "hosts" {
data "remote_file" "hosts" {
conn {
host = "google.com"
host = "10.0.0.12"
username = "john"
password = "password"
sudo = true
Expand Down
2 changes: 1 addition & 1 deletion examples/provider/provider.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
provider "remotefile" {
provider "remote" {
max_sessions = 2
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "remotefile" "bashrc" {
resource "remote_file" "bashrc" {
conn {
host = "google.com"
host = "10.0.0.12"
port = 22
username = "john"
private_key = "<ssh private key>"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/tenstad/terraform-provider-remotefile
module github.com/tenstad/terraform-provider-remote

go 1.15

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceRemotefile() *schema.Resource {
func dataSourceRemoteFile() *schema.Resource {
return &schema.Resource{
Description: "File on remote host.",

ReadContext: dataSourceRemotefileRead,
ReadContext: dataSourceRemoteFileRead,

Schema: map[string]*schema.Schema{
"conn": {
Expand Down Expand Up @@ -85,6 +85,6 @@ func dataSourceRemotefile() *schema.Resource {
}
}

func dataSourceRemotefileRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
return resourceRemotefileRead(ctx, d, meta)
func dataSourceRemoteFileRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
return resourceRemoteFileRead(ctx, d, meta)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccDataSourceRemotefile(t *testing.T) {
func TestAccDataSourceRemoteFile(t *testing.T) {

resource.UnitTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: testAccDataSourceRemotefile,
Config: testAccDataSourceRemoteFile,
Check: resource.ComposeTestCheckFunc(
resource.TestMatchResourceAttr(
// TODO: check content is correct
"data.remotefile.bar", "content", regexp.MustCompile("")),
"data.remote_file.bar", "content", regexp.MustCompile("")),
),
},
},
})
}

const testAccDataSourceRemotefile = `
data "remotefile" "bar" {
const testAccDataSourceRemoteFile = `
data "remote_file" "bar" {
conn {
host = "remotehost"
username = "root"
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ func New(version string) func() *schema.Provider {
return func() *schema.Provider {
p := &schema.Provider{
DataSourcesMap: map[string]*schema.Resource{
"remotefile": dataSourceRemotefile(),
"remote_file": dataSourceRemoteFile(),
},
ResourcesMap: map[string]*schema.Resource{
"remotefile": resourceRemotefile(),
"remote_file": resourceRemoteFile(),
},
Schema: map[string]*schema.Schema{
"max_sessions": {
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// The factory function will be invoked for every Terraform CLI command executed
// to create a provider server to which the CLI can reattach.
var providerFactories = map[string]func() (*schema.Provider, error){
"remotefile": func() (*schema.Provider, error) {
"remote": func() (*schema.Provider, error) {
return New("dev")(), nil
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func resourceRemotefile() *schema.Resource {
func resourceRemoteFile() *schema.Resource {
return &schema.Resource{
Description: "File on remote host.",

CreateContext: resourceRemotefileCreate,
ReadContext: resourceRemotefileRead,
UpdateContext: resourceRemotefileUpdate,
DeleteContext: resourceRemotefileDelete,
CreateContext: resourceRemoteFileCreate,
ReadContext: resourceRemoteFileRead,
UpdateContext: resourceRemoteFileUpdate,
DeleteContext: resourceRemoteFileDelete,

Schema: map[string]*schema.Schema{
"conn": {
Expand Down Expand Up @@ -97,7 +97,7 @@ func resourceRemotefile() *schema.Resource {
}
}

func resourceRemotefileCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceRemoteFileCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
d.SetId(fmt.Sprintf("%s:%s", d.Get("conn.0.host").(string), d.Get("path").(string)))

client, err := meta.(*apiClient).getRemoteClient(d)
Expand Down Expand Up @@ -130,7 +130,7 @@ func resourceRemotefileCreate(ctx context.Context, d *schema.ResourceData, meta
return diag.Diagnostics{}
}

func resourceRemotefileRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceRemoteFileRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
d.SetId(fmt.Sprintf("%s:%s", d.Get("conn.0.host").(string), d.Get("path").(string)))

client, err := meta.(*apiClient).getRemoteClient(d)
Expand Down Expand Up @@ -167,11 +167,11 @@ func resourceRemotefileRead(ctx context.Context, d *schema.ResourceData, meta in
return diag.Diagnostics{}
}

func resourceRemotefileUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
return resourceRemotefileCreate(ctx, d, meta)
func resourceRemoteFileUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
return resourceRemoteFileCreate(ctx, d, meta)
}

func resourceRemotefileDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceRemoteFileDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client, err := meta.(*apiClient).getRemoteClient(d)
if err != nil {
return diag.Errorf("error while opening remote client: %s", err.Error())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccResourceRemotefile(t *testing.T) {
func TestAccResourceRemoteFile(t *testing.T) {
resource.UnitTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: testAccResourceRemotefile,
Config: testAccResourceRemoteFile,
Check: resource.ComposeTestCheckFunc(
resource.TestMatchResourceAttr(
"remotefile.foo", "content", regexp.MustCompile("bar")),
"remote_file.foo", "content", regexp.MustCompile("bar")),
),
},
},
})
}

const testAccResourceRemotefile = `
resource "remotefile" "foo" {
const testAccResourceRemoteFile = `
resource "remote_file" "foo" {
conn {
host = "remotehost"
username = "root"
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"

"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
"github.com/tenstad/terraform-provider-remotefile/internal/provider"
"github.com/tenstad/terraform-provider-remote/internal/provider"
)

// Run "go generate" to format example terraform files and generate the docs for the registry/website
Expand Down Expand Up @@ -37,7 +37,7 @@ func main() {
opts := &plugin.ServeOpts{ProviderFunc: provider.New(version)}

if debugMode {
err := plugin.Debug(context.Background(), "registry.terraform.io/tenstad/remotefile", opts)
err := plugin.Debug(context.Background(), "registry.terraform.io/tenstad/remote", opts)
if err != nil {
log.Fatal(err.Error())
}
Expand Down

0 comments on commit 92ef45a

Please sign in to comment.