From e40b8c0d5fdc5a197ddfff90b2f45f9fd7ff0253 Mon Sep 17 00:00:00 2001 From: Mark Farrell Date: Thu, 20 Apr 2023 10:42:20 +1000 Subject: [PATCH] use nobody to read and update if not private --- splunk/resource_splunk_data_ui_views.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/splunk/resource_splunk_data_ui_views.go b/splunk/resource_splunk_data_ui_views.go index bf747759..d81728b5 100644 --- a/splunk/resource_splunk_data_ui_views.go +++ b/splunk/resource_splunk_data_ui_views.go @@ -64,7 +64,14 @@ func splunkDashboardsRead(d *schema.ResourceData, meta interface{}) error { aclObject := getResourceDataViewACL(d) - resp, err := (*provider.Client).ReadDashboardObject(name, aclObject.Owner, aclObject.App) + readUser := "nobody" + + if aclObject.Sharing == "user" { + // If we have a private dashboard we can only query it using the owner + readUser = aclObject.Owner + } + + resp, err := (*provider.Client).ReadDashboardObject(name, readUser, aclObject.App) if err != nil { return err } @@ -101,11 +108,18 @@ func splunkDashboardsUpdate(d *schema.ResourceData, meta interface{}) error { splunkDashboardsObj := getSplunkDashboardsConfig(d) aclObject := getResourceDataViewACL(d) - if err := (*provider.Client).UpdateDashboardObject(aclObject.Owner, aclObject.App, name, splunkDashboardsObj); err != nil { + updateUser := "nobody" + + if aclObject.Sharing == "user" { + // If we have a private dashboard we can only update it using the owner + updateUser = aclObject.Owner + } + + if err := (*provider.Client).UpdateDashboardObject(updateUser, aclObject.App, name, splunkDashboardsObj); err != nil { return err } - if err := (*provider.Client).UpdateAcl(aclObject.Owner, aclObject.App, name, aclObject, "data", "ui", "views"); err != nil { + if err := (*provider.Client).UpdateAcl(updateUser, aclObject.App, name, aclObject, "data", "ui", "views"); err != nil { return err }