Skip to content

Commit

Permalink
Make port optional
Browse files Browse the repository at this point in the history
  • Loading branch information
tenstad committed Apr 30, 2021
1 parent 562d31a commit 8a762b6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 20 deletions.
21 changes: 11 additions & 10 deletions internal/provider/data_source_remotefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ func dataSourceRemotefile() *schema.Resource {
Description: "Connection to host where files are located.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"host": {
Type: schema.TypeString,
Required: true,
Description: "The target host.",
},
"port": {
Type: schema.TypeInt,
Optional: true,
Default: 22,
Description: "The ssh port to the target host.",
},
"username": {
Type: schema.TypeString,
Required: true,
Expand All @@ -31,16 +42,6 @@ func dataSourceRemotefile() *schema.Resource {
Sensitive: true,
Description: "The private key used to login to the target host.",
},
"host": {
Type: schema.TypeString,
Required: true,
Description: "The target host.",
},
"port": {
Type: schema.TypeInt,
Required: true,
Description: "The ssh port to the target host.",
},
},
},
},
Expand Down
5 changes: 5 additions & 0 deletions internal/provider/data_source_remotefile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ func TestAccDataSourceRemotefile(t *testing.T) {

const testAccDataSourceRemotefile = `
data "remotefile" "bar" {
conn {
host = "localhost"
username = "root"
private_key = ""
}
path = "/tmp/bar.txt"
}
`
21 changes: 11 additions & 10 deletions internal/provider/resource_remotefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ func resourceRemotefile() *schema.Resource {
Description: "Connection to host where files are located.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"host": {
Type: schema.TypeString,
Required: true,
Description: "The target host.",
},
"port": {
Type: schema.TypeInt,
Optional: true,
Default: 22,
Description: "The ssh port to the target host.",
},
"username": {
Type: schema.TypeString,
Required: true,
Expand All @@ -36,16 +47,6 @@ func resourceRemotefile() *schema.Resource {
Sensitive: true,
Description: "The private key used to login to the target host.",
},
"host": {
Type: schema.TypeString,
Required: true,
Description: "The target host.",
},
"port": {
Type: schema.TypeInt,
Required: true,
Description: "The ssh port to the target host.",
},
},
},
},
Expand Down
5 changes: 5 additions & 0 deletions internal/provider/resource_remotefile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ func TestAccResourceRemotefile(t *testing.T) {

const testAccResourceRemotefile = `
resource "remotefile" "foo" {
conn {
host = "localhost"
username = "root"
private_key = ""
}
path = "/tmp/foo.txt"
content = "bar"
permissions = "0777"
Expand Down

0 comments on commit 8a762b6

Please sign in to comment.