Skip to content

Commit

Permalink
feat: support isHome field for bookmark_group (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
obs-gh-abhinavpappu authored Sep 24, 2024
1 parent a7e1068 commit 3bf6b24
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 18 deletions.
1 change: 1 addition & 0 deletions client/internal/meta/operation/bookmark_group.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ fragment BookmarkGroup on BookmarkGroup {
description
iconUrl
workspaceId
isHome
}

mutation createOrUpdateBookmarkGroup(
Expand Down
6 changes: 6 additions & 0 deletions client/meta/genqlient.generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions docs/resources/bookmark_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,20 @@ resource "observe_bookmark_group" "example" {
### Required

- `name` (String) Name of bookmark group.
- `workspace` (String) OID of workspace bookmark group belongs to.
- `workspace` (String) OID of the workspace this object is contained in.

### Optional

- `description` (String) Description of bookmark group.
- `icon_url` (String) Icon used when presenting bookmark group.
- `is_home` (Boolean) Whether to add this bookmark group to the home page
- `presentation` (String)

### Read-Only

- `id` (String) The ID of this resource.
- `oid` (String) Observe ID of the bookmark group.
- `oid` (String) OID (Observe ID) for this object. This is the canonical identifier that
should be used when referring to this object in terraform manifests.
## Import
Import is supported using the following syntax:
```shell
Expand Down
12 changes: 12 additions & 0 deletions observe/descriptions/bookmark_group.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
description: |
Manages a bookmark group.
schema:
name: |
Name of bookmark group.
description: |
Description of bookmark group.
icon_url: |
Icon used when presenting bookmark group.
presentation: ""
is_home: |
Whether to add this bookmark group to the home page
35 changes: 19 additions & 16 deletions observe/resource_bookmark_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,12 @@ import (
observe "github.com/observeinc/terraform-provider-observe/client"
gql "github.com/observeinc/terraform-provider-observe/client/meta"
"github.com/observeinc/terraform-provider-observe/client/oid"
)

const (
schemaBookmarkGroupOIDDescription = "Observe ID of the bookmark group."
schemaBookmarkGroupWorkspaceDescription = "OID of workspace bookmark group belongs to."
schemaBookmarkGroupNameDescription = "Name of bookmark group."
schemaBookmarkGroupDescriptionDescription = "Description of bookmark group."
schemaBookmarkGroupIconDescription = "Icon used when presenting bookmark group."
schemaBookmarkGroupPresentationDescription = ""
"github.com/observeinc/terraform-provider-observe/observe/descriptions"
)

func resourceBookmarkGroup() *schema.Resource {
return &schema.Resource{
Description: "Manages a bookmark group.",
Description: descriptions.Get("bookmark_group", "description"),
CreateContext: resourceBookmarkGroupCreate,
ReadContext: resourceBookmarkGroupRead,
UpdateContext: resourceBookmarkGroupUpdate,
Expand All @@ -35,29 +27,29 @@ func resourceBookmarkGroup() *schema.Resource {
"oid": {
Type: schema.TypeString,
Computed: true,
Description: schemaBookmarkGroupOIDDescription,
Description: descriptions.Get("common", "schema", "oid"),
},
"workspace": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateDiagFunc: validateOID(oid.TypeWorkspace),
Description: schemaBookmarkGroupWorkspaceDescription,
Description: descriptions.Get("common", "schema", "workspace"),
},
"name": {
Type: schema.TypeString,
Required: true,
Description: schemaBookmarkGroupNameDescription,
Description: descriptions.Get("bookmark_group", "schema", "name"),
},
"description": {
Type: schema.TypeString,
Optional: true,
Description: schemaBookmarkGroupDescriptionDescription,
Description: descriptions.Get("bookmark_group", "schema", "description"),
},
"icon_url": {
Type: schema.TypeString,
Optional: true,
Description: schemaBookmarkGroupIconDescription,
Description: descriptions.Get("bookmark_group", "schema", "icon_url"),
},
"presentation": {
Type: schema.TypeString,
Expand All @@ -67,7 +59,13 @@ func resourceBookmarkGroup() *schema.Resource {
}, false),
Default: gql.BookmarkGroupPresentationPercustomerworkspace,
Optional: true,
Description: schemaBookmarkGroupPresentationDescription,
Description: descriptions.Get("bookmark_group", "schema", "presentation"),
},
"is_home": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: descriptions.Get("bookmark_group", "schema", "is_home"),
},
},
}
Expand All @@ -77,6 +75,7 @@ func newBookmarkGroupConfig(data *schema.ResourceData) (input *gql.BookmarkGroup
input = &gql.BookmarkGroupInput{
Name: stringPtr(data.Get("name").(string)),
Description: stringPtr(data.Get("description").(string)),
IsHome: boolPtr(data.Get("is_home").(bool)),
}

p := gql.BookmarkGroupPresentation(data.Get("presentation").(string))
Expand Down Expand Up @@ -104,6 +103,10 @@ func bookmarkGroupToResourceData(bg *gql.BookmarkGroup, data *schema.ResourceDat
}
}

if err := data.Set("is_home", bg.IsHome); err != nil {
diags = append(diags, diag.FromErr(err)...)
}

if diags.HasError() {
return diags
}
Expand Down

0 comments on commit 3bf6b24

Please sign in to comment.