Repository: honeycombio/terraform-provider-honeycombio
Pull request #254 (2022-12-16 16:04:54)

Add board_url link to the board resource output
Co-authored-by: Jason Harley <jason@honeycomb.io>
Signed-off-by: Davin Taddeo <davin@honeycomb.io>

<!--
Thank you for contributing to the project! 💜
Please see our [OSS process document](https://github.com/honeycombio/home/blob/main/honeycomb-oss-lifecycle-and-practices.md#) to get an idea of how we operate.
-->


## Short description of the changes
Adds the new `board_url` output from the Boards API when returning a board create or get action

## How to verify that this has the expected result


codecov-commenter: # [Codecov](https://codecov.io/gh/honeycombio/terraform-provider-honeycombio/pull/254?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=honeycombio) Report
> Merging [#254](https://codecov.io/gh/honeycombio/terraform-provider-honeycombio/pull/254?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=honeycombio) (e88b218) into [main](https://codecov.io/gh/honeycombio/terraform-provider-honeycombio/commit/b5c18699f2a70f04b5b0e4676cd268b664de24a9?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=honeycombio) (b5c1869) will **increase** coverage by `0.03%`.
> The diff coverage is `100.00%`.

> :exclamation: Current head e88b218 differs from pull request most recent head e43f72f. Consider uploading reports for the commit e43f72f to get more accurate results

```diff
@@            Coverage Diff             @@
##             main     #254      +/-   ##
==========================================
+ Coverage   80.51%   80.55%   +0.03%     
==========================================
  Files          42       42              
  Lines        3495     3502       +7     
==========================================
+ Hits         2814     2821       +7     
  Misses        564      564              
  Partials      117      117              
```


| [Impacted Files](https://codecov.io/gh/honeycombio/terraform-provider-honeycombio/pull/254?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=honeycombio) | Coverage Δ | |
|---|---|---|
| [client/board.go](https://codecov.io/gh/honeycombio/terraform-provider-honeycombio/pull/254/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=honeycombio#diff-Y2xpZW50L2JvYXJkLmdv) | `81.81% <ø> (ø)` | |
| [honeycombio/resource\_board.go](https://codecov.io/gh/honeycombio/terraform-provider-honeycombio/pull/254/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=honeycombio#diff-aG9uZXljb21iaW8vcmVzb3VyY2VfYm9hcmQuZ28=) | `83.39% <100.00%> (+0.46%)` | :arrow_up: |

:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=honeycombio)


Patch:
diff --git a/client/board.go b/client/board.go
index 9243b35..b486a7b 100644
--- a/client/board.go
+++ b/client/board.go
@@ -53,6 +53,8 @@ type Board struct {
 	ColumnLayout BoardColumnStyle `json:"column_layout,omitempty"`
 	// How the board should be displayed in the UI, defaults to "list".
 	Style BoardStyle `json:"style,omitempty"`
+	// Links returned by the board API for the Board
+	Links BoardLinks `json:"links,omitempty"`
 	// A list of queries displayed on the board, in order of appearance.
 	Queries []BoardQuery `json:"queries"`
 }
@@ -78,6 +80,12 @@ const (
 	BoardColumnStyleSingle BoardColumnStyle = "single"
 )
 
+// BoardLinks represents links returned by the board API.
+type BoardLinks struct {
+	// URL For accessing the board
+	BoardURL string `json:"board_url,omitempty"`
+}
+
 // BoardQuery represents a query that is part of a board.
 type BoardQuery struct {
 	Caption string `json:"caption,omitempty"`
diff --git a/docs/resources/board.md b/docs/resources/board.md
index 73f08f8..dd093af 100644
--- a/docs/resources/board.md
+++ b/docs/resources/board.md
@@ -125,12 +125,13 @@ Currently supported toggles are:
 In addition to all arguments above, the following attributes are exported:
 
 * `id` - ID of the board.
+* `board_url` - The URL to the board in the Honeycomb UI.
 
 ## Import
 
 Boards can be imported using their ID, e.g.
 
-```
+```shell
 $ terraform import honeycombio_board.my_board AobW9oAZX71
 ```
 
diff --git a/honeycombio/resource_board.go b/honeycombio/resource_board.go
index 2c376df..c14eacf 100644
--- a/honeycombio/resource_board.go
+++ b/honeycombio/resource_board.go
@@ -43,6 +43,12 @@ func newBoard() *schema.Resource {
 				Default:      "list",
 				ValidateFunc: validation.StringInSlice(boardStyleStrings(), false),
 			},
+			"board_url": {
+				Type:     schema.TypeString,
+				Required: false,
+				Optional: false,
+				Computed: true,
+			},
 			"query": {
 				Type:     schema.TypeList,
 				Optional: true,
@@ -156,6 +162,7 @@ func resourceBoardRead(ctx context.Context, d *schema.ResourceData, meta interfa
 	d.Set("description", b.Description)
 	d.Set("style", b.Style)
 	d.Set("column_layout", b.ColumnLayout)
+	d.Set("board_url", b.Links.BoardURL)
 
 	queries := make([]map[string]interface{}, len(b.Queries))
 


Test patch:
diff --git a/client/board_test.go b/client/board_test.go
index 9cd87f4..ba80298 100644
--- a/client/board_test.go
+++ b/client/board_test.go
@@ -54,6 +54,10 @@ func TestBoards(t *testing.T) {
 		data.ID = b.ID
 		data.Queries[0].QueryID = b.Queries[0].QueryID
 
+		// ensure the board URL got populated
+		assert.NotEqual(t, b.Links.BoardURL, "")
+		data.Links.BoardURL = b.Links.BoardURL
+
 		assert.Equal(t, data, b)
 	})