diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c15c9c09..cb378039 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,6 +5,7 @@ on: branches: [ master ] pull_request: branches: [ master ] + workflow_dispatch: jobs: diff --git a/client/saved_searches.go b/client/saved_searches.go index 8f29f13b..4b468082 100644 --- a/client/saved_searches.go +++ b/client/saved_searches.go @@ -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 { @@ -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 } @@ -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 } 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 }