diff --git a/CHANGELOG.md b/CHANGELOG.md index e65432f..f359504 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/go.mod b/go.mod index e6c9684..dc29f9a 100644 --- a/go.mod +++ b/go.mod @@ -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 ( diff --git a/go.sum b/go.sum index 2ddc45d..8f3514a 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/iface.go b/iface.go index 4b8074b..4828347 100644 --- a/iface.go +++ b/iface.go @@ -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 } diff --git a/iface_test.go b/iface_test.go index b70d82c..a19735e 100644 --- a/iface_test.go +++ b/iface_test.go @@ -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() diff --git a/link.go b/link.go index bbc77f7..a24ddfd 100644 --- a/link.go +++ b/link.go @@ -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) +} diff --git a/link_test.go b/link_test.go index 84d375f..45be699 100644 --- a/link_test.go +++ b/link_test.go @@ -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) +} diff --git a/vendor/golang.org/x/sync/errgroup/errgroup.go b/vendor/golang.org/x/sync/errgroup/errgroup.go index b18efb7..948a3ee 100644 --- a/vendor/golang.org/x/sync/errgroup/errgroup.go +++ b/vendor/golang.org/x/sync/errgroup/errgroup.go @@ -4,6 +4,9 @@ // Package errgroup provides synchronization, error propagation, and Context // cancelation for groups of goroutines working on subtasks of a common task. +// +// [errgroup.Group] is related to [sync.WaitGroup] but adds handling of tasks +// returning errors. package errgroup import ( diff --git a/vendor/modules.txt b/vendor/modules.txt index dad1024..0c9740a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -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