File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -130,8 +130,10 @@ func (p *Provisioner) Apply(
130130 // easily build a ResourceData structure. We do this by simply treating
131131 // the conn info as configuration input.
132132 raw := make (map [string ]interface {})
133- for k , v := range s .Ephemeral .ConnInfo {
134- raw [k ] = v
133+ if s != nil {
134+ for k , v := range s .Ephemeral .ConnInfo {
135+ raw [k ] = v
136+ }
135137 }
136138
137139 c , err := config .NewRawConfig (raw )
Original file line number Diff line number Diff line change @@ -137,6 +137,42 @@ func TestProvisionerApply(t *testing.T) {
137137 }
138138}
139139
140+ func TestProvisionerApply_nilState (t * testing.T ) {
141+ p := & Provisioner {
142+ ConnSchema : map [string ]* Schema {
143+ "foo" : & Schema {
144+ Type : TypeString ,
145+ Optional : true ,
146+ },
147+ },
148+
149+ Schema : map [string ]* Schema {
150+ "foo" : & Schema {
151+ Type : TypeInt ,
152+ Optional : true ,
153+ },
154+ },
155+
156+ ApplyFunc : func (ctx context.Context ) error {
157+ return nil
158+ },
159+ }
160+
161+ conf := map [string ]interface {}{
162+ "foo" : 42 ,
163+ }
164+
165+ c , err := config .NewRawConfig (conf )
166+ if err != nil {
167+ t .Fatalf ("err: %s" , err )
168+ }
169+
170+ err = p .Apply (nil , nil , terraform .NewResourceConfig (c ))
171+ if err != nil {
172+ t .Fatalf ("err: %s" , err )
173+ }
174+ }
175+
140176func TestProvisionerStop (t * testing.T ) {
141177 var p Provisioner
142178
You can’t perform that action at this time.
0 commit comments