Skip to content

Commit

Permalink
Merge branch 'splunk:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Xboarder56 authored Apr 16, 2024
2 parents 0975915 + 8fac47b commit 55c1aab
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:

Expand Down
20 changes: 18 additions & 2 deletions client/saved_searches.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package client

import (
"github.com/google/go-querystring/query"
"github.com/splunk/terraform-provider-splunk/client/models"
"log"
"net/http"

"github.com/google/go-querystring/query"
"net/http/httputil"
)

func (client *Client) CreateSavedSearches(name, owner, app string, savedSearchObject *models.SavedSearchObject) error {
Expand All @@ -19,6 +20,14 @@ func (client *Client) CreateSavedSearches(name, owner, app string, savedSearchOb
if err != nil {
return err
}

respBody, error := httputil.DumpResponse(resp, true)
if error != nil {
log.Printf("[ERROR] Error occured during CreateSavedSearches %s", error)
}

log.Printf("[DEBUG] Response object returned from CreateSavedSearches is: %s", string(respBody))

defer resp.Body.Close()
return nil
}
Expand Down Expand Up @@ -54,5 +63,12 @@ func (client *Client) DeleteSavedSearches(name, owner, app string) (*http.Respon
return nil, err
}

respBody, error := httputil.DumpResponse(resp, true)
if error != nil {
log.Printf("[ERROR] Error occured during DeleteSavedSearches %s", error)
}

log.Printf("[DEBUG] Response object returned from DeleteSavedSearches is: %s", string(respBody))

return resp, nil
}
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 55c1aab

Please sign in to comment.