From fe17a73874d8824065babbbd99316caa3080fec1 Mon Sep 17 00:00:00 2001 From: Jack Shaw Date: Wed, 5 Jul 2023 18:20:01 +0100 Subject: [PATCH] start machine now accepts a base datastructure This is converted to a series if deploying with base isn't supported As a flyby, tidy go.mod and replace github.com/juju/version with github.com/juju/version/v2 --- base.go | 81 ++++++++++++++++++++++++++++++++++++++++++++ blockdevice.go | 2 +- blockdevice_test.go | 2 +- bootresource.go | 2 +- bootresource_test.go | 2 +- controller.go | 22 +++++++----- controller_test.go | 2 +- device.go | 2 +- device_test.go | 2 +- domain.go | 2 +- fabric.go | 2 +- fabric_test.go | 2 +- file.go | 2 +- file_test.go | 2 +- go.mod | 23 ++++++------- go.sum | 41 ++++++++++++++-------- interface.go | 2 +- interface_test.go | 2 +- interfaces.go | 7 ++-- link.go | 2 +- link_test.go | 2 +- machine.go | 23 +++++++++---- machine_test.go | 2 +- partition.go | 2 +- partition_test.go | 2 +- pool.go | 2 +- pool_test.go | 2 +- space.go | 2 +- space_test.go | 2 +- staticroute.go | 2 +- staticroute_test.go | 2 +- subnet.go | 2 +- subnet_test.go | 2 +- tags.go | 2 +- vlan.go | 2 +- vlan_test.go | 2 +- zone.go | 2 +- zone_test.go | 2 +- 38 files changed, 185 insertions(+), 76 deletions(-) create mode 100644 base.go diff --git a/base.go b/base.go new file mode 100644 index 0000000..19fe490 --- /dev/null +++ b/base.go @@ -0,0 +1,81 @@ +// Copyright 2023 Canonical Ltd. +// Licensed under the LGPLv3, see LICENCE file for details. + +package gomaasapi + +import ( + "fmt" + + "github.com/juju/errors" + "github.com/juju/version/v2" +) + +var VersionDeploySupportsBases = version.Number{Major: 3, Minor: 3, Patch: 5} + +type OSType string + +var ( + Custom OSType = "custom" + Ubuntu OSType = "ubuntu" + Centos OSType = "centos" +) + +type Base struct { + OS OSType + Version string +} + +func (b Base) String() string { + if b.OS != "" && b.Version != "" { + return fmt.Sprintf("%s/%s", b.OS, b.Version) + } + if b.Version != "" { + return b.Version + } + return "" +} + +func (b Base) toSeries() (string, error) { + if b.OS == "" { + return b.Version, nil + } + switch b.OS { + case Custom: + return b.String(), nil + case Ubuntu: + if series, ok := ubuntuMap[b.Version]; ok { + return series, nil + } + return "", errors.NotValidf("base %s cannot be converted into a series", b) + case Centos: + if series, ok := centosMap[b.Version]; ok { + return series, nil + } + return "", errors.NotValidf("base %s cannot be converted into a series", b) + default: + return "", errors.NotValidf("base %s OS", b) + } + +} + +const ( + centos7 = "centos7" + centos8 = "centos8" + centos9 = "centos9" +) + +var ubuntuMap = map[string]string{ + "20.04": "ubuntu/focal", + "20.10": "ubuntu/groovy", + "21.04": "ubuntu/hirsute", + "21.10": "ubuntu/impish", + "22.04": "ubuntu/jammy", + "22.10": "ubuntu/kinetic", + "23.04": "ubuntu/lunar", +} + +var centosMap = map[string]string{ + "7": "centos/centos7", + "8": "centos/centos8", + "9": "centos/centos9", +} diff --git a/blockdevice.go b/blockdevice.go index b107635..7cdb4d0 100644 --- a/blockdevice.go +++ b/blockdevice.go @@ -6,7 +6,7 @@ package gomaasapi import ( "github.com/juju/errors" "github.com/juju/schema" - "github.com/juju/version" + "github.com/juju/version/v2" ) type blockdevice struct { diff --git a/blockdevice_test.go b/blockdevice_test.go index 0d7d883..fbb570d 100644 --- a/blockdevice_test.go +++ b/blockdevice_test.go @@ -5,7 +5,7 @@ package gomaasapi import ( jc "github.com/juju/testing/checkers" - "github.com/juju/version" + "github.com/juju/version/v2" gc "gopkg.in/check.v1" ) diff --git a/bootresource.go b/bootresource.go index 6ba68eb..59f9920 100644 --- a/bootresource.go +++ b/bootresource.go @@ -9,7 +9,7 @@ import ( "github.com/juju/collections/set" "github.com/juju/errors" "github.com/juju/schema" - "github.com/juju/version" + "github.com/juju/version/v2" ) type bootResource struct { diff --git a/bootresource_test.go b/bootresource_test.go index 1faebb2..db50cf9 100644 --- a/bootresource_test.go +++ b/bootresource_test.go @@ -6,7 +6,7 @@ package gomaasapi import ( "github.com/juju/collections/set" jc "github.com/juju/testing/checkers" - "github.com/juju/version" + "github.com/juju/version/v2" gc "gopkg.in/check.v1" ) diff --git a/controller.go b/controller.go index 7b266fb..b2ec6e8 100644 --- a/controller.go +++ b/controller.go @@ -19,7 +19,7 @@ import ( "github.com/juju/errors" "github.com/juju/loggo" "github.com/juju/schema" - "github.com/juju/version" + "github.com/juju/version/v2" ) var ( @@ -97,7 +97,7 @@ func newControllerWithVersion(baseURL, apiVersion, apiKey string, httpClient *ht Minor: minor, } controller := &controller{client: client, apiVersion: controllerVersion} - _, _, controller.capabilities, err = controller.readAPIVersionInfo() + controller.maasVersion, _, controller.capabilities, err = controller.readAPIVersionInfo() if err != nil { logger.Debugf("read version failed: %#v", err) return nil, errors.Trace(err) @@ -132,6 +132,7 @@ func newControllerUnknownVersion(args ControllerArgs) (Controller, error) { type controller struct { client *Client apiVersion version.Number + maasVersion version.Number capabilities set.Strings } @@ -914,17 +915,17 @@ func indicatesUnsupportedVersion(err error) bool { // APIVersionInfo returns the version and subversion strings for the MAAS // controller. -func (c *controller) APIVersionInfo() (string, string, error) { +func (c *controller) APIVersionInfo() (version.Number, string, error) { version, subversion, _, err := c.readAPIVersionInfo() return version, subversion, err } -func (c *controller) readAPIVersionInfo() (string, string, set.Strings, error) { +func (c *controller) readAPIVersionInfo() (version.Number, string, set.Strings, error) { parsed, err := c.get("version") if indicatesUnsupportedVersion(err) { - return "", "", nil, WrapWithUnsupportedVersionError(err) + return version.Zero, "", nil, WrapWithUnsupportedVersionError(err) } else if err != nil { - return "", "", nil, errors.Trace(err) + return version.Zero, "", nil, errors.Trace(err) } fields := schema.Fields{ @@ -935,7 +936,7 @@ func (c *controller) readAPIVersionInfo() (string, string, set.Strings, error) { checker := schema.FieldMap(fields, nil) // no defaults coerced, err := checker.Coerce(parsed, nil) if err != nil { - return "", "", nil, WrapWithDeserializationError(err, "version response") + return version.Zero, "", nil, WrapWithDeserializationError(err, "version response") } // For now, we don't append any subversion, but as it becomes used, we // should parse and check. @@ -949,10 +950,13 @@ func (c *controller) readAPIVersionInfo() (string, string, set.Strings, error) { capabilities.Add(value.(string)) } - version := valid["version"].(string) + maasVersion, err := version.Parse(valid["version"].(string)) + if err != nil { + return version.Zero, "", nil, WrapWithDeserializationError(err, "version response") + } subversion := valid["subversion"].(string) - return version, subversion, capabilities, nil + return maasVersion, subversion, capabilities, nil } func parseAllocateConstraintsResponse(source interface{}, machine *machine) (ConstraintMatches, error) { diff --git a/controller_test.go b/controller_test.go index 4962293..55ebd85 100644 --- a/controller_test.go +++ b/controller_test.go @@ -14,7 +14,7 @@ import ( "github.com/juju/loggo" "github.com/juju/testing" jc "github.com/juju/testing/checkers" - "github.com/juju/version" + "github.com/juju/version/v2" gc "gopkg.in/check.v1" ) diff --git a/device.go b/device.go index 7ff2447..8035969 100644 --- a/device.go +++ b/device.go @@ -10,7 +10,7 @@ import ( "github.com/juju/errors" "github.com/juju/schema" - "github.com/juju/version" + "github.com/juju/version/v2" ) type device struct { diff --git a/device_test.go b/device_test.go index c346b24..4a0f4cf 100644 --- a/device_test.go +++ b/device_test.go @@ -9,7 +9,7 @@ import ( "github.com/juju/errors" "github.com/juju/testing" jc "github.com/juju/testing/checkers" - "github.com/juju/version" + "github.com/juju/version/v2" gc "gopkg.in/check.v1" ) diff --git a/domain.go b/domain.go index 22ffef2..3632cbb 100644 --- a/domain.go +++ b/domain.go @@ -6,7 +6,7 @@ package gomaasapi import ( "github.com/juju/errors" "github.com/juju/schema" - "github.com/juju/version" + "github.com/juju/version/v2" ) type domain struct { diff --git a/fabric.go b/fabric.go index e38a61a..92c641a 100644 --- a/fabric.go +++ b/fabric.go @@ -6,7 +6,7 @@ package gomaasapi import ( "github.com/juju/errors" "github.com/juju/schema" - "github.com/juju/version" + "github.com/juju/version/v2" ) type fabric struct { diff --git a/fabric_test.go b/fabric_test.go index a7e757a..ccff876 100644 --- a/fabric_test.go +++ b/fabric_test.go @@ -5,7 +5,7 @@ package gomaasapi import ( jc "github.com/juju/testing/checkers" - "github.com/juju/version" + "github.com/juju/version/v2" gc "gopkg.in/check.v1" ) diff --git a/file.go b/file.go index 63fb854..02ead98 100644 --- a/file.go +++ b/file.go @@ -10,7 +10,7 @@ import ( "github.com/juju/errors" "github.com/juju/schema" - "github.com/juju/version" + "github.com/juju/version/v2" ) type file struct { diff --git a/file_test.go b/file_test.go index 039bf49..8361a7d 100644 --- a/file_test.go +++ b/file_test.go @@ -8,7 +8,7 @@ import ( "github.com/juju/testing" jc "github.com/juju/testing/checkers" - "github.com/juju/version" + "github.com/juju/version/v2" gc "gopkg.in/check.v1" ) diff --git a/go.mod b/go.mod index 1446975..9bc273d 100644 --- a/go.mod +++ b/go.mod @@ -3,27 +3,24 @@ module github.com/juju/gomaasapi/v2 go 1.17 require ( - github.com/juju/collections v0.0.0-20220203020748-febd7cad8a7a - github.com/juju/errors v0.0.0-20220203013757-bd733f3c86b9 - github.com/juju/loggo v0.0.0-20210728185423-eebad3a902c4 + github.com/juju/collections v1.0.0 + github.com/juju/errors v1.0.0 + github.com/juju/loggo v1.0.0 github.com/juju/mgo/v2 v2.0.0-20220111072304-f200228f1090 github.com/juju/schema v1.0.1-0.20190814234152-1f8aaeef0989 - github.com/juju/testing v0.0.0-20220203020004-a0ff61f03494 - github.com/juju/version v0.0.0-20191219164919-81c1be00b9a6 + github.com/juju/testing v1.0.1 + github.com/juju/version/v2 v2.0.1 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c ) require ( - github.com/juju/clock v0.0.0-20220203021603-d9deb868a28a // indirect - github.com/juju/retry v0.0.0-20220204093819-62423bf33287 // indirect - github.com/juju/utils/v3 v3.0.0-20220203023959-c3fbc78a33b0 // indirect - github.com/juju/version/v2 v2.0.0-20220204124744-fc9915e3d935 // indirect - github.com/kr/pretty v0.2.1 // indirect + github.com/juju/clock v1.0.0 // indirect + github.com/juju/mgo/v3 v3.0.2 // indirect + github.com/juju/utils/v3 v3.0.0 // indirect + github.com/kr/pretty v0.3.0 // indirect github.com/kr/text v0.2.0 // indirect - github.com/xdg-go/stringprep v1.0.2 // indirect + github.com/rogpeppe/go-internal v1.8.1 // indirect golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect golang.org/x/net v0.0.0-20211216030914-fe4d6282115f // indirect - golang.org/x/text v0.3.7 // indirect - gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index 9eec077..c5ca9b7 100644 --- a/go.sum +++ b/go.sum @@ -19,34 +19,39 @@ github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a/go.mod h1:UJSiEoRfvx github.com/juju/ansiterm v0.0.0-20210706145210-9283cdf370b5/go.mod h1:UJSiEoRfvx3hP73CvoARgeLjaIOjybY9vj8PUPPFGeU= github.com/juju/clock v0.0.0-20190205081909-9c5c9712527c/go.mod h1:nD0vlnrUjcjJhqN5WuCWZyzfd5AHZAC9/ajvbSx69xA= github.com/juju/clock v0.0.0-20220202072423-1b0f830854c4/go.mod h1:zDZCPSgCJQINeZtQwHx2/cFk4seaBC8Yiqe8V82xiP0= -github.com/juju/clock v0.0.0-20220203021603-d9deb868a28a h1:Az/6CM/P5guGHNy7r6TkOCctv3lDmN3W1uhku7QMupk= github.com/juju/clock v0.0.0-20220203021603-d9deb868a28a/go.mod h1:GZ/FY8Cqw3KHG6DwRVPUKbSPTAwyrU28xFi5cqZnLsc= +github.com/juju/clock v1.0.0 h1:9U1jPr/FT0DfZjl8qh9dSACAXUodjPOz+uZBdeVv/N8= +github.com/juju/clock v1.0.0/go.mod h1:GZ/FY8Cqw3KHG6DwRVPUKbSPTAwyrU28xFi5cqZnLsc= github.com/juju/cmd v0.0.0-20171107070456-e74f39857ca0/go.mod h1:yWJQHl73rdSX4DHVKGqkAip+huBslxRwS8m9CrOLq18= github.com/juju/cmd/v3 v3.0.0-20220202061353-b1cc80b193b0/go.mod h1:EoGJiEG+vbMwO9l+Es0SDTlaQPjH6nLcnnc4NfZB3cY= github.com/juju/collections v0.0.0-20200605021417-0d0ec82b7271/go.mod h1:5XgO71dV1JClcOJE+4dzdn4HrI5LiyKd7PlVG6eZYhY= -github.com/juju/collections v0.0.0-20220203020748-febd7cad8a7a h1:d7eZO8OS/ZXxdP0uq3E8CdoA1qNFaecAv90UxrxaY2k= github.com/juju/collections v0.0.0-20220203020748-febd7cad8a7a/go.mod h1:JWeZdyttIEbkR51z2S13+J+aCuHVe0F6meRy+P0YGDo= +github.com/juju/collections v1.0.0 h1:iuWddKN/SMbjLoyOpcnAl8XyBCavZm6coeFBcXQldbw= +github.com/juju/collections v1.0.0/go.mod h1:JWeZdyttIEbkR51z2S13+J+aCuHVe0F6meRy+P0YGDo= github.com/juju/errors v0.0.0-20150916125642-1b5e39b83d18/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= github.com/juju/errors v0.0.0-20200330140219-3fe23663418f/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= github.com/juju/errors v0.0.0-20210818161939-5560c4c073ff/go.mod h1:i1eL7XREII6aHpQ2gApI/v6FkVUDEBremNkcBCKYAcY= -github.com/juju/errors v0.0.0-20220203013757-bd733f3c86b9 h1:EJHbsNpQyupmMeWTq7inn+5L/WZ7JfzCVPJ+DP9McCQ= github.com/juju/errors v0.0.0-20220203013757-bd733f3c86b9/go.mod h1:TRm7EVGA3mQOqSVcBySRY7a9Y1/gyVhh/WTCnc5sD4U= +github.com/juju/errors v1.0.0 h1:yiq7kjCLll1BiaRuNY53MGI0+EQ3rF6GB+wvboZDefM= +github.com/juju/errors v1.0.0/go.mod h1:B5x9thDqx0wIMH3+aLIMP9HjItInYWObRovoCFM5Qe8= github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE= github.com/juju/httpprof v0.0.0-20141217160036-14bf14c30767/go.mod h1:+MaLYz4PumRkkyHYeXJ2G5g5cIW0sli2bOfpmbaMV/g= github.com/juju/loggo v0.0.0-20170605014607-8232ab8918d9/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= github.com/juju/loggo v0.0.0-20200526014432-9ce3a2e09b5e/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= -github.com/juju/loggo v0.0.0-20210728185423-eebad3a902c4 h1:NO5tuyw++EGLnz56Q8KMyDZRwJwWO8jQnj285J3FOmY= github.com/juju/loggo v0.0.0-20210728185423-eebad3a902c4/go.mod h1:NIXFioti1SmKAlKNuUwbMenNdef59IF52+ZzuOmHYkg= +github.com/juju/loggo v1.0.0 h1:Y6ZMQOGR9Aj3BGkiWx7HBbIx6zNwNkxhVNOHU2i1bl0= +github.com/juju/loggo v1.0.0/go.mod h1:NIXFioti1SmKAlKNuUwbMenNdef59IF52+ZzuOmHYkg= github.com/juju/mgo/v2 v2.0.0-20210302023703-70d5d206e208/go.mod h1:0OChplkvPTZ174D2FYZXg4IB9hbEwyHkD+zT+/eK+Fg= github.com/juju/mgo/v2 v2.0.0-20220111072304-f200228f1090 h1:zX5GoH3Jp8k1EjUFkApu/YZAYEn0PYQfg/U6IDyNyYs= github.com/juju/mgo/v2 v2.0.0-20220111072304-f200228f1090/go.mod h1:N614SE0a4e+ih2rg96Vi2PeC3cTpUOWgCTv3Cgk974c= +github.com/juju/mgo/v3 v3.0.2 h1:I2F9bfxhlydulZhtTSYm+r0k6T3SDkgs4oJZ3TCTnTY= +github.com/juju/mgo/v3 v3.0.2/go.mod h1:fAvhDCRbUlEbRIae6UQT8RvPUoLwKnJsBgO6OzHKNxw= github.com/juju/mutex v0.0.0-20171110020013-1fe2a4bf0a3a/go.mod h1:Y3oOzHH8CQ0Ppt0oCKJ2JFO81/EsWenH5AEqigLH+yY= github.com/juju/mutex/v2 v2.0.0-20220128011612-57176ebdcfa3/go.mod h1:TTCG9BJD9rCC4DZFz3jA0QvCqFDHw8Eqz0jstwY7RTQ= github.com/juju/mutex/v2 v2.0.0-20220203023141-11eeddb42c6c/go.mod h1:jwCfBs/smYDaeZLqeaCi8CB8M+tOes4yf827HoOEoqk= github.com/juju/retry v0.0.0-20151029024821-62c620325291/go.mod h1:OohPQGsr4pnxwD5YljhQ+TZnuVRYpa5irjugL1Yuif4= github.com/juju/retry v0.0.0-20180821225755-9058e192b216/go.mod h1:OohPQGsr4pnxwD5YljhQ+TZnuVRYpa5irjugL1Yuif4= -github.com/juju/retry v0.0.0-20220204093819-62423bf33287 h1:U+7oMWEglXfiikIppNexButZRwKPlzLBGKYSNCXzXf8= -github.com/juju/retry v0.0.0-20220204093819-62423bf33287/go.mod h1:SssN1eYeK3A2qjnFGTiVMbdzGJ2BfluaJblJXvuvgqA= +github.com/juju/retry v1.0.0/go.mod h1:SssN1eYeK3A2qjnFGTiVMbdzGJ2BfluaJblJXvuvgqA= github.com/juju/schema v1.0.1-0.20190814234152-1f8aaeef0989 h1:qx1Zh1bnHHVIMmRxq0fehYk7npCG50GhUwEkYeUg/t4= github.com/juju/schema v1.0.1-0.20190814234152-1f8aaeef0989/go.mod h1:Y+ThzXpUJ0E7NYYocAbuvJ7vTivXfrof/IfRPq/0abI= github.com/juju/testing v0.0.0-20180402130637-44801989f0f7/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= @@ -55,27 +60,32 @@ github.com/juju/testing v0.0.0-20190723135506-ce30eb24acd2/go.mod h1:63prj8cnj0t github.com/juju/testing v0.0.0-20210302031854-2c7ee8570c07/go.mod h1:7lxZW0B50+xdGFkvhAb8bwAGt6IU87JB1H9w4t8MNVM= github.com/juju/testing v0.0.0-20210324180055-18c50b0c2098/go.mod h1:7lxZW0B50+xdGFkvhAb8bwAGt6IU87JB1H9w4t8MNVM= github.com/juju/testing v0.0.0-20220202055744-1ad0816210a6/go.mod h1:QgWc2UdIPJ8t3rnvv95tFNOsQDfpXYEZDbP281o3b2c= -github.com/juju/testing v0.0.0-20220203020004-a0ff61f03494 h1:XEDzpuZb8Ma7vLja3+5hzUqVTvAqm5Y+ygvnDs5iTMM= github.com/juju/testing v0.0.0-20220203020004-a0ff61f03494/go.mod h1:rUquetT0ALL48LHZhyRGvjjBH8xZaZ8dFClulKK5wK4= +github.com/juju/testing v1.0.0/go.mod h1:rUquetT0ALL48LHZhyRGvjjBH8xZaZ8dFClulKK5wK4= +github.com/juju/testing v1.0.1 h1:Zlg3HKP+wBRpkxCmh+Bsxp3WOmfelcZXuX6Adb7Dvec= +github.com/juju/testing v1.0.1/go.mod h1:h3Vd2rzB57KrdsBEy6R7bmSKPzP76BnNavt7i8PerwQ= github.com/juju/utils v0.0.0-20180424094159-2000ea4ff043/go.mod h1:6/KLg8Wz/y2KVGWEpkK9vMNGkOnu4k/cqs8Z1fKjTOk= github.com/juju/utils v0.0.0-20200116185830-d40c2fe10647 h1:wQpkHVbIIpz1PCcLYku9KFWsJ7aEMQXHBBmLy3tRBTk= github.com/juju/utils v0.0.0-20200116185830-d40c2fe10647/go.mod h1:6/KLg8Wz/y2KVGWEpkK9vMNGkOnu4k/cqs8Z1fKjTOk= github.com/juju/utils/v2 v2.0.0-20200923005554-4646bfea2ef1/go.mod h1:fdlDtQlzundleLLz/ggoYinEt/LmnrpNKcNTABQATNI= github.com/juju/utils/v3 v3.0.0-20220130232349-cd7ecef0e94a/go.mod h1:LzwbbEN7buYjySp4nqnti6c6olSqRXUk6RkbSUUP1n8= github.com/juju/utils/v3 v3.0.0-20220202114721-338bb0530e89/go.mod h1:wf5w+8jyTh2IYnSX0sHnMJo4ZPwwuiBWn+xN3DkQg4k= -github.com/juju/utils/v3 v3.0.0-20220203023959-c3fbc78a33b0 h1:bn+2Adl1yWqYjm3KSFlFqsvfLg2eq+XNL7GGMYApdVw= github.com/juju/utils/v3 v3.0.0-20220203023959-c3fbc78a33b0/go.mod h1:8csUcj1VRkfjNIRzBFWzLFCMLwLqsRWvkmhfVAUwbC4= +github.com/juju/utils/v3 v3.0.0 h1:Gg3n63mGPbBuoXCo+EPJuMi44hGZfloI8nlCIebHu2Q= +github.com/juju/utils/v3 v3.0.0/go.mod h1:8csUcj1VRkfjNIRzBFWzLFCMLwLqsRWvkmhfVAUwbC4= github.com/juju/version v0.0.0-20161031051906-1f41e27e54f2/go.mod h1:kE8gK5X0CImdr7qpSKl3xB2PmpySSmfj7zVbkZFs81U= github.com/juju/version v0.0.0-20180108022336-b64dbd566305/go.mod h1:kE8gK5X0CImdr7qpSKl3xB2PmpySSmfj7zVbkZFs81U= github.com/juju/version v0.0.0-20191219164919-81c1be00b9a6 h1:nrqc9b4YKpKV4lPI3GPPFbo5FUuxkWxgZE2Z8O4lgaw= github.com/juju/version v0.0.0-20191219164919-81c1be00b9a6/go.mod h1:kE8gK5X0CImdr7qpSKl3xB2PmpySSmfj7zVbkZFs81U= github.com/juju/version/v2 v2.0.0-20211007103408-2e8da085dc23/go.mod h1:Ljlbryh9sYaUSGXucslAEDf0A2XUSGvDbHJgW8ps6nc= -github.com/juju/version/v2 v2.0.0-20220204124744-fc9915e3d935 h1:6YoyzXVW1XkqN86y2s/rz365Jm7EiAy39v2G5ikzvHU= -github.com/juju/version/v2 v2.0.0-20220204124744-fc9915e3d935/go.mod h1:ZeFjNy+UFEWJDDPdzW7Cm9NeU6dsViGaFYhXzycLQrw= +github.com/juju/version/v2 v2.0.0/go.mod h1:ZeFjNy+UFEWJDDPdzW7Cm9NeU6dsViGaFYhXzycLQrw= +github.com/juju/version/v2 v2.0.1 h1:4psP9XDv8qIbSdv3llCmcmBXe+wvm57BvYp2sG/i6zc= +github.com/juju/version/v2 v2.0.1/go.mod h1:OK+DKO9ve3fFCVUZGT8ZbUWU2TnZh914S6gMhiM2hXg= github.com/julienschmidt/httprouter v1.1.1-0.20151013225520-77a895ad01eb/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -94,12 +104,16 @@ github.com/mattn/go-isatty v0.0.0-20160806122752-66b8e73f3f5c/go.mod h1:M+lRXTBq github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= +github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/xdg-go/stringprep v1.0.2 h1:6iq84/ryjjeRmMJwxutI51F2GIPlP5BfTvXHeYjyhBc= github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= +github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= golang.org/x/crypto v0.0.0-20180214000028-650f4a345ab4/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -135,7 +149,6 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -148,9 +161,9 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v1 v1.0.0-20161222125816-442357a80af5/go.mod h1:u0ALmqvLRxLI95fkdCEWrE6mhWYZW1aMOJHp5YXLHTg= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/httprequest.v1 v1.1.1/go.mod h1:/CkavNL+g3qLOrpFHVrEx4NKepeqR4XTZWNj4sGGjz0= gopkg.in/mgo.v2 v2.0.0-20160818015218-f2b6f6c918c4/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= -gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 h1:VpOs+IwYnYBaFnrNAeB8UUWtL3vEUnzSCL1nVjPhqrw= gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637/go.mod h1:BHsqpu/nsuzkT5BpiH1EMZPLyqSMM8JbIavyFACoFNk= diff --git a/interface.go b/interface.go index 9865833..98b74d9 100644 --- a/interface.go +++ b/interface.go @@ -9,7 +9,7 @@ import ( "github.com/juju/errors" "github.com/juju/schema" - "github.com/juju/version" + "github.com/juju/version/v2" ) // Can't use "interface" as a type, so add an underscore. Yay. diff --git a/interface_test.go b/interface_test.go index 608d50a..6943c0c 100644 --- a/interface_test.go +++ b/interface_test.go @@ -9,7 +9,7 @@ import ( "github.com/juju/errors" "github.com/juju/testing" jc "github.com/juju/testing/checkers" - "github.com/juju/version" + "github.com/juju/version/v2" gc "gopkg.in/check.v1" ) diff --git a/interfaces.go b/interfaces.go index 12c1afb..dfc0c15 100644 --- a/interfaces.go +++ b/interfaces.go @@ -3,7 +3,10 @@ package gomaasapi -import "github.com/juju/collections/set" +import ( + "github.com/juju/collections/set" + "github.com/juju/version/v2" +) const ( // Capability constants. @@ -21,7 +24,7 @@ const ( type Controller interface { // APIVersionInfo returns the version and subversion strings for the MAAS // controller. - APIVersionInfo() (string, string, error) + APIVersionInfo() (version.Number, string, error) // Capabilities returns a set of capabilities as defined by the string // constants. diff --git a/link.go b/link.go index 9e930e1..b1e9993 100644 --- a/link.go +++ b/link.go @@ -6,7 +6,7 @@ package gomaasapi import ( "github.com/juju/errors" "github.com/juju/schema" - "github.com/juju/version" + "github.com/juju/version/v2" ) type link struct { diff --git a/link_test.go b/link_test.go index bb8f5cd..88573f3 100644 --- a/link_test.go +++ b/link_test.go @@ -5,7 +5,7 @@ package gomaasapi import ( jc "github.com/juju/testing/checkers" - "github.com/juju/version" + "github.com/juju/version/v2" gc "gopkg.in/check.v1" ) diff --git a/machine.go b/machine.go index 6914eb8..304a29b 100644 --- a/machine.go +++ b/machine.go @@ -10,7 +10,7 @@ import ( "github.com/juju/errors" "github.com/juju/schema" - "github.com/juju/version" + "github.com/juju/version/v2" ) type machine struct { @@ -266,19 +266,30 @@ func (m *machine) Devices(args DevicesArgs) ([]Device, error) { // method. type StartArgs struct { // UserData needs to be Base64 encoded user data for cloud-init. - UserData string - DistroSeries string - Kernel string - Comment string + UserData string + Base Base + Kernel string + Comment string } // Start implements Machine. func (m *machine) Start(args StartArgs) error { params := NewURLParams() params.MaybeAdd("user_data", args.UserData) - params.MaybeAdd("distro_series", args.DistroSeries) params.MaybeAdd("hwe_kernel", args.Kernel) params.MaybeAdd("comment", args.Comment) + + var distroVersion string + if m.controller.maasVersion.Compare(VersionDeploySupportsBases) > 0 { + distroVersion = args.Base.String() + } else { + var err error + distroVersion, err = args.Base.toSeries() + if err != nil { + return errors.Trace(err) + } + } + params.MaybeAdd("distro_series", distroVersion) result, err := m.controller.post(m.resourceURI, "deploy", params.Values) if err != nil { if svrErr, ok := errors.Cause(err).(ServerError); ok { diff --git a/machine_test.go b/machine_test.go index 56e5937..e98aaec 100644 --- a/machine_test.go +++ b/machine_test.go @@ -10,7 +10,7 @@ import ( "github.com/juju/errors" "github.com/juju/testing" jc "github.com/juju/testing/checkers" - "github.com/juju/version" + "github.com/juju/version/v2" gc "gopkg.in/check.v1" ) diff --git a/partition.go b/partition.go index 26401e5..63d6524 100644 --- a/partition.go +++ b/partition.go @@ -6,7 +6,7 @@ package gomaasapi import ( "github.com/juju/errors" "github.com/juju/schema" - "github.com/juju/version" + "github.com/juju/version/v2" ) type partition struct { diff --git a/partition_test.go b/partition_test.go index cf83e5f..78c4bb2 100644 --- a/partition_test.go +++ b/partition_test.go @@ -5,7 +5,7 @@ package gomaasapi import ( jc "github.com/juju/testing/checkers" - "github.com/juju/version" + "github.com/juju/version/v2" gc "gopkg.in/check.v1" ) diff --git a/pool.go b/pool.go index f39e015..608e460 100644 --- a/pool.go +++ b/pool.go @@ -6,7 +6,7 @@ package gomaasapi import ( "github.com/juju/errors" "github.com/juju/schema" - "github.com/juju/version" + "github.com/juju/version/v2" ) type pool struct { diff --git a/pool_test.go b/pool_test.go index 7732304..30b18d2 100644 --- a/pool_test.go +++ b/pool_test.go @@ -5,7 +5,7 @@ package gomaasapi import ( jc "github.com/juju/testing/checkers" - "github.com/juju/version" + "github.com/juju/version/v2" gc "gopkg.in/check.v1" ) diff --git a/space.go b/space.go index 5b8b8cf..0d7b605 100644 --- a/space.go +++ b/space.go @@ -6,7 +6,7 @@ package gomaasapi import ( "github.com/juju/errors" "github.com/juju/schema" - "github.com/juju/version" + "github.com/juju/version/v2" ) type space struct { diff --git a/space_test.go b/space_test.go index 38d7cbc..e2aacd2 100644 --- a/space_test.go +++ b/space_test.go @@ -5,7 +5,7 @@ package gomaasapi import ( jc "github.com/juju/testing/checkers" - "github.com/juju/version" + "github.com/juju/version/v2" gc "gopkg.in/check.v1" ) diff --git a/staticroute.go b/staticroute.go index bef4d4b..f6fde25 100644 --- a/staticroute.go +++ b/staticroute.go @@ -6,7 +6,7 @@ package gomaasapi import ( "github.com/juju/errors" "github.com/juju/schema" - "github.com/juju/version" + "github.com/juju/version/v2" ) type staticRoute struct { diff --git a/staticroute_test.go b/staticroute_test.go index dc92d8b..2916411 100644 --- a/staticroute_test.go +++ b/staticroute_test.go @@ -5,7 +5,7 @@ package gomaasapi import ( jc "github.com/juju/testing/checkers" - "github.com/juju/version" + "github.com/juju/version/v2" gc "gopkg.in/check.v1" ) diff --git a/subnet.go b/subnet.go index f509ccd..89bb4ca 100644 --- a/subnet.go +++ b/subnet.go @@ -6,7 +6,7 @@ package gomaasapi import ( "github.com/juju/errors" "github.com/juju/schema" - "github.com/juju/version" + "github.com/juju/version/v2" ) type subnet struct { diff --git a/subnet_test.go b/subnet_test.go index c075583..b67ff15 100644 --- a/subnet_test.go +++ b/subnet_test.go @@ -5,7 +5,7 @@ package gomaasapi import ( jc "github.com/juju/testing/checkers" - "github.com/juju/version" + "github.com/juju/version/v2" gc "gopkg.in/check.v1" ) diff --git a/tags.go b/tags.go index 6678cbe..f48ae94 100644 --- a/tags.go +++ b/tags.go @@ -6,7 +6,7 @@ package gomaasapi import ( "github.com/juju/errors" "github.com/juju/schema" - "github.com/juju/version" + "github.com/juju/version/v2" ) type tag struct { diff --git a/vlan.go b/vlan.go index c509d42..9690fb3 100644 --- a/vlan.go +++ b/vlan.go @@ -6,7 +6,7 @@ package gomaasapi import ( "github.com/juju/errors" "github.com/juju/schema" - "github.com/juju/version" + "github.com/juju/version/v2" ) type vlan struct { diff --git a/vlan_test.go b/vlan_test.go index 8de35bb..e2d7846 100644 --- a/vlan_test.go +++ b/vlan_test.go @@ -5,7 +5,7 @@ package gomaasapi import ( jc "github.com/juju/testing/checkers" - "github.com/juju/version" + "github.com/juju/version/v2" gc "gopkg.in/check.v1" ) diff --git a/zone.go b/zone.go index 6f10cb4..cbacb91 100644 --- a/zone.go +++ b/zone.go @@ -6,7 +6,7 @@ package gomaasapi import ( "github.com/juju/errors" "github.com/juju/schema" - "github.com/juju/version" + "github.com/juju/version/v2" ) type zone struct { diff --git a/zone_test.go b/zone_test.go index ba3d04d..216037b 100644 --- a/zone_test.go +++ b/zone_test.go @@ -5,7 +5,7 @@ package gomaasapi import ( jc "github.com/juju/testing/checkers" - "github.com/juju/version" + "github.com/juju/version/v2" gc "gopkg.in/check.v1" )