Skip to content

Commit

Permalink
more fixes to adjust to current nodeping API behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticroentgen committed Jan 25, 2024
1 parent 9808fcd commit c8ed642
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
3 changes: 2 additions & 1 deletion nodeping/data_source_checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func dataSourceCheck() *schema.Resource {
"dohdot": &schema.Schema{Type: schema.TypeString, Optional: true, Computed: true},
"dnstype": &schema.Schema{Type: schema.TypeString, Optional: true, Computed: true},
"dnstoresolve": &schema.Schema{Type: schema.TypeString, Optional: true, Computed: true},
"dnssection": &schema.Schema{Type: schema.TypeString, Optional: true, Computed: true},
"dnsrd": &schema.Schema{Type: schema.TypeBool, Optional: true, Computed: true},
"transport": &schema.Schema{Type: schema.TypeString, Optional: true, Computed: true},
"follow": &schema.Schema{Type: schema.TypeBool, Optional: true, Computed: true},
Expand All @@ -60,7 +61,7 @@ func dataSourceCheck() *schema.Resource {
"username": &schema.Schema{Type: schema.TypeString, Optional: true, Computed: true},
"password": &schema.Schema{Type: schema.TypeString, Optional: true, Computed: true},
"secure": &schema.Schema{Type: schema.TypeString, Optional: true, Computed: true},
"verify": &schema.Schema{Type: schema.TypeString, Optional: true, Computed: true},
"verify": &schema.Schema{Type: schema.TypeBool, Optional: true, Computed: true},
"ignore": &schema.Schema{Type: schema.TypeString, Optional: true, Computed: true},
"invert": &schema.Schema{Type: schema.TypeBool, Optional: true, Computed: true},
"warningdays": &schema.Schema{Type: schema.TypeInt, Optional: true, Computed: true},
Expand Down
17 changes: 9 additions & 8 deletions nodeping/resource_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func resourceCheck() *schema.Resource {
"SPEC10RDDS", "SSH", "SSL", "WEBSOCKET", "WHOIS",
}
httpAdvMethods := []string{"GET", "POST", "PUT", "HEAD", "TRACE", "CONNECT"}
trueFalseStrings := []string{"false", "true"}
//trueFalseStrings := []string{"false", "true"}

return &schema.Resource{
CreateContext: resourceCheckCreate,
Expand Down Expand Up @@ -65,6 +65,7 @@ func resourceCheck() *schema.Resource {
"ANY", "A", "AAAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", "TXT",
}, false)},
"dnstoresolve": &schema.Schema{Type: schema.TypeString, Optional: true},
"dnssection": &schema.Schema{Type: schema.TypeString, Optional: true},
"dnsrd": &schema.Schema{Type: schema.TypeBool, Optional: true},
"transport": &schema.Schema{Type: schema.TypeString, Optional: true,
ValidateFunc: validation.StringInSlice([]string{"udp", "tcp"}, false)},
Expand All @@ -75,8 +76,7 @@ func resourceCheck() *schema.Resource {
"password": &schema.Schema{Type: schema.TypeString, Optional: true},
"secure": &schema.Schema{Type: schema.TypeString, Optional: true,
ValidateFunc: validation.StringInSlice([]string{"false", "ssl"}, false)},
"verify": &schema.Schema{Type: schema.TypeString, Optional: true,
ValidateFunc: validation.StringInSlice(trueFalseStrings, false)},
"verify": &schema.Schema{Type: schema.TypeBool, Optional: true},
"ignore": &schema.Schema{Type: schema.TypeString, Optional: true},
"invert": &schema.Schema{Type: schema.TypeBool, Optional: true, Default: false},
"warningdays": &schema.Schema{Type: schema.TypeInt, Optional: true,
Expand Down Expand Up @@ -262,11 +262,11 @@ func getCheckUpdateFromSchema(d *schema.ResourceData, ctx context.Context) *node
notificationsSchemaList := d.Get("notifications").(*schema.Set).List()
checkUpdate.Notifications = make([]map[string]nodeping_api_client.Notification, len(notificationsSchemaList))
for idx, nS := range notificationsSchemaList {
notisicationSchema := nS.(map[string]interface{})
notificationSchema := nS.(map[string]interface{})
notificationMap := make(map[string]nodeping_api_client.Notification, 1)
notificationMap[notisicationSchema["contact"].(string)] = nodeping_api_client.Notification{
notisicationSchema["delay"].(int),
notisicationSchema["schedule"].(string),
notificationMap[notificationSchema["contact"].(string)] = nodeping_api_client.Notification{
notificationSchema["delay"].(int),
notificationSchema["schedule"].(string),
}
checkUpdate.Notifications[idx] = notificationMap
}
Expand All @@ -278,6 +278,7 @@ func getCheckUpdateFromSchema(d *schema.ResourceData, ctx context.Context) *node
checkUpdate.Dohdot = d.Get("dohdot").(string)
checkUpdate.DnsType = d.Get("dnstype").(string)
checkUpdate.DnsToResolve = d.Get("dnstoresolve").(string)
checkUpdate.DnsSection = d.Get("dnssection").(string)
checkUpdate.Dnsrd = d.Get("dnsrd").(bool)
checkUpdate.Transport = d.Get("transport").(string)
checkUpdate.Follow = d.Get("follow").(bool)
Expand All @@ -286,7 +287,7 @@ func getCheckUpdateFromSchema(d *schema.ResourceData, ctx context.Context) *node
checkUpdate.Username = d.Get("username").(string)
checkUpdate.Password = d.Get("password").(string)
checkUpdate.Secure = d.Get("secure").(string)
checkUpdate.Verify = d.Get("verify").(string)
checkUpdate.Verify = d.Get("verify").(bool)
checkUpdate.Ignore = d.Get("ignore").(string)
checkUpdate.Invert = d.Get("invert").(bool)
checkUpdate.WarningDays = d.Get("warningdays").(int)
Expand Down
5 changes: 3 additions & 2 deletions nodeping_api_client/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ type CheckUpdate struct { // used for PUT and POST requests.
Description string `json:"description,omitempty"`
// the following are only relevant for certain types
CheckToken string `json:"checktoken,omitempty"`
ClientCert interface{} `json:"clientcert,omitempty"`
ClientCert interface{} `json:"clientcert,omitempty"`
ContentString string `json:"contentstring,omitempty"`
Dohdot string `json:"dohdot,omitempty"`
DnsType string `json:"dnstype,omitempty"`
DnsToResolve string `json:"dnstoresolve,omitempty"`
DnsSection string `json:"dnssection,omitempty"`
Dnsrd bool `json:"dnsrd,omitempty"`
Transport string `json:"transport,omitempty"`
Follow bool `json:"follow"`
Expand All @@ -80,7 +81,7 @@ type CheckUpdate struct { // used for PUT and POST requests.
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
Secure string `json:"secure,omitempty"`
Verify string `json:"verify,omitempty"`
Verify bool `json:"verify,omitempty"`
Ignore string `json:"ignore,omitempty"`
Invert bool `json:"invert"`
WarningDays int `json:"warningdays,omitempty"`
Expand Down

0 comments on commit c8ed642

Please sign in to comment.