Skip to content

Commit

Permalink
use nobody to read and update if not private
Browse files Browse the repository at this point in the history
  • Loading branch information
markafarrell committed Apr 20, 2023
1 parent f60ef19 commit e40b8c0
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions splunk/resource_splunk_data_ui_views.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit e40b8c0

Please sign in to comment.