Skip to content

Commit

Permalink
added dog_inventory group children
Browse files Browse the repository at this point in the history
  • Loading branch information
dgulinobw committed Mar 14, 2023
1 parent 3b7ebad commit 70608a6
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/hashicorp/terraform-plugin-go v0.14.1
github.com/hashicorp/terraform-plugin-log v0.7.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.0
github.com/relaypro-open/dog_api_golang v0.0.0-20230314165349-3ab62e33385c
github.com/relaypro-open/dog_api_golang v0.0.0-20230314202211-1f206a499fdf
golang.org/x/exp v0.0.0-20221114191408-850992195362
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ github.com/relaypro-open/dog_api_golang v0.0.0-20230314145046-afc83bae3332 h1:xr
github.com/relaypro-open/dog_api_golang v0.0.0-20230314145046-afc83bae3332/go.mod h1:gVISNtT0C/Ej5ZnCePDyppaDQiPRANiq2A/qhx/tH+8=
github.com/relaypro-open/dog_api_golang v0.0.0-20230314165349-3ab62e33385c h1:ErGp9MPmTLJ+Z/onCWkvXwIFbskhRLcl5usX9k7Ctwk=
github.com/relaypro-open/dog_api_golang v0.0.0-20230314165349-3ab62e33385c/go.mod h1:gVISNtT0C/Ej5ZnCePDyppaDQiPRANiq2A/qhx/tH+8=
github.com/relaypro-open/dog_api_golang v0.0.0-20230314202211-1f206a499fdf h1:hjOYbQV/tPMthuxmI4iwtAI85WHJ/h2ac4EHs9T4B/w=
github.com/relaypro-open/dog_api_golang v0.0.0-20230314202211-1f206a499fdf/go.mod h1:gVISNtT0C/Ej5ZnCePDyppaDQiPRANiq2A/qhx/tH+8=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
Expand Down
1 change: 1 addition & 0 deletions internal/provider/datasource_inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type (
Name types.String `tfsdk:"name"`
Vars map[string]string `tfsdk:"vars"`
Hosts map[string]map[string]string `tfsdk:"hosts"`
Children []string `tfsdk:"children"`
}
)

Expand Down
8 changes: 8 additions & 0 deletions internal/provider/resource_inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ func (*inventoryResource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Dia
Required: true,
Type: types.MapType{ElemType: types.MapType{ElemType: types.StringType}},
},
"children": {
MarkdownDescription: "inventory group children",
Required: true,
Type: types.ListType{ElemType: types.StringType},
},
}),
},
"name": {
Expand Down Expand Up @@ -112,6 +117,7 @@ func InventoryToCreateRequest(plan inventoryResourceData) api.InventoryCreateReq
Name: group.Name.Value,
Vars: group.Vars,
Hosts: group.Hosts,
Children: group.Children,
}
newGroups = append(newGroups, g)
}
Expand All @@ -129,6 +135,7 @@ func InventoryToUpdateRequest(plan inventoryResourceData) api.InventoryUpdateReq
Name: group.Name.Value,
Vars: group.Vars,
Hosts: group.Hosts,
Children: group.Children,
}
newGroups = append(newGroups, g)
}
Expand All @@ -146,6 +153,7 @@ func ApiToInventory(inventory api.Inventory) Inventory {
Name: types.String{Value: group.Name},
Vars: group.Vars,
Hosts: group.Hosts,
Children: group.Children,
}
newGroups = append(newGroups, g)
}
Expand Down
10 changes: 8 additions & 2 deletions internal/provider/test/datasource_inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ resource "dog_inventory" %[1]q {
host2 = {
key2 = "value2"
}
}
},
children = [
"test"
]
},
{
name = "app"
Expand All @@ -53,7 +56,10 @@ resource "dog_inventory" %[1]q {
host1 = {
key = "value"
}
}
},
children = [
"test2"
]
}
]
}
Expand Down
10 changes: 8 additions & 2 deletions internal/provider/test/resource_inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ resource %[1]q %[2]q {
host2 = {
key2 = "value2"
}
}
},
children = [
"test"
]
},
{
name = "app"
Expand All @@ -66,7 +69,10 @@ resource %[1]q %[2]q {
host1 = {
key = "value"
}
}
},
children = [
"test2"
]
}
]
}
Expand Down

0 comments on commit 70608a6

Please sign in to comment.