Skip to content

Commit

Permalink
chore(go): Fix small inconsistencies
Browse files Browse the repository at this point in the history
  • Loading branch information
hollow authored and fbreckle committed Jan 2, 2023
1 parent 26eb126 commit be89031
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 33 deletions.
4 changes: 2 additions & 2 deletions netbox/data_source_netbox_asn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ data "netbox_asn" "test" {
}`

func testAccNetboxAsnByAsn() string {
return fmt.Sprintf(`
return `
data "netbox_asn" "test" {
asn = "123"
}`)
}`
}

func testAccNetboxAsnByTag(testName string) string {
Expand Down
12 changes: 6 additions & 6 deletions netbox/data_source_netbox_asns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,27 @@ resource "netbox_asn" "test_2" {
}

func testAccNetboxAsnsByAsn() string {
return fmt.Sprintf(`
return `
data "netbox_asns" "test" {
filter {
name = "asn"
value = "123"
}
}`)
}`
}

func testAccNetboxAsnsByAsnN() string {
return fmt.Sprintf(`
return `
data "netbox_asns" "test" {
filter {
name = "asn__n"
value = "123"
}
}`)
}`
}

func testAccNetboxAsnsByRange(testName string) string {
return fmt.Sprintf(`
return `
data "netbox_asns" "test" {
filter {
name = "asn__gte"
Expand All @@ -62,7 +62,7 @@ data "netbox_asns" "test" {
name = "asn__lte"
value = "2000"
}
}`)
}`
}

func TestAccNetboxAsnsDataSource_basic(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions netbox/resource_netbox_available_ip_address.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package netbox

import (
"strconv"

"github.com/fbreckle/go-netbox/netbox/client"
"github.com/fbreckle/go-netbox/netbox/client/ipam"
"github.com/fbreckle/go-netbox/netbox/models"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"strconv"
)

func resourceNetboxAvailableIPAddress() *schema.Resource {
Expand All @@ -21,7 +22,7 @@ func resourceNetboxAvailableIPAddress() *schema.Resource {
> An IP address comprises a single host address (either IPv4 or IPv6) and its subnet mask. Its mask should match exactly how the IP address is configured on an interface in the real world.
> Like a prefix, an IP address can optionally be assigned to a VRF (otherwise, it will appear in the "global" table). IP addresses are automatically arranged under parent prefixes within their respective VRFs according to the IP hierarchya.
>
> Each IP address can also be assigned an operational status and a functional role. Statuses are hard-coded in NetBox and include the following:
> Each IP address can also be assigned an operational status and a functional role. Statuses are hard-coded in NetBox and include the following:
> * Active
> * Reserved
> * Deprecated
Expand Down
2 changes: 1 addition & 1 deletion netbox/resource_netbox_circuit.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func resourceNetboxCircuit() *schema.Resource {
Description: `:meta:subcategory:Circuits:From the [official documentation](https://docs.netbox.dev/en/stable/features/circuits/#circuits_1):
> A communications circuit represents a single physical link connecting exactly two endpoints, commonly referred to as its A and Z terminations. A circuit in NetBox may have zero, one, or two terminations defined. It is common to have only one termination defined when you don't necessarily care about the details of the provider side of the circuit, e.g. for Internet access circuits. Both terminations would likely be modeled for circuits which connect one customer site to another.
>
>
> Each circuit is associated with a provider and a user-defined type. For example, you might have Internet access circuits delivered to each site by one provider, and private MPLS circuits delivered by another. Each circuit must be assigned a circuit ID, each of which must be unique per provider.`,

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion netbox/resource_netbox_circuit_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ resource "netbox_circuit_provider" "test" {
),
},
{
Config: fmt.Sprintf(`
Config: fmt.Sprintf(`
resource "netbox_circuit_provider" "test" {
name = "%[1]s"
slug = "%[2]s"
Expand Down
4 changes: 2 additions & 2 deletions netbox/resource_netbox_circuit_termination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ resource "netbox_site" "test" {
name = "%[1]s"
slug = "%[2]s"
status = "active"
}
}
resource "netbox_circuit_provider" "test" {
name = "%[1]s"
slug = "%[2]s"
}
resource "netbox_circuit_type" "test" {
name = "%[1]s"
slug = "%[2]s"
}
}
resource "netbox_circuit" "test" {
cid = "%[1]s"
status = "active"
Expand Down
2 changes: 1 addition & 1 deletion netbox/resource_netbox_circuit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ resource "netbox_circuit_provider" "test" {
resource "netbox_circuit_type" "test" {
name = "%[1]s"
slug = "%[2]s"
}
}
`, testName, testSlug)
}
func TestAccNetboxCircuit_basic(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion netbox/resource_netbox_circuit_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestAccNetboxCircuitType_basic(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) },
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`
Config: fmt.Sprintf(`
resource "netbox_circuit_type" "test" {
name = "%[1]s"
slug = "%[2]s"
Expand Down
2 changes: 1 addition & 1 deletion netbox/resource_netbox_site_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func resourceNetboxSiteGroup() *schema.Resource {
Description: `:meta:subcategory:Data Center Inventory Management (DCIM):From the [official documentation](https://docs.netbox.dev/en/stable/features/facilities/#site-groups):
> Like regions, site groups can be arranged in a recursive hierarchy for grouping sites. However, whereas regions are intended for geographic organization, site groups may be used for functional grouping. For example, you might classify sites as corporate, branch, or customer sites in addition to where they are physically located.
>
>
> The use of both regions and site groups affords to independent but complementary dimensions across which sites can be organized.`,

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion netbox/resource_netbox_tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func resourceNetboxTenant() *schema.Resource {

Description: `:meta:subcategory:Tenancy:From the [official documentation](https://docs.netbox.dev/en/stable/features/tenancy/#tenants):
> A tenant represents a discrete grouping of resources used for administrative purposes. Typically, tenants are used to represent individual customers or internal departments within an organization.
> A tenant represents a discrete grouping of resources used for administrative purposes. Typically, tenants are used to represent individual customers or internal departments within an organization.
>
> Tenant assignment is used to signify the ownership of an object in NetBox. As such, each object may only be owned by a single tenant. For example, if you have a firewall dedicated to a particular customer, you would assign it to the tenant which represents that customer. However, if the firewall serves multiple customers, it doesn't belong to any particular customer, so tenant assignment would not be appropriate.`,

Expand Down
15 changes: 0 additions & 15 deletions netbox/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,15 @@ package netbox

import (
"fmt"
"strconv"
"strings"

sp "github.com/davecgh/go-spew/spew"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func spew(obj interface{}) string {
return sp.Sdump(obj)
}

func getInt64FromString(s string) int64 {
res, _ := strconv.ParseInt(s, 10, 64)
return res
}

func strToPtr(str string) *string {
return &str
}

func intToPtr(i int) *int {
return &i
}

func int64ToPtr(i int64) *int64 {
return &i
}
Expand Down

0 comments on commit be89031

Please sign in to comment.