Skip to content

Commit 5838e2e

Browse files
authored
Add support for managing imageUrl in Kibana spaces (#664)
* Add support for managing image_url * Generate docs * Changelog
1 parent 332281f commit 5838e2e

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- Fix alerting rule update crash when backend responds with HTTP 4xx. ([#649](https://github.com/elastic/terraform-provider-elasticstack/pull/649))
1010
- Fix the elasticstack_kibana_data_view resource when not specifying an `id` and running against Kibana 8.14 ([#663](https://github.com/elastic/terraform-provider-elasticstack/pull/663))
1111
- Support allow_write_after_shrink when managing ILM policies ([#662](https://github.com/elastic/terraform-provider-elasticstack/pull/662))
12+
- Support managing image_url in Kibana spaces ([#664](https://github.com/elastic/terraform-provider-elasticstack/pull/664))
1213

1314
## [0.11.3] - 2024-05-16
1415

docs/resources/kibana_space.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ resource "elasticstack_kibana_space" "example" {
3939
- `color` (String) The hexadecimal color code used in the space avatar. By default, the color is automatically generated from the space name.
4040
- `description` (String) The description for the space.
4141
- `disabled_features` (Set of String) The list of disabled features for the space. To get a list of available feature IDs, use the Features API (https://www.elastic.co/guide/en/kibana/master/features-api-get.html).
42+
- `image_url` (String) The data-URL encoded image to display in the space avatar.
4243
- `initials` (String) The initials shown in the space avatar. By default, the initials are automatically generated from the space name. Initials must be 1 or 2 characters.
4344

4445
### Read-Only

internal/kibana/space.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package kibana
22

33
import (
44
"context"
5+
"regexp"
56

67
"github.com/disaster37/go-kibana-rest/v8/kbapi"
78
"github.com/elastic/terraform-provider-elasticstack/internal/clients"
@@ -54,6 +55,12 @@ func ResourceSpace() *schema.Resource {
5455
Computed: true, // If not provided, a value is autogenerated
5556
Optional: true,
5657
},
58+
"image_url": {
59+
Description: "The data-URL encoded image to display in the space avatar.",
60+
Type: schema.TypeString,
61+
Optional: true,
62+
ValidateFunc: validation.StringMatch(regexp.MustCompile("^data:image/"), "must be a valid data-URL encoded image"),
63+
},
5764
}
5865

5966
return &schema.Resource{
@@ -109,6 +116,10 @@ func resourceSpaceUpsert(ctx context.Context, d *schema.ResourceData, meta inter
109116
space.Color = color.(string)
110117
}
111118

119+
if imageUrl, ok := d.GetOk("image_url"); ok {
120+
space.ImageURL = imageUrl.(string)
121+
}
122+
112123
var spaceResponse *kbapi.KibanaSpace
113124

114125
if d.IsNewResource() {

internal/kibana/space_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func TestAccResourceSpace(t *testing.T) {
3636
resource.TestCheckTypeSetElemAttr("elasticstack_kibana_space.test_space", "disabled_features.*", "ingestManager"),
3737
resource.TestCheckTypeSetElemAttr("elasticstack_kibana_space.test_space", "disabled_features.*", "enterpriseSearch"),
3838
resource.TestCheckResourceAttr("elasticstack_kibana_space.test_space", "color", "#FFFFFF"),
39+
resource.TestCheckResourceAttrSet("elasticstack_kibana_space.test_space", "image_url"),
3940
),
4041
},
4142
{
@@ -77,6 +78,7 @@ resource "elasticstack_kibana_space" "test_space" {
7778
description = "Updated space description"
7879
disabled_features = ["ingestManager", "enterpriseSearch"]
7980
color = "#FFFFFF"
81+
image_url = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD4AAABACAYAAABC6cT1AAAGf0lEQVRoQ+3abYydRRUH8N882xYo0IqagEVjokQJKAiKBjXExC9G/aCkGowCIghCkRcrVSSKIu/FEiqgGL6gBIlAYrAqUTH6hZgQFVEMKlQFfItWoQWhZe8z5uzMLdvbfbkLxb13d+fbvfe588x/zpn/+Z9zJpmnI81T3BaAzzfLL1h8weLzZAcWXH2eGHo7zAWLL1h8nuzAjFw9G1N6Kzq8HnuM36MR8iibF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xqrdeWDYgIe7X5L4cGJPJX2940lOX8pD41FnFnc4riluvQKbK0dcHJFi2IBHNTQSlguru4d2/wPOTNzRA3x5y+U1E1uqWDkETOT026XuUJzx6u7ReLhSYenQ7uHua0fKZmwfmcPqsQjxE5WVONcRxn7X89zgn/EKPMRMxOVQXmP18Mx3q3b/Y/0cQE/IhFtHESMsHFlZ1Ml3CH3DZPHImY+pxcKumNmYirtvqMBfhMuU6s3iqOQkTsMPe1tCQwO8Ajs0lxr7W+vnp1MJc9EgCNd/cy6x+9D4veXmprj5wxMw/3C4egW6zzgZOlYZzfwo3F2J7ael0pJamvlPKgWNKFft1AAcKotXoFEbD7kaoSoQPVKB35+5KHF0lai/rJo+up87jWEE/qqqwY+qrL21LWLm95lPJ16ppKw31XC3PXYPJauPEx7B6BHCgrSizRs18qiaRp8tlN3ueCTYPHH9RNaunjI8Z7wLYpT3jZSCYXQ8e9vTsRE/q+no3XMKeObgGtaintbb/AvXj4JDkNw/5hrwYPfIvlZFUbLn7G5q+eQIN09Vnho6cqvnM/Lt99RixH49wO8K0ZL41WTWHoQzvsNVkOheZqKhEGpsp3SzB+BBtZAYve7uOR9tuTaaB6l0XScdYfEQPpkTUyHEGP+XqyDBzu+NBCITUjNWHynkrbWKOuWFn1xKzqsyx0bdvS78odp0+N503Zao0uCsWuSIDku8/7EO60b41vN5+Ses9BKlTdvd8bhp9EBvJjWJAIn/vxwHe6b3tSk6JFPV4nq85oAOrx555v/x/rh3E6Lo+bnuNS4uB4Cuq0ZfvO8X1rM6q/+vnjLVqZq7v83onttc2oYF4HPJmv1gWbB4P7s0l55ZsPhcsmY/WBYs3s8uzaVn5q3F/wf70mRuBCtbjQAAAABJRU5ErkJggg=="
8082
}
8183
`, id, fmt.Sprintf("Updated %s", id))
8284
}

libs/go-kibana-rest/kbapi/api.kibana_spaces.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type KibanaSpace struct {
2222
Reserved bool `json:"_reserved,omitempty"`
2323
Initials string `json:"initials,omitempty"`
2424
Color string `json:"color,omitempty"`
25+
ImageURL string `json:"imageUrl,omitempty"`
2526
}
2627

2728
// KibanaSpaces is the list of KibanaSpace object

0 commit comments

Comments
 (0)