Ejemplo n.º 1
0
// ParseFilesystemAttachmentId parses a string as a filesystem attachment ID,
// returning the machine and filesystem components.
func ParseFilesystemAttachmentId(id string) (names.MachineTag, names.FilesystemTag, error) {
	fields := strings.SplitN(id, ":", 2)
	if len(fields) != 2 || !names.IsValidMachine(fields[0]) || !names.IsValidFilesystem(fields[1]) {
		return names.MachineTag{}, names.FilesystemTag{}, errors.Errorf("invalid filesystem attachment ID %q", id)
	}
	machineTag := names.NewMachineTag(fields[0])
	filesystemTag := names.NewFilesystemTag(fields[1])
	return machineTag, filesystemTag, nil
}
Ejemplo n.º 2
0
func assertFilesystemIdInvalid(c *gc.C, name string) {
	c.Assert(names.IsValidFilesystem(name), gc.Equals, false)
	testFilesystemTag := func() { names.NewFilesystemTag(name) }
	expect := fmt.Sprintf("%q is not a valid filesystem id", name)
	c.Assert(testFilesystemTag, gc.PanicMatches, expect)
}
Ejemplo n.º 3
0
func assertFilesystemIdValid(c *gc.C, name string) {
	c.Assert(names.IsValidFilesystem(name), gc.Equals, true)
	names.NewFilesystemTag(name)
}