Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions client/models/inputs_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ type InputsScriptResponse struct {
}

type InputsScriptEntry struct {
Name string `json:"name"`
ACL ACLObject `json:"acl"`
Content InputsScriptObject `json:"content"`
Name string `json:"name"`
ACL ACLObject `json:"acl"`
Content InputsScriptObjectResponse `json:"content"`
}

type InputsScriptObject struct {
Expand All @@ -22,3 +22,14 @@ type InputsScriptObject struct {
Disabled bool `json:"disabled,omitempty" url:"disabled"`
Interval int `json:"interval,omitempty" url:"interval,omitempty"`
}

type InputsScriptObjectResponse struct {
Host string `json:"host,omitempty"`
Index string `json:"index,omitempty"`
Source string `json:"source,omitempty"`
SourceType string `json:"sourcetype,omitempty"`
RenameSource string `json:"rename-source,omitempty"`
PassAuth string `json:"passAuth,omitempty"`
Disabled bool `json:"disabled,omitempty"`
Interval interface{} `json:"interval,omitempty"` // Can be int or string
}
13 changes: 10 additions & 3 deletions splunk/resource_splunk_inputs_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/splunk/terraform-provider-splunk/client/models"
"net/http"
"net/url"
"regexp"

"github.com/splunk/terraform-provider-splunk/client/models"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
)
Expand Down Expand Up @@ -68,7 +69,7 @@ func inputsScript() *schema.Resource {
Type: schema.TypeInt,
Required: true,
ValidateFunc: validation.IntAtLeast(60),
Description: "Specify an integer or cron schedule. This parameter specifies how often to execute the specified script, in seconds or a valid cron schedule. If you specify a cron schedule, the script is not executed on start-up.",
Description: "Specify an integer. This parameter specifies how often to execute the specified script, in seconds. Cron schedule is not supported",
},
"acl": aclSchema(),
},
Expand Down Expand Up @@ -138,6 +139,7 @@ func inputsScriptRead(d *schema.ResourceData, meta interface{}) error {
defer resp.Body.Close()

entry, err = getScriptedInputsConfigByName(name, resp)

if err != nil {
return err
}
Expand Down Expand Up @@ -170,7 +172,12 @@ func inputsScriptRead(d *schema.ResourceData, meta interface{}) error {
return err
}

if err = d.Set("interval", entry.Content.Interval); err != nil {
interval, ok := entry.Content.Interval.(float64)
if !ok {
fmt.Print(ok)
return err
}
if err = d.Set("interval", int(interval)); err != nil {
return err
}

Expand Down
5 changes: 3 additions & 2 deletions splunk/resource_splunk_inputs_script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package splunk

import (
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"net/http"
"os"
"path/filepath"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

const inputsScriptConfig = `
Expand Down
Loading