Skip to content

Commit

Permalink
Merge pull request #14 from BESTSELLER/bring-it-up-to-date
Browse files Browse the repository at this point in the history
Bring it up to date
  • Loading branch information
Gaardsholt authored Feb 9, 2023
2 parents 38ff9e5 + 29a23e0 commit 22f2b13
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 39 deletions.
11 changes: 4 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ commands:
- run:
name: Install GoReleaser
command: |
curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh
sudo mv ./bin/goreleaser /usr/bin/goreleaser
rm -rf ./bin
go install github.com/goreleaser/goreleaser@latest
- run:
name: Import private key
command: |
Expand All @@ -27,9 +25,9 @@ commands:
source /tmp/secrets.env
if [ "<< parameters.release-type >>" = "test" ] ; then
goreleaser release --snapshot --rm-dist
goreleaser release --snapshot --clean
else
goreleaser release --rm-dist
goreleaser release --clean
fi
jobs:
Expand All @@ -40,7 +38,7 @@ jobs:
enum: ["test", "release"]
default: "test"
docker:
- image: cimg/go:1.15
- image: cimg/go:1.19
steps:
- checkout
- attach_workspace:
Expand Down Expand Up @@ -68,7 +66,6 @@ release_filter: &release_filter
only: *tag_filter

workflows:
version: 2
tester:
jobs:
- secret-injector/dump-secrets:
Expand Down
2 changes: 2 additions & 0 deletions .github/dependabot-circleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
reviewers:
- BESTSELLER/engineering-services
4 changes: 2 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
before:
hooks:
# this is just an example and not a requirement for provider building/publishing
- go mod download
- go mod tidy
builds:
- env:
# goreleaser does not work with CGO, it could also complicate
Expand All @@ -16,7 +16,7 @@ builds:
ldflags:
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
goos:
- freebsd
# - freebsd
- windows
- linux
- darwin
Expand Down
34 changes: 21 additions & 13 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"regexp"
"strconv"

Expand Down Expand Up @@ -46,7 +47,7 @@ func (client *Client) GetPrefix(newCidr string) (*models.ReponsePrefix, error) {
}
prefixPath := models.PathAvailablePrefixes + "?prefix=" + newCidr

resp, err := client.sendRequest("GET", prefixPath, nil, 200)
resp, err := client.SendRequest("GET", prefixPath, nil, 200)
if err != nil {
return nil, err
}
Expand All @@ -64,7 +65,7 @@ func (client *Client) GetPrefix(newCidr string) (*models.ReponsePrefix, error) {
func (client *Client) GetSite(siteName string) (*models.ResponseSites, error) {
sitesPath := "/dcim/sites/?name=" + siteName

resp, err := client.sendRequest("GET", sitesPath, nil, 200)
resp, err := client.SendRequest("GET", sitesPath, nil, 200)
if err != nil {
return nil, err
}
Expand All @@ -80,17 +81,17 @@ func (client *Client) GetSite(siteName string) (*models.ResponseSites, error) {

// DeletePrefix will delete a given prefix
func (client *Client) DeletePrefix(d *schema.ResourceData) error {
_, err := client.sendRequest("DELETE", d.Id(), nil, 204)
_, err := client.SendRequest("DELETE", d.Id(), nil, 204)
if err != nil {
return err
}
return nil
}

//UpdatePrefix will patch a prefix
// UpdatePrefix will patch a prefix
func (client *Client) UpdatePrefix(d *schema.ResourceData) error {
body := AvailablePrefixBody(d)
_, err := client.sendRequest("PATCH", d.Id(), body, 200)
_, err := client.SendRequest("PATCH", d.Id(), body, 200)
if err != nil {
return err
}
Expand All @@ -101,7 +102,7 @@ func (client *Client) UpdatePrefix(d *schema.ResourceData) error {
func (client *Client) CreatePrefix(body *models.AvailablePrefixes, parentID int) (*models.ReponseAvailablePrefixes, error) {
path := fmt.Sprintf("%s%d/available-prefixes/", models.PathAvailablePrefixes, parentID)

resp, err := client.sendRequest("POST", path, body, 201)
resp, err := client.SendRequest("POST", path, body, 201)
if err != nil {
return nil, err
}
Expand All @@ -115,7 +116,7 @@ func (client *Client) CreatePrefix(body *models.AvailablePrefixes, parentID int)

// GetAvailablePrefix will return all available prefixes
func (client *Client) GetAvailablePrefix(id string) (*models.GetAvailablePrefixResponse, error) {
resp, err := client.sendRequest("GET", id, nil, 200)
resp, err := client.SendRequest("GET", id, nil, 200)
if err != nil {
return nil, err
}
Expand All @@ -128,7 +129,7 @@ func (client *Client) GetAvailablePrefix(id string) (*models.GetAvailablePrefixR
re := regexp.MustCompile(`(?m)(?:[0-9]{1,3}\.){3}[0-9]{1,3}/`)
prefixLength, _ := strconv.Atoi(re.ReplaceAllString(jsonData.Prefix, ""))

resp2, err := client.sendRequest("GET", models.PathAvailablePrefixes+"?q="+jsonData.Prefix, nil, 200)
resp2, err := client.SendRequest("GET", models.PathAvailablePrefixes+"?q="+jsonData.Prefix, nil, 200)
if err != nil {
return nil, err
}
Expand All @@ -139,18 +140,25 @@ func (client *Client) GetAvailablePrefix(id string) (*models.GetAvailablePrefixR
}

returnValue := &models.GetAvailablePrefixResponse{
PrefixLength: prefixLength,
Description: jsonData.Description,
ID: models.PathAvailablePrefixes + strconv.Itoa(jsonData.ID) + "/",
PrefixLength: prefixLength,
Description: jsonData.Description,
// ID: models.PathAvailablePrefixes + strconv.Itoa(jsonData.ID) + "/",
ID: fmt.Sprintf("%s%d/", models.PathAvailablePrefixes, jsonData.ID),
ParentPrefixID: jsonData2.Results[0].ID,
Prefix: jsonData.Prefix,
PrefixID: jsonData.ID,
}
return returnValue, nil
}

func (client *Client) sendRequest(method string, path string, payload interface{}, statusCode int) (value string, err error) {
url := client.endpoint + path
func (client *Client) SendRequest(method string, path string, payload interface{}, statusCode int) (value string, err error) {
baseUrl, err := url.Parse(client.endpoint)
if err != nil {
return "", err
}

url := fmt.Sprintf("%s/%s", baseUrl.String(), path)

httpClient := &http.Client{}

b := new(bytes.Buffer)
Expand Down
82 changes: 81 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,85 @@
module github.com/BESTSELLER/terraform-provider-netbox

go 1.15
go 1.19

require github.com/hashicorp/terraform-plugin-sdk v1.17.2

require (
cloud.google.com/go v0.65.0 // indirect
cloud.google.com/go/storage v1.10.0 // indirect
github.com/Masterminds/goutils v1.1.0 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-cidr v1.1.0 // indirect
github.com/apparentlymart/go-textseg/v12 v12.0.0 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/aws/aws-sdk-go v1.37.0 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.7.0 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/protobuf v1.4.2 // indirect
github.com/google/go-cmp v0.5.5 // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-getter v1.5.3 // indirect
github.com/hashicorp/go-hclog v0.9.2 // indirect
github.com/hashicorp/go-multierror v1.0.0 // indirect
github.com/hashicorp/go-plugin v1.3.0 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-uuid v1.0.1 // indirect
github.com/hashicorp/go-version v1.3.0 // indirect
github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f // indirect
github.com/hashicorp/hcl/v2 v2.8.2 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-config-inspect v0.0.0-20191212124732-c6ae6269b9d7 // indirect
github.com/hashicorp/terraform-exec v0.13.3 // indirect
github.com/hashicorp/terraform-json v0.10.0 // indirect
github.com/hashicorp/terraform-plugin-test/v2 v2.2.1 // indirect
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jstemmer/go-junit-report v0.9.1 // indirect
github.com/klauspost/compress v1.11.2 // indirect
github.com/mattn/go-colorable v0.1.1 // indirect
github.com/mattn/go-isatty v0.0.5 // indirect
github.com/mitchellh/cli v1.1.2 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.0.4 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/mitchellh/reflectwalk v1.0.1 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/posener/complete v1.2.1 // indirect
github.com/spf13/afero v1.2.2 // indirect
github.com/ulikunitz/xz v0.5.8 // indirect
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
github.com/vmihailenco/tagparser v0.1.1 // indirect
github.com/zclconf/go-cty v1.8.2 // indirect
github.com/zclconf/go-cty-yaml v1.0.2 // indirect
go.opencensus.io v0.22.4 // indirect
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/mod v0.3.0 // indirect
golang.org/x/net v0.0.0-20210326060303-6b1517762897 // indirect
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 // indirect
golang.org/x/sys v0.0.0-20210324051608-47abb6519492 // indirect
golang.org/x/text v0.3.5 // indirect
golang.org/x/tools v0.0.0-20201028111035-eafbe7b904eb // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/api v0.34.0 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d // indirect
google.golang.org/grpc v1.32.0 // indirect
google.golang.org/protobuf v1.25.0 // indirect
)
10 changes: 0 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,14 @@ github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412/go.mod h1:WPjqKcmVOxf0XSf3YxCJs6N6AOSrOx3obionmG7T0y0=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
github.com/andybalholm/crlf v0.0.0-20171020200849-670099aa064f/go.mod h1:k8feO4+kXDxro6ErPXBRTJ/ro2mf0SsFG8s7doP9kJE=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/apparentlymart/go-cidr v1.1.0 h1:2mAhrMoF+nhXqxTzSZMUzDHkLjmIHC+Zzn4tdgBZjnU=
github.com/apparentlymart/go-cidr v1.1.0/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc=
github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM=
github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I=
github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM=
github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0=
github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
github.com/apparentlymart/go-textseg/v12 v12.0.0 h1:bNEQyAGak9tojivJNkoqWErVCQbjdL7GzRt3F8NvfJ0=
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
Expand All @@ -67,7 +64,6 @@ github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkE
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM=
github.com/aws/aws-sdk-go v1.37.0 h1:GzFnhOIsrGyQ69s7VgqtrG2BG8v7X7vwB3Xpbd/DBBk=
Expand Down Expand Up @@ -95,16 +91,13 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E=
github.com/go-git/go-billy/v5 v5.0.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
github.com/go-git/go-billy/v5 v5.1.0 h1:4pl5BV4o7ZG/lterP4S6WzJ6xr49Ba5ET9ygheTYahk=
github.com/go-git/go-billy/v5 v5.1.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
github.com/go-git/go-git-fixtures/v4 v4.0.2-0.20200613231340-f56387b50c12 h1:PbKy9zOy4aAKrJ5pibIRpVO2BXnK1Tlcg+caKI7Ox5M=
github.com/go-git/go-git-fixtures/v4 v4.0.2-0.20200613231340-f56387b50c12/go.mod h1:m+ICp2rF3jDhFgEZ/8yziagdT1C+ZpZcrJjappBCDSw=
github.com/go-git/go-git/v5 v5.3.0 h1:8WKMtJR2j8RntEXR/uvTKagfEt4GYlwQ7mntE4+0GWc=
github.com/go-git/go-git/v5 v5.3.0/go.mod h1:xdX4bWJ48aOrdhnl2XqHYstHbbp6+LFS4r4X+lNVprw=
Expand Down Expand Up @@ -291,7 +284,6 @@ github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down Expand Up @@ -319,7 +311,6 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/ulikunitz/xz v0.5.8 h1:ERv8V6GKqVi23rgu5cj9pVfVzJbOqAY2Ntl88O6c2nQ=
github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/vmihailenco/msgpack v3.3.3+incompatible h1:wapg9xDUZDzGCNFlwc5SqI1rvcciqcxEHac4CYj89xI=
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U=
github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
Expand Down Expand Up @@ -473,7 +464,6 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210324051608-47abb6519492 h1:Paq34FxTluEPvVyayQqMPgHm+vTOrIifmcYxFBx9TLg=
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
4 changes: 2 additions & 2 deletions provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func testAccPreCheck(t *testing.T) {
t.Fatal("NETBOX_ENDPOINT must be set for acceptance tests")
}
if v := os.Getenv("NETBOX_API_TOKEN"); v == "" {
t.Fatal("NETNOX_API_TOKEN must be set for acceptance tests")
t.Fatal("NETBOX_API_TOKEN must be set for acceptance tests")
}

}
Expand All @@ -51,7 +51,7 @@ func testAccCheckResourceExists(resource string) resource.TestCheckFunc {
name := rs.Primary.ID

apiClient := testAccProvider.Meta().(*client.Client)
_, _, err := apiClient.SendRequest("GET", name, nil, 200)
_, err := apiClient.SendRequest("GET", name, nil, 200)
if err != nil {
return fmt.Errorf("error fetching item with resource %s. %s", resource, err)
}
Expand Down
34 changes: 30 additions & 4 deletions provider/resource_availableprefixes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestAccRegistryBasic(t *testing.T) {

testAccCheckResourceExists("netbox_available_prefix.main"),
resource.TestCheckResourceAttr(
"netbox_available_prefix.main", "description", "bw-testing-terraform"),
"netbox_available_prefix.main", "description", "acc-testing-terraform"),
),
},
},
Expand All @@ -36,7 +36,7 @@ func testAccCheckRegistryDestroy(s *terraform.State) error {
continue
}

resp, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 404)
resp, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 404)
if err != nil {
return fmt.Errorf("Resouse was not delete \n %s", resp)
}
Expand All @@ -50,10 +50,36 @@ func testAccCheckAvailablePrefix() string {

return fmt.Sprintf(`
data "netbox_prefix" "prefix" {
cidr_notation = "172.24.0.0/13"
}
resource "netbox_available_prefix" "main" {
parent_prefix_id = "758"
prefix_length = 26
parent_prefix_id = data.netbox_prefix.prefix.prefix_id
prefix_length = 19
description = "acc-testing-terraform"
status = "active"
site = data.netbox_prefix.prefix.site_id
tenant = data.netbox_prefix.prefix.tenant_id
role = data.netbox_prefix.prefix.role_id
}
resource "netbox_available_prefix" "main2" {
parent_prefix_id = data.netbox_prefix.prefix.prefix_id
prefix_length = 20
description = "acc-testing-terraform"
status = "active"
site = data.netbox_prefix.prefix.site_id
tenant = data.netbox_prefix.prefix.tenant_id
role = data.netbox_prefix.prefix.role_id
}
resource "netbox_available_prefix" "main3" {
parent_prefix_id = data.netbox_prefix.prefix.prefix_id
prefix_length = 28
description = "acc-testing-terraform"
status = "active"
site = data.netbox_prefix.prefix.site_id
tenant = data.netbox_prefix.prefix.tenant_id
role = data.netbox_prefix.prefix.role_id
}
`)
Expand Down

0 comments on commit 22f2b13

Please sign in to comment.