diff --git a/GNUmakefile b/GNUmakefile index b88187c..676d2f0 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -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 diff --git a/README.md b/README.md index 42ced3c..36a67c3 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/data-sources/remotefile.md b/docs/data-sources/file.md similarity index 89% rename from docs/data-sources/remotefile.md rename to docs/data-sources/file.md index eeb528c..41a465b 100644 --- a/docs/data-sources/remotefile.md +++ b/docs/data-sources/file.md @@ -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 diff --git a/docs/index.md b/docs/index.md index 64e9013..05bff0a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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 } ``` diff --git a/docs/resources/remotefile.md b/docs/resources/file.md similarity index 90% rename from docs/resources/remotefile.md rename to docs/resources/file.md index f42dcda..104677b 100644 --- a/docs/resources/remotefile.md +++ b/docs/resources/file.md @@ -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 = "" diff --git a/examples/data-sources/remotefile/data-source.tf b/examples/data-sources/remote_file/data-source.tf similarity index 65% rename from examples/data-sources/remotefile/data-source.tf rename to examples/data-sources/remote_file/data-source.tf index 75b01a6..d3e26f1 100644 --- a/examples/data-sources/remotefile/data-source.tf +++ b/examples/data-sources/remote_file/data-source.tf @@ -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 diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 6906f9e..3f9d699 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -1,3 +1,3 @@ -provider "remotefile" { +provider "remote" { max_sessions = 2 } diff --git a/examples/resources/remotefile/resource.tf b/examples/resources/remote_file/resource.tf similarity index 75% rename from examples/resources/remotefile/resource.tf rename to examples/resources/remote_file/resource.tf index 2fc41a1..638d9d7 100644 --- a/examples/resources/remotefile/resource.tf +++ b/examples/resources/remote_file/resource.tf @@ -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 = "" diff --git a/go.mod b/go.mod index 99c8844..dd4a215 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/tenstad/terraform-provider-remotefile +module github.com/tenstad/terraform-provider-remote go 1.15 diff --git a/internal/provider/data_source_remotefile.go b/internal/provider/data_source_remote_file.go similarity index 92% rename from internal/provider/data_source_remotefile.go rename to internal/provider/data_source_remote_file.go index 7fc2485..b4219d4 100644 --- a/internal/provider/data_source_remotefile.go +++ b/internal/provider/data_source_remote_file.go @@ -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": { @@ -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) } diff --git a/internal/provider/data_source_remotefile_test.go b/internal/provider/data_source_remote_file_test.go similarity index 71% rename from internal/provider/data_source_remotefile_test.go rename to internal/provider/data_source_remote_file_test.go index 93fbd0a..5617fb5 100644 --- a/internal/provider/data_source_remotefile_test.go +++ b/internal/provider/data_source_remote_file_test.go @@ -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" diff --git a/internal/provider/provider.go b/internal/provider/provider.go index b34cbcb..f14803f 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -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": { diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go index 37dd3fc..459281f 100644 --- a/internal/provider/provider_test.go +++ b/internal/provider/provider_test.go @@ -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 }, } diff --git a/internal/provider/resource_remotefile.go b/internal/provider/resource_remote_file.go similarity index 91% rename from internal/provider/resource_remotefile.go rename to internal/provider/resource_remote_file.go index cb03e46..e5d3cbe 100644 --- a/internal/provider/resource_remotefile.go +++ b/internal/provider/resource_remote_file.go @@ -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": { @@ -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) @@ -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) @@ -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()) diff --git a/internal/provider/resource_remotefile_test.go b/internal/provider/resource_remote_file_test.go similarity index 71% rename from internal/provider/resource_remotefile_test.go rename to internal/provider/resource_remote_file_test.go index 099e0d2..78e8290 100644 --- a/internal/provider/resource_remotefile_test.go +++ b/internal/provider/resource_remote_file_test.go @@ -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" diff --git a/main.go b/main.go index 7f23373..d4f346c 100644 --- a/main.go +++ b/main.go @@ -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 @@ -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()) }