func (s *networkSuite) TestNetworkNames(c *gc.C) { for i, test := range networkNameTests { c.Logf("test %d: %q", i, test.pattern) c.Check(names.IsNetwork(test.pattern), gc.Equals, test.valid) if test.valid { expectTag := fmt.Sprintf("%s-%s", names.NetworkTagKind, test.pattern) c.Check(names.NetworkTag(test.pattern), gc.Equals, expectTag) } else { expectErr := fmt.Sprintf("%q is not a valid network name", test.pattern) testNetworkTag := func() { names.NetworkTag(test.pattern) } c.Check(testNetworkTag, gc.PanicMatches, regexp.QuoteMeta(expectErr)) } } }
// parseNetworks returns a list of network tags by parsing the // comma-delimited string value of --networks argument. func parseNetworks(networksValue string) (networks []string) { parts := strings.Split(networksValue, ",") for _, part := range parts { network := strings.TrimSpace(part) if network != "" { networks = append(networks, names.NetworkTag(network)) } } return networks }
// NetworkTag returns the network tag of the interface. func (ni *NetworkInterface) NetworkTag() string { return names.NetworkTag(ni.doc.NetworkName) }