Renamed sharing function

This commit is contained in:
Juan Font 2021-09-06 14:39:52 +02:00
parent 7edd0cd14c
commit 729cd54401
3 changed files with 9 additions and 9 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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)