Add InsecureSkipVerify functionality.
This commit is contained in:
parent
79ae6869a7
commit
62df6ed37f
2 changed files with 11 additions and 4 deletions
|
@ -1,13 +1,15 @@
|
|||
package nbclient
|
||||
|
||||
type NetBox struct {
|
||||
RootURL string
|
||||
Token string
|
||||
RootURL string
|
||||
Token string
|
||||
InsecureSkipVerify bool
|
||||
}
|
||||
|
||||
func (n *NetBox) New(root, token string) error {
|
||||
func (n *NetBox) New(root, token string, TlsSkipVerify bool) error {
|
||||
n.RootURL = root
|
||||
n.Token = token
|
||||
n.InsecureSkipVerify = TlsSkipVerify
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package nbclient
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -85,9 +86,13 @@ func (i *Dcim_Interfaces_Create) CreateInterface(n *NetBox) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
transport := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: n.InsecureSkipVerify},
|
||||
}
|
||||
timeout := time.Duration(60 * time.Second)
|
||||
client := &http.Client{
|
||||
Timeout: timeout,
|
||||
Timeout: timeout,
|
||||
Transport: transport,
|
||||
}
|
||||
request, err := http.NewRequest("POST", n.RootURL+"/dcim/interfaces/", bytes.NewBuffer(interfaceData))
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue