func (*suite) TestParseMajorMinor(c *gc.C) { for i, test := range parseMajorMinorTests { c.Logf("test %d", i) major, minor, err := version.ParseMajorMinor(test.v) if test.err != "" { c.Check(err, gc.ErrorMatches, test.err) } else { c.Check(err, gc.IsNil) c.Check(major, gc.Equals, test.expectMajor) c.Check(minor, gc.Equals, test.expectMinor) } } }
func (c *SyncToolsCommand) Init(args []string) error { if err := c.EnvCommandBase.EnsureEnvName(); err != nil { return err } if c.destination != "" { // Override localDir with destination as localDir now replaces destination c.localDir = c.destination logger.Warningf("Use of the --destination flag is deprecated in 1.18. Please use --local-dir instead.") } if c.versionStr != "" { var err error if c.majorVersion, c.minorVersion, err = version.ParseMajorMinor(c.versionStr); err != nil { return err } } return cmd.CheckEmpty(args) }
func (c *ValidateToolsMetadataCommand) Init(args []string) error { if err := c.EnvCommandBase.EnsureEnvName(); err != nil { return err } if c.providerType != "" { if c.region == "" { return fmt.Errorf("region required if provider type is specified") } if c.metadataDir == "" { return fmt.Errorf("metadata directory required if provider type is specified") } } if c.exactVersion == "current" { c.exactVersion = version.Current.Number.String() } if c.partVersion != "" { var err error if c.major, c.minor, err = version.ParseMajorMinor(c.partVersion); err != nil { return err } } return cmd.CheckEmpty(args) }