Skip to content

Commit

Permalink
Merge pull request #15 from scottwinkler/feature/triggers
Browse files Browse the repository at this point in the history
add triggers attribute and updates for provider sdk
  • Loading branch information
scottwinkler authored Oct 16, 2019
2 parents dd68b54 + ffa2655 commit 3bbb265
Show file tree
Hide file tree
Showing 11 changed files with 579 additions and 292 deletions.
23 changes: 22 additions & 1 deletion examples/test.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
provider "shell" {}


//test complete data resource
data "shell_script" "test" {
lifecycle_commands {
Expand Down Expand Up @@ -84,12 +85,32 @@ resource "shell_script" "test5" {

working_directory = "${path.module}"

environment {
environment = {
yolo = "yolo"
ball = "room"
}
}

output "commit_id2" {
value = shell_script.test5.output["commit_id"]
}

//resource with triggers
resource "shell_script" "test6" {
lifecycle_commands {
create = file("${path.module}/scripts/create.sh")
read = file("${path.module}/scripts/read.sh")
delete = file("${path.module}/scripts/delete.sh")
}

working_directory = "${path.module}"

environment = {
yolo = "yolo"
ball = "room"
}

triggers = {
abc = 123
}
}
10 changes: 7 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
module githubdev.dco.elmae/CloudPlatform/terraform-provider-shell
module github.com/scottwinkler/terraform-provider-shell

go 1.12

require (
github.com/armon/circbuf v0.0.0-20190214190532-5111143e8da2
github.com/hashicorp/terraform v0.12.0
github.com/blang/semver v0.0.0-20170202183821-4a1e882c79dc // indirect
github.com/golang/lint v0.0.0-20180702182130-06c8688daad7 // indirect
github.com/hashicorp/terraform v0.11.11 // indirect
github.com/hashicorp/terraform-plugin-sdk v1.0.0
github.com/kisielk/gotool v1.0.0 // indirect
github.com/mitchellh/hashstructure v0.0.0-20160209213820-6b17d669fac5 // indirect
github.com/rs/xid v1.2.1
github.com/scottwinkler/terraform-provider-shell v0.0.0-20190308051913-56533de967fb
)

replace git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999
409 changes: 137 additions & 272 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/hashicorp/terraform/plugin"
"github.com/hashicorp/terraform-plugin-sdk/plugin"
"github.com/scottwinkler/terraform-provider-shell/shell"
)

Expand Down
2 changes: 1 addition & 1 deletion shell/data_source_shell_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package shell
import (
"log"

"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/rs/xid"
)

Expand Down
4 changes: 2 additions & 2 deletions shell/data_source_shell_script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccShellDataShellScript_basic(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions shell/provider.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package shell

import (
"github.com/hashicorp/terraform/helper/mutexkv"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
"github.com/hashicorp/terraform-plugin-sdk/helper/mutexkv"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

// Provider returns a terraform.ResourceProvider.
Expand Down
6 changes: 3 additions & 3 deletions shell/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package shell
import (
"testing"

"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

var testAccProviders map[string]terraform.ResourceProvider
Expand All @@ -25,4 +25,4 @@ func TestProvider(t *testing.T) {

func TestProvider_impl(t *testing.T) {
var _ terraform.ResourceProvider = Provider()
}
}
7 changes: 6 additions & 1 deletion shell/resource_shell_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"log"
"reflect"

"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/rs/xid"
)

Expand Down Expand Up @@ -45,6 +45,11 @@ func resourceShellScript() *schema.Resource {
},
},
},
"triggers": {
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
},
"environment": {
Type: schema.TypeMap,
Optional: true,
Expand Down
15 changes: 10 additions & 5 deletions shell/resource_shell_script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package shell

import (
"fmt"
"os"
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

func TestAccShellShellScript_basic(t *testing.T) {
Expand Down Expand Up @@ -90,15 +91,15 @@ func TestAccShellShellScript_complete(t *testing.T) {
}

func testAccCheckShellScriptDestroy(s *terraform.State) error {
/*for _, rs := range s.RootModule().Resources {
for _, rs := range s.RootModule().Resources {
if rs.Type != "shell_script" {
continue
}
fileName := rs.Primary.Attributes["shell_script.test.environment.filename"]
if _, err := os.Stat(fileName); os.IsExist(err) {
return fmt.Errorf("Shell Script file failed to cleanup")
}
}*/
}
return nil
}

Expand Down Expand Up @@ -185,6 +186,10 @@ func testAccShellScriptConfig_complete(outValue string) string {
testdatasize = "10240"
out1 = "%s"
}
triggers = {
key = "value"
}
}
`, outValue)
}
Loading

0 comments on commit 3bbb265

Please sign in to comment.