From 7fb583bd4e16d28e39d3160304f7d12ae42bdfde Mon Sep 17 00:00:00 2001 From: Kalle Carlbark Date: Fri, 26 Nov 2021 11:15:19 +0100 Subject: [PATCH] use correct path --- .pre-commit-config.yaml | 18 ++++++++++++++++++ devices.go | 12 ++++++------ netbox.go | 3 ++- secrets.go | 2 +- 4 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..af12555 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,18 @@ +repos: +- repo: https://git.candidator.se/go/dev-tools/pre-commit-golang.git + rev: f898003d6bfc677c18ee10210eb663fa5394cfb5 + hooks: + - id: go-fmt + - id: go-vet + - id: go-staticcheck + - id: go-imports + - id: go-cyclo + args: [-over=100] + - id: revive + - id: gosec + - id: validate-toml + - id: no-go-testing + # - id: golangci-lint + - id: go-critic + - id: go-unit-tests + - id: go-build diff --git a/devices.go b/devices.go index 84f982e..6b7ed0e 100644 --- a/devices.go +++ b/devices.go @@ -171,11 +171,11 @@ type Device struct { } type NewDevice struct { - Name string `json:"name,omitempty,omitempty"` - DeviceType int `json:"device_type,omitempty,omitempty"` - DeviceRole int `json:"device_role,omitempty,omitempty"` - Tenant int `json:"tenant,omitempty,omitempty"` - Platform int `json:"platform,omitempty,omitempty"` + Name string `json:"name,omitempty"` + DeviceType int `json:"device_type,omitempty"` + DeviceRole int `json:"device_role,omitempty"` + Tenant int `json:"tenant,omitempty"` + Platform int `json:"platform,omitempty"` Serial string `json:"serial,omitempty"` AssetTag string `json:"asset_tag,omitempty"` Site int `json:"site,omitempty"` @@ -257,7 +257,7 @@ type UpdateDevice struct { DcimDeviceBelongsToService int `json:"dcim_device_belongs_to_service,omitempty"` DcimDeviceCendotid string `json:"dcim_device_cendotid,omitempty"` DcimDeviceExposedToInternet int `json:"dcim_device_exposed_to_internet,omitempty"` - DcimDeviceImportOsVersion bool `json:"dcim_device_import_os_version,omitempty,omitempty"` + DcimDeviceImportOsVersion bool `json:"dcim_device_import_os_version,omitempty"` DcimDevicePod int `json:"dcim_device_pod,omitempty"` } `json:"custom_fields,omitempty"` } diff --git a/netbox.go b/netbox.go index a2b1da3..a880170 100644 --- a/netbox.go +++ b/netbox.go @@ -149,7 +149,7 @@ func NewClient(apiurl string, httpClient *http.Client) (*Client, error) { c.DeviceRoles = (*DeviceRolesService)(&c.common) c.DeviceTypes = (*DeviceTypesService)(&c.common) c.Interfaces = (*InterfacesService)(&c.common) - c.InventoryItems = (*InventoryItemsServices)(&c.common) + c.InventoryItems = (*InventoryItemsService)(&c.common) c.Prefixes = (*PrefixesService)(&c.common) c.RearPorts = (*RearPortsService)(&c.common) c.Tenants = (*TenantsService)(&c.common) @@ -185,6 +185,7 @@ func (n *Client) FetchSessionKey(privatekey string) error { query := form.Encode() transport := &http.Transport{ + // #nosec XXX: FIXIT TLSClientConfig: &tls.Config{InsecureSkipVerify: n.InsecureSkipVerify}, } timeout := time.Duration(60 * time.Second) diff --git a/secrets.go b/secrets.go index 583fbe3..08534c0 100644 --- a/secrets.go +++ b/secrets.go @@ -87,7 +87,7 @@ func (s *SecretsService) List(ctx context.Context, f *SecretFilter) (*Secrets, e } query = form.Encode() - req, err = s.client.newRequest(ctx, "GET", devicesPath, query, nil) + req, err = s.client.newRequest(ctx, "GET", secretsPath, query, nil) if err != nil { return &secrets, err }