Skip to content

Commit 6dea731

Browse files
committed
Add description to page resource
1 parent 414b784 commit 6dea731

File tree

9 files changed

+60
-45
lines changed

9 files changed

+60
-45
lines changed

docs/resources/port_page.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ subcategory: ""
55
description: |-
66
Page resource
77
Docs about the different page types can be found here https://docs.getport.io/customize-pages-dashboards-and-plugins/page/catalog-page.
8-
~> WARNINGThe page resource is currently in beta and is subject to change in future versions.Use it by setting the Environment Variable PORT_BETA_FEATURES_ENABLED=true.If this Environment Variable isn't specified, you won't be able to use the resource.
8+
~> WARNING
9+
The page resource is currently in beta and is subject to change in future versions.
10+
Use it by setting the Environment Variable PORT_BETA_FEATURES_ENABLED=true.
11+
If this Environment Variable isn't specified, you won't be able to use the resource.
912
Example Usage
1013
Blueprint Entities Page
1114
```hcl
@@ -213,10 +216,10 @@ description: |-
213216

214217
Docs about the different page types can be found [here](https://docs.getport.io/customize-pages-dashboards-and-plugins/page/catalog-page).
215218

216-
~> **WARNING**
217-
The page resource is currently in beta and is subject to change in future versions.
218-
Use it by setting the Environment Variable `PORT_BETA_FEATURES_ENABLED=true`.
219-
If this Environment Variable isn't specified, you won't be able to use the resource.
219+
~> **WARNING**
220+
The page resource is currently in beta and is subject to change in future versions.
221+
Use it by setting the Environment Variable `PORT_BETA_FEATURES_ENABLED=true`.
222+
If this Environment Variable isn't specified, you won't be able to use the resource.
220223

221224
## Example Usage
222225

@@ -440,7 +443,7 @@ resource "port_page" "home_page" {
440443

441444
The home page is a special page, which is created by default when you create a new organization.
442445

443-
- When deleting the home page resource using terraform, the home page will not be deleted from Port as it isn't deletable page, instead, the home page will be removed from the terraform state.
446+
- When deleting the home page resource using terraform, the home page will not be deleted from Port as it isn't deletable page, instead, the home page will be removed from the terraform state.
444447
- Due to only having one home page you'll have to import the state of the home page manually.
445448

446449
```
@@ -461,6 +464,7 @@ terraform import port_page.home_page "\$home"
461464

462465
- `after` (String) The identifier of the page/folder after which the page should be placed
463466
- `blueprint` (String) The blueprint for which the page is created, relevant only for pages of type "blueprint-entities"
467+
- `description` (String) The page description
464468
- `icon` (String) The icon of the page
465469
- `locked` (Boolean) Whether the page is locked, if true, viewers will not be able to edit the page widgets and filters
466470
- `parent` (String) The identifier of the folder in which the page is in, default is the root of the sidebar
@@ -474,5 +478,3 @@ terraform import port_page.home_page "\$home"
474478
- `id` (String) The ID of this resource.
475479
- `updated_at` (String) The last update date of the page
476480
- `updated_by` (String) The last updater of the page
477-
478-

examples/resources/port_page/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ resource "port_page" "microservice_blueprint_page" {
44
type = "blueprint-entities"
55
icon = "Microservice"
66
blueprint = port_blueprint.base_blueprint.identifier
7+
description = "My microservice blueprint page"
78
widgets = [
89
jsonencode(
910
{

internal/cli/models.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,16 @@ type (
255255

256256
Page struct {
257257
Meta
258-
Identifier string `json:"identifier,omitempty"`
259-
Type string `json:"type,omitempty"`
260-
Icon *string `json:"icon,omitempty"`
261-
Parent *string `json:"parent,omitempty"`
262-
After *string `json:"after,omitempty"`
263-
Title *string `json:"title,omitempty"`
264-
Locked *bool `json:"locked,omitempty"`
265-
Blueprint *string `json:"blueprint,omitempty"`
266-
Widgets *[]map[string]any `json:"widgets,omitempty"`
258+
Identifier string `json:"identifier,omitempty"`
259+
Type string `json:"type,omitempty"`
260+
Icon *string `json:"icon,omitempty"`
261+
Parent *string `json:"parent,omitempty"`
262+
After *string `json:"after,omitempty"`
263+
Title *string `json:"title,omitempty"`
264+
Locked *bool `json:"locked,omitempty"`
265+
Blueprint *string `json:"blueprint,omitempty"`
266+
Widgets *[]map[string]any `json:"widgets,omitempty"`
267+
Description *string `json:"description,omitempty"`
267268
}
268269

269270
PageReadPermissions struct {

port/page/model.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@ package page
33
import "github.com/hashicorp/terraform-plugin-framework/types"
44

55
type PageModel struct {
6-
ID types.String `tfsdk:"id"`
7-
Identifier types.String `tfsdk:"identifier"`
8-
Title types.String `tfsdk:"title"`
9-
Type types.String `tfsdk:"type"`
10-
Parent types.String `tfsdk:"parent"`
11-
After types.String `tfsdk:"after"`
12-
Icon types.String `tfsdk:"icon"`
13-
Locked types.Bool `tfsdk:"locked"`
14-
Blueprint types.String `tfsdk:"blueprint"`
15-
Widgets []types.String `tfsdk:"widgets"`
16-
CreatedAt types.String `tfsdk:"created_at"`
17-
CreatedBy types.String `tfsdk:"created_by"`
18-
UpdatedAt types.String `tfsdk:"updated_at"`
19-
UpdatedBy types.String `tfsdk:"updated_by"`
6+
ID types.String `tfsdk:"id"`
7+
Identifier types.String `tfsdk:"identifier"`
8+
Title types.String `tfsdk:"title"`
9+
Type types.String `tfsdk:"type"`
10+
Parent types.String `tfsdk:"parent"`
11+
After types.String `tfsdk:"after"`
12+
Icon types.String `tfsdk:"icon"`
13+
Locked types.Bool `tfsdk:"locked"`
14+
Blueprint types.String `tfsdk:"blueprint"`
15+
Widgets []types.String `tfsdk:"widgets"`
16+
CreatedAt types.String `tfsdk:"created_at"`
17+
CreatedBy types.String `tfsdk:"created_by"`
18+
UpdatedAt types.String `tfsdk:"updated_at"`
19+
UpdatedBy types.String `tfsdk:"updated_by"`
20+
Description types.String `tfsdk:"description"`
2021
}

port/page/pageToPortBody.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ import (
88

99
func PageToPortBody(pm *PageModel) (*cli.Page, error) {
1010
pb := &cli.Page{
11-
Identifier: pm.Identifier.ValueString(),
12-
Type: pm.Type.ValueString(),
13-
Icon: pm.Icon.ValueStringPointer(),
14-
Title: pm.Title.ValueStringPointer(),
15-
Locked: pm.Locked.ValueBoolPointer(),
16-
Blueprint: pm.Blueprint.ValueStringPointer(),
17-
Parent: pm.Parent.ValueStringPointer(),
18-
After: pm.After.ValueStringPointer(),
11+
Identifier: pm.Identifier.ValueString(),
12+
Type: pm.Type.ValueString(),
13+
Icon: pm.Icon.ValueStringPointer(),
14+
Title: pm.Title.ValueStringPointer(),
15+
Locked: pm.Locked.ValueBoolPointer(),
16+
Blueprint: pm.Blueprint.ValueStringPointer(),
17+
Parent: pm.Parent.ValueStringPointer(),
18+
After: pm.After.ValueStringPointer(),
19+
Description: pm.Description.ValueStringPointer(),
1920
}
2021

2122
widgets, err := widgetsToPortBody(pm.Widgets)

port/page/refreshPageToState.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ func refreshPageToState(pm *PageModel, b *cli.Page) error {
1616
pm.Title = types.StringPointerValue(b.Title)
1717
pm.Locked = types.BoolPointerValue(b.Locked)
1818
pm.Blueprint = types.StringPointerValue(b.Blueprint)
19+
pm.Description = types.StringPointerValue(b.Description)
1920

2021
pm.Widgets = make([]types.String, len(*b.Widgets))
2122
if b.Widgets != nil {

port/page/resource.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ func (r *PageResource) Create(ctx context.Context, req resource.CreateRequest, r
135135
state.CreatedBy = types.StringValue(p.CreatedBy)
136136
state.UpdatedAt = types.StringValue(p.UpdatedAt.String())
137137
state.UpdatedBy = types.StringValue(p.UpdatedBy)
138+
state.Description = types.StringPointerValue(p.Description)
138139

139140
resp.Diagnostics.Append(resp.State.Set(ctx, &state)...)
140141
}
@@ -172,6 +173,7 @@ func (r *PageResource) Update(ctx context.Context, req resource.UpdateRequest, r
172173
state.CreatedBy = types.StringValue(p.CreatedBy)
173174
state.UpdatedAt = types.StringValue(p.UpdatedAt.String())
174175
state.UpdatedBy = types.StringValue(p.UpdatedBy)
176+
state.Description = types.StringPointerValue(p.Description)
175177

176178
resp.Diagnostics.Append(resp.State.Set(ctx, &state)...)
177179

port/page/resource_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ resource "port_page" "microservice_dashboard_page" {
146146
title = "dashboards"
147147
icon = "GitHub"
148148
type = "dashboard"
149+
description = "My Dashboard Page Description"
149150
widgets = [
150151
jsonencode(
151152
{
@@ -186,6 +187,7 @@ resource "port_page" "microservice_dashboard_page" {
186187
Config: acctest.ProviderConfig + testAccPortPageResourceBasic,
187188
Check: resource.ComposeTestCheckFunc(
188189
resource.TestCheckResourceAttr("port_page.microservice_dashboard_page", "identifier", pageIdentifier),
190+
resource.TestCheckResourceAttr("port_page.microservice_dashboard_page", "description", "My Dashboard Page Description"),
189191
resource.TestCheckResourceAttr("port_page.microservice_dashboard_page", "title", "dashboards"),
190192
resource.TestCheckResourceAttr("port_page.microservice_dashboard_page", "icon", "GitHub"),
191193
resource.TestCheckResourceAttr("port_page.microservice_dashboard_page", "type", "dashboard"),

port/page/schema.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ func PageSchema() map[string]schema.Attribute {
8383
MarkdownDescription: "The last updater of the page",
8484
Computed: true,
8585
},
86+
"description": schema.StringAttribute{
87+
MarkdownDescription: "The page description",
88+
Optional: true,
89+
},
8690
}
8791
}
8892

@@ -114,10 +118,10 @@ var PageResourceMarkdownDescription = `
114118
115119
Docs about the different page types can be found [here](https://docs.getport.io/customize-pages-dashboards-and-plugins/page/catalog-page).
116120
117-
~> **WARNING**
118-
The page resource is currently in beta and is subject to change in future versions.
119-
Use it by setting the Environment Variable ` + "`PORT_BETA_FEATURES_ENABLED=true`" + `.
120-
If this Environment Variable isn't specified, you won't be able to use the resource.
121+
~> **WARNING**
122+
The page resource is currently in beta and is subject to change in future versions.
123+
Use it by setting the Environment Variable ` + "`PORT_BETA_FEATURES_ENABLED=true`" + `.
124+
If this Environment Variable isn't specified, you won't be able to use the resource.
121125
122126
## Example Usage
123127
@@ -341,11 +345,11 @@ resource "port_page" "home_page" {
341345
342346
The home page is a special page, which is created by default when you create a new organization.
343347
344-
- When deleting the home page resource using terraform, the home page will not be deleted from Port as it isn't deletable page, instead, the home page will be removed from the terraform state.
348+
- When deleting the home page resource using terraform, the home page will not be deleted from Port as it isn't deletable page, instead, the home page will be removed from the terraform state.
345349
- Due to only having one home page you'll have to import the state of the home page manually.
346350
347351
` + "```" + `
348352
terraform import port_page.home_page "\$home"
349353
` + "```" + `
350-
354+
351355
`

0 commit comments

Comments
 (0)