mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 18:01:01 -06:00
helper/schema: provisioner allows for nil state
This commit is contained in:
parent
b2891bc9ef
commit
a1da59a73e
@ -130,8 +130,10 @@ func (p *Provisioner) Apply(
|
||||
// easily build a ResourceData structure. We do this by simply treating
|
||||
// the conn info as configuration input.
|
||||
raw := make(map[string]interface{})
|
||||
for k, v := range s.Ephemeral.ConnInfo {
|
||||
raw[k] = v
|
||||
if s != nil {
|
||||
for k, v := range s.Ephemeral.ConnInfo {
|
||||
raw[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
c, err := config.NewRawConfig(raw)
|
||||
|
@ -137,6 +137,42 @@ func TestProvisionerApply(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestProvisionerApply_nilState(t *testing.T) {
|
||||
p := &Provisioner{
|
||||
ConnSchema: map[string]*Schema{
|
||||
"foo": &Schema{
|
||||
Type: TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
},
|
||||
|
||||
Schema: map[string]*Schema{
|
||||
"foo": &Schema{
|
||||
Type: TypeInt,
|
||||
Optional: true,
|
||||
},
|
||||
},
|
||||
|
||||
ApplyFunc: func(ctx context.Context) error {
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
conf := map[string]interface{}{
|
||||
"foo": 42,
|
||||
}
|
||||
|
||||
c, err := config.NewRawConfig(conf)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
err = p.Apply(nil, nil, terraform.NewResourceConfig(c))
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProvisionerStop(t *testing.T) {
|
||||
var p Provisioner
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user