From 729cd54401dc122cb19b72eb868f9eee98dd999c Mon Sep 17 00:00:00 2001 From: Juan Font Date: Mon, 6 Sep 2021 14:39:52 +0200 Subject: [PATCH] Renamed sharing function --- cmd/headscale/cli/nodes.go | 2 +- sharing_nodes.go | 4 ++-- sharing_nodes_test.go | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/headscale/cli/nodes.go b/cmd/headscale/cli/nodes.go index 33dd3f79..171e98d1 100644 --- a/cmd/headscale/cli/nodes.go +++ b/cmd/headscale/cli/nodes.go @@ -203,7 +203,7 @@ var shareNodeCmd = &cobra.Command{ log.Fatalf("Error getting node: %s", err) } - err = h.ShareNodeInNamespace(m, destNs) + err = h.AddSharedMachineToNamespace(m, destNs) if strings.HasPrefix(o, "json") { JsonOutput(map[string]string{"Result": "Node shared"}, err, o) return diff --git a/sharing_nodes.go b/sharing_nodes.go index feab1fb2..54d9976b 100644 --- a/sharing_nodes.go +++ b/sharing_nodes.go @@ -14,8 +14,8 @@ type SharedNode struct { Namespace Namespace } -// ShareNodeInNamespace adds a machine as a shared node to a namespace -func (h *Headscale) ShareNodeInNamespace(m *Machine, ns *Namespace) error { +// AddSharedMachineToNamespace adds a machine as a shared node to a namespace +func (h *Headscale) AddSharedMachineToNamespace(m *Machine, ns *Namespace) error { if m.NamespaceID == ns.ID { return errorSameNamespace } diff --git a/sharing_nodes_test.go b/sharing_nodes_test.go index 2c8a7a13..7c3ff828 100644 --- a/sharing_nodes_test.go +++ b/sharing_nodes_test.go @@ -59,7 +59,7 @@ func (s *Suite) TestBasicSharedNodesInNamespace(c *check.C) { c.Assert(err, check.IsNil) c.Assert(len(*p1s), check.Equals, 0) - err = h.ShareNodeInNamespace(&m2, n1) + err = h.AddSharedMachineToNamespace(&m2, n1) c.Assert(err, check.IsNil) p1sAfter, err := h.getPeers(m1) @@ -122,7 +122,7 @@ func (s *Suite) TestSameNamespace(c *check.C) { c.Assert(err, check.IsNil) c.Assert(len(*p1s), check.Equals, 0) - err = h.ShareNodeInNamespace(&m1, n1) + err = h.AddSharedMachineToNamespace(&m1, n1) c.Assert(err, check.Equals, errorSameNamespace) } @@ -180,9 +180,9 @@ func (s *Suite) TestAlreadyShared(c *check.C) { c.Assert(err, check.IsNil) c.Assert(len(*p1s), check.Equals, 0) - err = h.ShareNodeInNamespace(&m2, n1) + err = h.AddSharedMachineToNamespace(&m2, n1) c.Assert(err, check.IsNil) - err = h.ShareNodeInNamespace(&m2, n1) + err = h.AddSharedMachineToNamespace(&m2, n1) c.Assert(err, check.Equals, errorNodeAlreadyShared) } @@ -240,7 +240,7 @@ func (s *Suite) TestDoNotIncludeRoutesOnShared(c *check.C) { c.Assert(err, check.IsNil) c.Assert(len(*p1s), check.Equals, 0) - err = h.ShareNodeInNamespace(&m2, n1) + err = h.AddSharedMachineToNamespace(&m2, n1) c.Assert(err, check.IsNil) p1sAfter, err := h.getPeers(m1) @@ -346,7 +346,7 @@ func (s *Suite) TestComplexSharingAcrossNamespaces(c *check.C) { c.Assert(err, check.IsNil) c.Assert(len(*p1s), check.Equals, 1) // nodes 1 and 4 - err = h.ShareNodeInNamespace(&m2, n1) + err = h.AddSharedMachineToNamespace(&m2, n1) c.Assert(err, check.IsNil) p1sAfter, err := h.getPeers(m1)