Skip to content

Commit

Permalink
[datadog_dashboards] Handle empty group definition (#1576)
Browse files Browse the repository at this point in the history
* fmt

* handle empty group definitions

* make docs
  • Loading branch information
skarimo authored Sep 26, 2022
1 parent 26bab4c commit 9e4bb40
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion datadog/internal/utils/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func NewResourceDataKey(d *schema.ResourceData, initial string) *ResourceDataKey
return rdk
}

//interfaceToPartsStr converts an interface to string, assuming it's a string or int,
// interfaceToPartsStr converts an interface to string, assuming it's a string or int,
// it panics otherwise.
func (k *ResourceDataKey) interfaceToPartsStr(i interface{}, method string) string {
switch i := i.(type) {
Expand Down
4 changes: 3 additions & 1 deletion datadog/resource_datadog_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ func getGroupDefinitionSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"widget": {
Type: schema.TypeList,
Required: true,
Optional: true,
Description: "The list of widgets in this group.",
Elem: &schema.Resource{
Schema: getNonGroupWidgetSchema(),
Expand Down Expand Up @@ -1306,6 +1306,8 @@ func buildDatadogGroupDefinition(terraformGroupDefinition map[string]interface{}
return nil, err
}
datadogGroupDefinition.SetWidgets(*datadogWidgets)
} else {
datadogGroupDefinition.SetWidgets([]datadogV1.Widget{})
}
if v, ok := terraformGroupDefinition["layout_type"].(string); ok && len(v) != 0 {
datadogGroupDefinition.SetLayoutType(datadogV1.WidgetLayoutType(v))
Expand Down
4 changes: 2 additions & 2 deletions datadog/resource_datadog_logs_archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func resourceDatadogLogsArchiveDelete(ctx context.Context, d *schema.ResourceDat
return nil
}

//Model to map
// Model to map
func buildDestination(archiveDestination datadogV2.NullableLogsArchiveDestination) (string, map[string]interface{}, error) {
emptyDestination := map[string]interface{}{}
if archiveDestination.IsSet() {
Expand Down Expand Up @@ -249,7 +249,7 @@ func buildS3Map(destination datadogV2.LogsArchiveDestinationS3) map[string]inter
return result
}

//Map to model
// Map to model
func buildDatadogArchiveCreateReq(d *schema.ResourceData) (*datadogV2.LogsArchiveCreateRequest, error) {
archive := datadogV2.NewLogsArchiveCreateRequest()
destination, err := buildCreateReqDestination(d)
Expand Down
2 changes: 1 addition & 1 deletion datadog/resource_datadog_logs_archive_order.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func getArchiveIds(d *schema.ResourceData) []string {
return ddList
}

//Map to model
// Map to model
func buildDatadogArchiveOrderCreateReq(d *schema.ResourceData) (*datadogV2.LogsArchiveOrder, error) {
archiveOrderAttributes := datadogV2.NewLogsArchiveOrderAttributes(getArchiveIds(d))

Expand Down
1 change: 1 addition & 0 deletions datadog/tests/data_source_datadog_application_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"

"github.com/terraform-providers/terraform-provider-datadog/datadog"
"github.com/terraform-providers/terraform-provider-datadog/datadog/internal/utils"
)
Expand Down
2 changes: 1 addition & 1 deletion datadog/tests/resource_datadog_logs_archive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)

//Test
// Test
// create: OK azure
func archiveAzureConfigForCreation(uniq string) string {
return fmt.Sprintf(`
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -2103,14 +2103,14 @@ Required:
Required:

- `layout_type` (String) The layout type of the group. Valid values are `ordered`.
- `widget` (Block List, Min: 1) The list of widgets in this group. (see [below for nested schema](#nestedblock--widget--group_definition--widget))

Optional:

- `background_color` (String) The background color of the group title, options: `vivid_blue`, `vivid_purple`, `vivid_pink`, `vivid_orange`, `vivid_yellow`, `vivid_green`, `blue`, `purple`, `pink`, `orange`, `yellow`, `green`, `gray` or `white`
- `banner_img` (String) The image URL to display as a banner for the group.
- `show_title` (Boolean) Whether to show the title or not.
- `title` (String) The title of the group.
- `widget` (Block List) The list of widgets in this group. (see [below for nested schema](#nestedblock--widget--group_definition--widget))

<a id="nestedblock--widget--group_definition--widget"></a>
### Nested Schema for `widget.group_definition.widget`
Expand Down

0 comments on commit 9e4bb40

Please sign in to comment.