Skip to content

Commit 5368653

Browse files
authored
Merge pull request #5 from rschmied/dev
Add LinkDestroy method, update deps
2 parents cfaf897 + 83535c2 commit 5368653

File tree

9 files changed

+37
-7
lines changed

9 files changed

+37
-7
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
Lists the changes in the gocmlclient package.
44

5+
## Version 0.0.23
6+
7+
- added LinkDestroy() method
8+
- removed rand.Seed() as it's not needed with newer go versions
9+
- made the package require 1.20
10+
- updated dependencies / vendor data
11+
512
## Version 0.0.22
613

714
- added HideLinks node property

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module github.com/rschmied/gocmlclient
22

3-
go 1.19
3+
go 1.20
44

55
require (
66
github.com/Masterminds/semver/v3 v3.2.1
77
github.com/rschmied/mockresponder v1.0.4
88
github.com/stretchr/testify v1.8.2
9-
golang.org/x/sync v0.5.0
9+
golang.org/x/sync v0.7.0
1010
)
1111

1212
require (

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
1414
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
1515
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
1616
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
17-
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
18-
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
17+
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
18+
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
1919
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
2020
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2121
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

iface.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (iface Interface) IsPhysical() bool {
6868
return iface.Type == IfaceTypePhysical
6969
}
7070

71-
func (c *Client) updateCachedIface(existingIface, iface *Interface) *Interface {
71+
func (c *Client) updateCachedIface(existingIface, _ *Interface) *Interface {
7272
// this is a no-op at this point, we don't allow updating interfaces
7373
return existingIface
7474
}

iface_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ func Test_Race(t *testing.T) {
237237
node := Node{ID: "node1", LabID: lab.ID}
238238
lab.Nodes[node.ID] = &node
239239
tc.client.labCache[lab.ID] = &lab
240-
rand.Seed(time.Now().UnixNano())
240+
// rand.Seed is not needed anymore from 1.20 onward
241+
// rand.Seed(time.Now().UnixNano())
241242

242243
for i := 0; i < 50; i++ {
243244
tc.mr.Reset()

link.go

+7
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,10 @@ func (c *Client) LinkCreate(ctx context.Context, link *Link) (*Link, error) {
258258

259259
return c.LinkGet(ctx, link.LabID, newLinkResult.ID, true)
260260
}
261+
262+
// LinkDestroy removes a link from a lab identified by the Lab ID and Link ID
263+
// provided in the link arg.
264+
func (c *Client) LinkDestroy(ctx context.Context, link *Link) error {
265+
api := fmt.Sprintf("labs/%s/links/%s", link.LabID, link.ID)
266+
return c.jsonDelete(ctx, api, 0)
267+
}

link_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -287,3 +287,15 @@ func TestClient_CreateLink(t *testing.T) {
287287
}
288288
}
289289
}
290+
291+
func TestClient_DestroyLink(t *testing.T) {
292+
tc := newAuthedTestAPIclient()
293+
294+
tc.mr.SetData(mr.MockRespList{
295+
mr.MockResp{Code: 200},
296+
})
297+
298+
tc.client.useCache = false
299+
err := tc.client.LinkDestroy(tc.ctx, &Link{LabID: "lab1", ID: "link1"})
300+
assert.NoError(t, err)
301+
}

vendor/golang.org/x/sync/errgroup/errgroup.go

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ github.com/rschmied/mockresponder
1313
# github.com/stretchr/testify v1.8.2
1414
## explicit; go 1.13
1515
github.com/stretchr/testify/assert
16-
# golang.org/x/sync v0.5.0
16+
# golang.org/x/sync v0.7.0
1717
## explicit; go 1.18
1818
golang.org/x/sync/errgroup
1919
# gopkg.in/yaml.v3 v3.0.1

0 commit comments

Comments
 (0)