Skip to content

Commit

Permalink
ci: add CI/release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
scottlaird committed Dec 25, 2023
1 parent 2f320ee commit 893c5a7
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 32 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Release
on:
push:
branches:
- main
pull_request:
branches:
- '**'
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: Jerome1337/gofmt-action@v1.0.5
with:
gofmt-flags: '-l -d'
- uses: actions/setup-go@v3
with:
go-version: 1.21
- uses: golangci/golangci-lint-action@v3
test:
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.21
- run: go test -v ./...
release:
runs-on: ubuntu-latest
needs: test
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.21
- uses: go-semantic-release/action@v1
with:
prerelease: true
hooks: goreleaser
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 4 additions & 5 deletions netbox/device.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package netbox

import (
"fmt"
"net/netip"

"github.com/netbox-community/go-netbox/v3/netbox/client"
Expand Down Expand Up @@ -81,8 +82,7 @@ func dcimDeviceToDevice(dev *models.DeviceWithConfigContext) (*Device, error) {
}

func ListDevices(c *client.NetBoxAPI) (Devices, error) {
var limit int64
limit = 0
limit := int64(0)

r := dcim.NewDcimDevicesListParams()
r.Limit = &limit
Expand All @@ -106,9 +106,8 @@ func ListDevices(c *client.NetBoxAPI) (Devices, error) {
}

func GetDevice(c *client.NetBoxAPI, id int64) (*Device, error) {
var limit int64
limit = 0
idStr := string(id)
limit := int64(0)
idStr := fmt.Sprint(id)

r := dcim.NewDcimDevicesListParams()
r.Limit = &limit
Expand Down
8 changes: 3 additions & 5 deletions netbox/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ func dcimInterfaceToInterface(i *models.Interface) (*Interface, error) {
}

func ListInterfaces(c *client.NetBoxAPI) (Interfaces, error) {
var limit int64
limit = 0
limit := int64(0)

r := dcim.NewDcimInterfacesListParams()
r.Limit = &limit
Expand All @@ -166,9 +165,8 @@ func ListInterfaces(c *client.NetBoxAPI) (Interfaces, error) {
}

func GetInterface(c *client.NetBoxAPI, id int64) (*Interface, error) {
var limit int64
limit = 0
idStr := string(id)
limit := int64(0)
idStr := fmt.Sprint(id)

r := dcim.NewDcimInterfacesListParams()
r.Limit = &limit
Expand Down
9 changes: 4 additions & 5 deletions netbox/ipaddr.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package netbox

import (
"fmt"
"net/netip"
"reflect"

Expand Down Expand Up @@ -88,8 +89,7 @@ func ipamAddressToIPAddr(i *models.IPAddress) (*IPAddr, error) {
}

func ListIPAddrs(c *client.NetBoxAPI) (IPAddrs, error) {
var limit int64
limit = 0
limit := int64(0)

r := ipam.NewIpamIPAddressesListParams()
r.Limit = &limit
Expand All @@ -113,9 +113,8 @@ func ListIPAddrs(c *client.NetBoxAPI) (IPAddrs, error) {
}

func GetIPAddr(c *client.NetBoxAPI, id int64) (*IPAddr, error) {
var limit int64
limit = 0
idStr := string(id)
limit := int64(0)
idStr := fmt.Sprint(id)

r := ipam.NewIpamIPAddressesListParams()
r.Limit = &limit
Expand Down
33 changes: 16 additions & 17 deletions netbox/ipprefix.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package netbox

import (
"fmt"
"net/netip"

"github.com/netbox-community/go-netbox/v3/netbox/client"
Expand All @@ -9,24 +10,24 @@ import (
)

type IPPrefix struct {
ID int64
Prefix netip.Prefix
Display string
Family string
Status string
Description string
Tags map[string]bool // Tags.Name -> true
VRF string
ID int64
Prefix netip.Prefix
Display string
Family string
Status string
Description string
Tags map[string]bool // Tags.Name -> true
VRF string
}

type IPPrefixes []*IPPrefix

func ipamPrefixToIPPrefix(i *models.Prefix) (*IPPrefix, error) {
ip := &IPPrefix{
Description: i.Description,
Display: i.Display,
ID: i.ID,
Tags: make(map[string]bool),
Description: i.Description,
Display: i.Display,
ID: i.ID,
Tags: make(map[string]bool),
}

if i.Prefix != nil {
Expand All @@ -53,8 +54,7 @@ func ipamPrefixToIPPrefix(i *models.Prefix) (*IPPrefix, error) {
}

func ListIPPrefixes(c *client.NetBoxAPI) (IPPrefixes, error) {
var limit int64
limit = 0
limit := int64(0)

r := ipam.NewIpamPrefixesListParams()
r.Limit = &limit
Expand All @@ -78,9 +78,8 @@ func ListIPPrefixes(c *client.NetBoxAPI) (IPPrefixes, error) {
}

func GetIPPrefix(c *client.NetBoxAPI, id int64) (*IPPrefix, error) {
var limit int64
limit = 0
idStr := string(id)
limit := int64(0)
idStr := fmt.Sprint(id)

r := ipam.NewIpamPrefixesListParams()
r.Limit = &limit
Expand Down

0 comments on commit 893c5a7

Please sign in to comment.