Skip to content

Commit 9abb9b8

Browse files
committed
Add import to host resources
1 parent c3b8a3d commit 9abb9b8

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

icinga2/resource_icinga2_host.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ import (
1111
func resourceIcinga2Host() *schema.Resource {
1212

1313
return &schema.Resource{
14-
Create: resourceIcinga2HostCreate,
15-
Exists: resourceIcinga2HostExists,
16-
Read: resourceIcinga2HostRead,
17-
Delete: resourceIcinga2HostDelete,
14+
Create: resourceIcinga2HostCreate,
15+
Exists: resourceIcinga2HostExists,
16+
Read: resourceIcinga2HostRead,
17+
Delete: resourceIcinga2HostDelete,
18+
Importer: &schema.ResourceImporter{
19+
State: resourceIcinga2HostImport,
20+
},
1821
Schema: map[string]*schema.Schema{
1922
"hostname": {
2023
Type: schema.TypeString,
@@ -172,3 +175,10 @@ func resourceIcinga2HostDelete(d *schema.ResourceData, meta interface{}) error {
172175
return nil
173176

174177
}
178+
179+
func resourceIcinga2HostImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
180+
d.Set("hostname", d.Id())
181+
err := resourceIcinga2HostRead(d, meta)
182+
183+
return []*schema.ResourceData{d}, err
184+
}

0 commit comments

Comments
 (0)