Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-recursive types for Group definition may be unhelpful #128

Open
t0yv0 opened this issue May 5, 2021 · 0 comments
Open

Non-recursive types for Group definition may be unhelpful #128

t0yv0 opened this issue May 5, 2021 · 0 comments
Labels
kind/bug Some behavior is incorrect or out of spec

Comments

@t0yv0
Copy link
Member

t0yv0 commented May 5, 2021

Consider this example from dashboard.md:

  widget {
    group_definition {
      layout_type = "ordered"
      title       = "Group Widget"

      widget {
        note_definition {
          content          = "cluster note widget"
          background_color = "pink"
          font_size        = "14"
          text_align       = "center"
          show_tick        = true
          tick_edge        = "left"
          tick_pos         = "50%"
        }
      }

      widget {
        alert_graph_definition {
          alert_id  = "123"
          viz_type  = "toplist"
          title     = "Alert Graph"
          live_span = "1h"
        }
      }
    }
  }

Expected behavior

Expect to group any kind of widget into a group_definition.

Current behavior

Generated types for the widget nested under the group_definition are different and cannot be used in a group_definition.

package datadog

import (
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func pinkNote() DashboardWidgetArgs {
	return DashboardWidgetArgs{
		NoteDefinition: DashboardWidgetNoteDefinitionArgs{
			BackgroundColor: pulumi.String("pink"),
			Content:         pulumi.String("pink note"),
		},
	}
}

func incorrect() DashboardWidgetArgs {
	return DashboardWidgetArgs{
		GroupDefinition: &DashboardWidgetGroupDefinitionArgs{
			LayoutType: pulumi.String("ordered"),
			Title:      pulumi.String("Group Widget"),
			Widgets: DashboardWidgetGroupDefinitionWidgetArray{
				pinkNote(),
			},
		},
	}
}

func correct() *DashboardWidgetArgs {
	return &DashboardWidgetArgs{
		GroupDefinition: &DashboardWidgetGroupDefinitionArgs{
			LayoutType: pulumi.String("ordered"),
			Title:      pulumi.String("Group Widget"),
			Widgets: DashboardWidgetGroupDefinitionWidgetArray{
				DashboardWidgetGroupDefinitionWidgetArgs{
					NoteDefinition: DashboardWidgetGroupDefinitionWidgetNoteDefinitionArgs{
						BackgroundColor: pulumi.String("pink"),
						Content:         pulumi.String("pink note"),
					},
				},
			},
		},
	}
}

./dashboard_test.go:22:13: cannot use pinkNote() (type DashboardWidgetArgs) as type DashboardWidgetGroupDefinitionWidgetInput in slice literal:
	DashboardWidgetArgs does not implement DashboardWidgetGroupDefinitionWidgetInput (missing ToDashboardWidgetGroupDefinitionWidgetOutput method)

Context (Environment)

Working on upgrading doc parsing to accept Nested Schema sections.

@t0yv0 t0yv0 added the kind/bug Some behavior is incorrect or out of spec label May 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

1 participant