Skip to content

Commit e7a2798

Browse files
committed
fix nil
1 parent d7c2ef2 commit e7a2798

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

provisioner/terraform/resources.go

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,20 @@ type agentAttributes struct {
2525

2626
// A mapping of attributes on the "coder_app" resource.
2727
type agentAppAttributes struct {
28-
AgentID string `mapstructure:"agent_id"`
29-
Name string `mapstructure:"name"`
30-
Icon string `mapstructure:"icon"`
31-
URL string `mapstructure:"url"`
32-
Command string `mapstructure:"command"`
33-
RelativePath bool `mapstructure:"relative_path"`
34-
HealthcheckURL string `mapstructure:"healthcheck_url"`
35-
HealthcheckInterval int32 `mapstructure:"healthcheck_interval"`
36-
HealthcheckThreshold int32 `mapstructure:"healthcheck_threshold"`
28+
AgentID string `mapstructure:"agent_id"`
29+
Name string `mapstructure:"name"`
30+
Icon string `mapstructure:"icon"`
31+
URL string `mapstructure:"url"`
32+
Command string `mapstructure:"command"`
33+
RelativePath bool `mapstructure:"relative_path"`
34+
Healthcheck *appHealthcheckAttributes `mapstructure:"healthcheck"`
35+
}
36+
37+
// A mapping of attributes on the "healthcheck" resource.
38+
type appHealthcheckAttributes struct {
39+
URL string `mapstructure:"url"`
40+
Interval int32 `mapstructure:"interval"`
41+
Threshold int32 `mapstructure:"threshold"`
3742
}
3843

3944
// A mapping of attributes on the "coder_metadata" resource.
@@ -221,6 +226,14 @@ func ConvertResources(module *tfjson.StateModule, rawGraph string) ([]*proto.Res
221226
// Default to the resource name if none is set!
222227
attrs.Name = resource.Name
223228
}
229+
var healthcheck *proto.Healthcheck
230+
if attrs.Healthcheck != nil {
231+
healthcheck = &proto.Healthcheck{
232+
Url: attrs.Healthcheck.URL,
233+
Interval: attrs.Healthcheck.Interval,
234+
Threshold: attrs.Healthcheck.Threshold,
235+
}
236+
}
224237
for _, agents := range resourceAgents {
225238
for _, agent := range agents {
226239
// Find agents with the matching ID and associate them!
@@ -233,11 +246,7 @@ func ConvertResources(module *tfjson.StateModule, rawGraph string) ([]*proto.Res
233246
Url: attrs.URL,
234247
Icon: attrs.Icon,
235248
RelativePath: attrs.RelativePath,
236-
Healthcheck: &proto.Healthcheck{
237-
Url: attrs.HealthcheckURL,
238-
Interval: attrs.HealthcheckInterval,
239-
Threshold: attrs.HealthcheckThreshold,
240-
},
249+
Healthcheck: healthcheck,
241250
})
242251
}
243252
}

0 commit comments

Comments
 (0)