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

add support for dashboard- and chart-level workflow links #232

Merged
merged 7 commits into from
Aug 8, 2024

Conversation

MisterSquishy
Copy link
Contributor

e.g.

resource "lightstep_dashboard" "test_workflow_links" {
	...
	workflow_link {
		name = "test dashboard link"
		url  = "https://test.com"
	}

	chart {
		...
		workflow_link {
			name = "test chart link"
			url  = "https://testchart.com"
		}
	}
}

@MisterSquishy MisterSquishy requested a review from a team August 7, 2024 17:48
@@ -471,13 +505,17 @@ func getUnifiedDashboardAttributesFromResource(d *schema.ResourceData) (*client.
eventQueriesSet := d.Get("event_query_ids").(*schema.Set)
eventQueries := buildStringSlice(eventQueriesSet.List())

workflowLinksList := d.Get("workflow_link").([]any)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this whole []any business? 🧐

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type casting with an unexpected shape?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that d.Get function is getting the list of workflow links from the terraform state -- but all we told terraform is the schema, so it doesnt have a strongly-typed representation of the data

im honestly not totally sure why we traditionally cast to []any first, and then do a subsequent cast (down here) to get the elements of the array as maps. i think maybe i dont like that pattern and im gonna break it here?? let's see how this goes...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 all for seeing how it goes in the face of uncertainty 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it did not go great 😂

panic: interface conversion: interface {} is []interface {}, not []map[string]string

i guess go makes you cast in two steps??

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even just this doesnt work -- i guess generic arrays and maps omit type info, so their elements must be cast individually 😞
CleanShot 2024-08-08 at 14 40 15@2x

@MisterSquishy MisterSquishy merged commit 2fc3ecf into main Aug 8, 2024
6 checks passed
@MisterSquishy MisterSquishy deleted the workflow_links branch August 8, 2024 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants