Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LinkDestroy method, update deps #5

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

Lists the changes in the gocmlclient package.

## Version 0.0.23

- added LinkDestroy() method
- removed rand.Seed() as it's not needed with newer go versions
- made the package require 1.20
- updated dependencies / vendor data

## Version 0.0.22

- added HideLinks node property
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module github.com/rschmied/gocmlclient

go 1.19
go 1.20

require (
github.com/Masterminds/semver/v3 v3.2.1
github.com/rschmied/mockresponder v1.0.4
github.com/stretchr/testify v1.8.2
golang.org/x/sync v0.5.0
golang.org/x/sync v0.7.0
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
2 changes: 1 addition & 1 deletion iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (iface Interface) IsPhysical() bool {
return iface.Type == IfaceTypePhysical
}

func (c *Client) updateCachedIface(existingIface, iface *Interface) *Interface {
func (c *Client) updateCachedIface(existingIface, _ *Interface) *Interface {
// this is a no-op at this point, we don't allow updating interfaces
return existingIface
}
Expand Down
3 changes: 2 additions & 1 deletion iface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ func Test_Race(t *testing.T) {
node := Node{ID: "node1", LabID: lab.ID}
lab.Nodes[node.ID] = &node
tc.client.labCache[lab.ID] = &lab
rand.Seed(time.Now().UnixNano())
// rand.Seed is not needed anymore from 1.20 onward
// rand.Seed(time.Now().UnixNano())

for i := 0; i < 50; i++ {
tc.mr.Reset()
Expand Down
7 changes: 7 additions & 0 deletions link.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,10 @@ func (c *Client) LinkCreate(ctx context.Context, link *Link) (*Link, error) {

return c.LinkGet(ctx, link.LabID, newLinkResult.ID, true)
}

// LinkDestroy removes a link from a lab identified by the Lab ID and Link ID
// provided in the link arg.
func (c *Client) LinkDestroy(ctx context.Context, link *Link) error {
api := fmt.Sprintf("labs/%s/links/%s", link.LabID, link.ID)
return c.jsonDelete(ctx, api, 0)
}
12 changes: 12 additions & 0 deletions link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,15 @@ func TestClient_CreateLink(t *testing.T) {
}
}
}

func TestClient_DestroyLink(t *testing.T) {
tc := newAuthedTestAPIclient()

tc.mr.SetData(mr.MockRespList{
mr.MockResp{Code: 200},
})

tc.client.useCache = false
err := tc.client.LinkDestroy(tc.ctx, &Link{LabID: "lab1", ID: "link1"})
assert.NoError(t, err)
}
3 changes: 3 additions & 0 deletions vendor/golang.org/x/sync/errgroup/errgroup.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ github.com/rschmied/mockresponder
# github.com/stretchr/testify v1.8.2
## explicit; go 1.13
github.com/stretchr/testify/assert
# golang.org/x/sync v0.5.0
# golang.org/x/sync v0.7.0
## explicit; go 1.18
golang.org/x/sync/errgroup
# gopkg.in/yaml.v3 v3.0.1
Expand Down
Loading