mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-27 09:21:14 -06:00
provisioner/remote-exec: Adding initial skeleton
This commit is contained in:
parent
1d6dc475df
commit
6381fbd226
10
builtin/bins/provisioner-remote-exec/main.go
Normal file
10
builtin/bins/provisioner-remote-exec/main.go
Normal file
@ -0,0 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform/builtin/provisioners/remote-exec"
|
||||
"github.com/hashicorp/terraform/plugin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
plugin.Serve(new(remoteexec.ResourceProvisioner))
|
||||
}
|
1
builtin/bins/provisioner-remote-exec/main_test.go
Normal file
1
builtin/bins/provisioner-remote-exec/main_test.go
Normal file
@ -0,0 +1 @@
|
||||
package main
|
25
builtin/provisioners/remote-exec/resource_provisioner.go
Normal file
25
builtin/provisioners/remote-exec/resource_provisioner.go
Normal file
@ -0,0 +1,25 @@
|
||||
package remoteexec
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform/helper/config"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
type ResourceProvisioner struct{}
|
||||
|
||||
func (p *ResourceProvisioner) Apply(
|
||||
s *terraform.ResourceState,
|
||||
c *terraform.ResourceConfig) (*terraform.ResourceState, error) {
|
||||
panic("not implemented")
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func (p *ResourceProvisioner) Validate(c *terraform.ResourceConfig) ([]string, []error) {
|
||||
validator := config.Validator{
|
||||
Optional: []string{
|
||||
"command",
|
||||
"inline",
|
||||
},
|
||||
}
|
||||
return validator.Validate(c)
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package remoteexec
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/config"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestResourceProvisioner_impl(t *testing.T) {
|
||||
var _ terraform.ResourceProvisioner = new(ResourceProvisioner)
|
||||
}
|
||||
|
||||
func TestResourceProvider_Validate_good(t *testing.T) {
|
||||
c := testConfig(t, map[string]interface{}{
|
||||
"command": "echo foo",
|
||||
})
|
||||
p := new(ResourceProvisioner)
|
||||
warn, errs := p.Validate(c)
|
||||
if len(warn) > 0 {
|
||||
t.Fatalf("Warnings: %v", warn)
|
||||
}
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("Errors: %v", errs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResourceProvider_Validate_bad(t *testing.T) {
|
||||
c := testConfig(t, map[string]interface{}{
|
||||
"invalid": "nope",
|
||||
})
|
||||
p := new(ResourceProvisioner)
|
||||
warn, errs := p.Validate(c)
|
||||
if len(warn) > 0 {
|
||||
t.Fatalf("Warnings: %v", warn)
|
||||
}
|
||||
if len(errs) == 0 {
|
||||
t.Fatalf("Should have errors")
|
||||
}
|
||||
}
|
||||
|
||||
func testConfig(
|
||||
t *testing.T,
|
||||
c map[string]interface{}) *terraform.ResourceConfig {
|
||||
r, err := config.NewRawConfig(c)
|
||||
if err != nil {
|
||||
t.Fatalf("bad: %s", err)
|
||||
}
|
||||
|
||||
return terraform.NewResourceConfig(r)
|
||||
}
|
Loading…
Reference in New Issue
Block a user