mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-24 16:10:46 -06:00
remote provisioners require a connection config
This commit is contained in:
parent
6697245c18
commit
47a682141a
@ -74,6 +74,11 @@ func (p *provisioner) ValidateProvisionerConfig(req provisioners.ValidateProvisi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *provisioner) ProvisionResource(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) {
|
func (p *provisioner) ProvisionResource(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) {
|
||||||
|
if req.Connection.IsNull() {
|
||||||
|
resp.Diagnostics = resp.Diagnostics.Append(errors.New("missing connection configuration for provisioner"))
|
||||||
|
return resp
|
||||||
|
}
|
||||||
|
|
||||||
comm, err := communicator.New(req.Connection)
|
comm, err := communicator.New(req.Connection)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
resp.Diagnostics = resp.Diagnostics.Append(err)
|
resp.Diagnostics = resp.Diagnostics.Append(err)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package file
|
package file
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/provisioners"
|
"github.com/hashicorp/terraform/provisioners"
|
||||||
@ -102,3 +103,16 @@ func TestResourceProvisioner_StopClose(t *testing.T) {
|
|||||||
p.Stop()
|
p.Stop()
|
||||||
p.Close()
|
p.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestResourceProvisioner_connectionRequired(t *testing.T) {
|
||||||
|
p := New()
|
||||||
|
resp := p.ProvisionResource(provisioners.ProvisionResourceRequest{})
|
||||||
|
if !resp.Diagnostics.HasErrors() {
|
||||||
|
t.Fatal("expected error")
|
||||||
|
}
|
||||||
|
|
||||||
|
got := resp.Diagnostics.Err().Error()
|
||||||
|
if !strings.Contains(got, "missing connection") {
|
||||||
|
t.Fatalf("expected 'missing connection' error: got %q", got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -85,6 +85,11 @@ func (p *provisioner) ValidateProvisionerConfig(req provisioners.ValidateProvisi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *provisioner) ProvisionResource(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) {
|
func (p *provisioner) ProvisionResource(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) {
|
||||||
|
if req.Connection.IsNull() {
|
||||||
|
resp.Diagnostics = resp.Diagnostics.Append(errors.New("missing connection configuration for provisioner"))
|
||||||
|
return resp
|
||||||
|
}
|
||||||
|
|
||||||
comm, err := communicator.New(req.Connection)
|
comm, err := communicator.New(req.Connection)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
resp.Diagnostics = resp.Diagnostics.Append(err)
|
resp.Diagnostics = resp.Diagnostics.Append(err)
|
||||||
|
@ -261,3 +261,16 @@ func TestResourceProvisioner_StopClose(t *testing.T) {
|
|||||||
p.Stop()
|
p.Stop()
|
||||||
p.Close()
|
p.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestResourceProvisioner_connectionRequired(t *testing.T) {
|
||||||
|
p := New()
|
||||||
|
resp := p.ProvisionResource(provisioners.ProvisionResourceRequest{})
|
||||||
|
if !resp.Diagnostics.HasErrors() {
|
||||||
|
t.Fatal("expected error")
|
||||||
|
}
|
||||||
|
|
||||||
|
got := resp.Diagnostics.Err().Error()
|
||||||
|
if !strings.Contains(got, "missing connection") {
|
||||||
|
t.Fatalf("expected 'missing connection' error: got %q", got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user