diff --git a/api/client.go b/api/client.go index f7c41f55fc3..a0c5ada069f 100644 --- a/api/client.go +++ b/api/client.go @@ -423,7 +423,7 @@ func (c *Client) UploadCharm(curl *charm.URL, content io.ReadSeeker) (*charm.URL } func (c *Client) validateCharmVersion(ch charm.Charm) error { - minver := jujuversion.ToVersion2(ch.Meta().MinJujuVersion) + minver := ch.Meta().MinJujuVersion if minver != version.Zero { agentver, err := c.AgentVersion() if err != nil { diff --git a/api/client_test.go b/api/client_test.go index 60aae47775d..75b23af64bd 100644 --- a/api/client_test.go +++ b/api/client_test.go @@ -391,7 +391,7 @@ func testMinVer(client *api.Client, t minverTest, c *gc.C) { curl := charm.MustParseURL( fmt.Sprintf("local:quantal/%s-%d", charmArchive.Meta().Name, charmArchive.Revision()), ) - charmArchive.Meta().MinJujuVersion = jujuversion.ToVersion1(charmMinVer) + charmArchive.Meta().MinJujuVersion = charmMinVer _, err := client.AddLocalCharm(curl, charmArchive, t.force) diff --git a/api/common/charms/common.go b/api/common/charms/common.go index e633cfcea4d..b3ef160f2e0 100644 --- a/api/common/charms/common.go +++ b/api/common/charms/common.go @@ -10,7 +10,7 @@ import ( "github.com/juju/errors" "github.com/juju/systems" "github.com/juju/systems/channel" - "github.com/juju/version" + "github.com/juju/version/v2" "github.com/juju/juju/api/base" "github.com/juju/juju/apiserver/params" diff --git a/api/common/charms/common_test.go b/api/common/charms/common_test.go index 08b71613d32..a3b999afa63 100644 --- a/api/common/charms/common_test.go +++ b/api/common/charms/common_test.go @@ -9,7 +9,7 @@ import ( "github.com/juju/charm/v9/resource" "github.com/juju/systems" "github.com/juju/systems/channel" - "github.com/juju/version" + "github.com/juju/version/v2" gc "gopkg.in/check.v1" basemocks "github.com/juju/juju/api/base/mocks" diff --git a/apiserver/dashboard.go b/apiserver/dashboard.go index 44261d8476a..0b14179e43c 100644 --- a/apiserver/dashboard.go +++ b/apiserver/dashboard.go @@ -19,7 +19,7 @@ import ( "github.com/gorilla/handlers" "github.com/juju/errors" - "github.com/juju/version" + "github.com/juju/version/v2" agenttools "github.com/juju/juju/agent/tools" "github.com/juju/juju/apiserver/common/apihttp" diff --git a/apiserver/dashboard_test.go b/apiserver/dashboard_test.go index 344c080922b..a35fc4657d8 100644 --- a/apiserver/dashboard_test.go +++ b/apiserver/dashboard_test.go @@ -20,7 +20,7 @@ import ( "strings" jc "github.com/juju/testing/checkers" - "github.com/juju/version" + "github.com/juju/version/v2" gc "gopkg.in/check.v1" agenttools "github.com/juju/juju/agent/tools" diff --git a/apiserver/facades/client/application/application.go b/apiserver/facades/client/application/application.go index 063823528f9..845f3523f69 100644 --- a/apiserver/facades/client/application/application.go +++ b/apiserver/facades/client/application/application.go @@ -407,8 +407,7 @@ func caasPrecheck( } // For older charms, operator-storage model config is mandatory. - minver := ch.Meta().MinJujuVersion - if k8s.RequireOperatorStorage(jujuversion.ToVersion2(minver)) { + if k8s.RequireOperatorStorage(ch.Meta().MinJujuVersion) { storageClassName, _ := cfg.AllAttrs()[k8sconstants.OperatorStorageKey].(string) if storageClassName == "" { return errors.New( @@ -486,8 +485,7 @@ func deployApplication( return errors.Trace(err) } - minver := ch.Meta().MinJujuVersion - if err := jujuversion.CheckJujuMinVersion(jujuversion.ToVersion2(minver), jujuversion.Current); err != nil { + if err := jujuversion.CheckJujuMinVersion(ch.Meta().MinJujuVersion, jujuversion.Current); err != nil { return errors.Trace(err) } diff --git a/apiserver/facades/client/application/application_unit_test.go b/apiserver/facades/client/application/application_unit_test.go index bc20d62ef7e..2f220254a17 100644 --- a/apiserver/facades/client/application/application_unit_test.go +++ b/apiserver/facades/client/application/application_unit_test.go @@ -1064,7 +1064,7 @@ func (s *ApplicationSuite) TestDeployCAASModelCharmNeedsNoOperatorStorage(c *gc. s.PatchValue(&jujuversion.Current, version.MustParse("2.8-beta1")) s.backend.charm = &mockCharm{ meta: &charm.Meta{ - MinJujuVersion: jujuversion.ToVersion1(version.MustParse("2.8.0")), + MinJujuVersion: version.MustParse("2.8.0"), }, } diff --git a/apiserver/facades/client/application/charmstore.go b/apiserver/facades/client/application/charmstore.go index 5001418fe3b..30d8c5f5c67 100644 --- a/apiserver/facades/client/application/charmstore.go +++ b/apiserver/facades/client/application/charmstore.go @@ -154,8 +154,7 @@ func AddCharmWithAuthorizationAndRepo(st State, args params.AddCharmWithAuthoriz type versionValidator struct{} func (versionValidator) Validate(meta *charm.Meta) error { - minver := meta.MinJujuVersion - return jujuversion.CheckJujuMinVersion(jujuversion.ToVersion2(minver), jujuversion.Current) + return jujuversion.CheckJujuMinVersion(meta.MinJujuVersion, jujuversion.Current) } type charmStateShim struct { diff --git a/apiserver/facades/client/charms/client.go b/apiserver/facades/client/charms/client.go index f5c8d6475f3..68170acaf31 100644 --- a/apiserver/facades/client/charms/client.go +++ b/apiserver/facades/client/charms/client.go @@ -424,8 +424,7 @@ func (a *API) addCharmWithAuthorization(args params.AddCharmWithAuth) (params.Ch type versionValidator struct{} func (versionValidator) Validate(meta *charm.Meta) error { - minver := meta.MinJujuVersion - return jujuversion.CheckJujuMinVersion(jujuversion.ToVersion2(minver), jujuversion.Current) + return jujuversion.CheckJujuMinVersion(meta.MinJujuVersion, jujuversion.Current) } // CharmArchive is the data that needs to be stored for a charm archive in diff --git a/apiserver/facades/client/machinemanager/upgrade_series.go b/apiserver/facades/client/machinemanager/upgrade_series.go index 0922cbafd43..23e72b6354b 100644 --- a/apiserver/facades/client/machinemanager/upgrade_series.go +++ b/apiserver/facades/client/machinemanager/upgrade_series.go @@ -4,6 +4,9 @@ package machinemanager import ( + "context" + "fmt" + "github.com/juju/charm/v9" "github.com/juju/collections/set" "github.com/juju/errors" diff --git a/apiserver/facades/controller/caasoperatorprovisioner/provisioner.go b/apiserver/facades/controller/caasoperatorprovisioner/provisioner.go index d2038985934..ccf9bf125d4 100644 --- a/apiserver/facades/controller/caasoperatorprovisioner/provisioner.go +++ b/apiserver/facades/controller/caasoperatorprovisioner/provisioner.go @@ -190,8 +190,7 @@ func (a *API) OperatorProvisioningInfo(args params.Entities) (params.OperatorPro result.Results[i].Error = apiservererrors.ServerError(err) continue } - minVer := ch.Meta().MinJujuVersion - needStorage := provider.RequireOperatorStorage(version.ToVersion2(minVer)) + needStorage := provider.RequireOperatorStorage(ch.Meta().MinJujuVersion) logger.Debugf("application %s has min-juju-version=%v, so charm storage is %v", appName.String(), ch.Meta().MinJujuVersion, needStorage) result.Results[i] = oneProvisioningInfo(needStorage) diff --git a/apiserver/facades/controller/caasoperatorprovisioner/provisioner_test.go b/apiserver/facades/controller/caasoperatorprovisioner/provisioner_test.go index 52592f3284a..081bb76dc71 100644 --- a/apiserver/facades/controller/caasoperatorprovisioner/provisioner_test.go +++ b/apiserver/facades/controller/caasoperatorprovisioner/provisioner_test.go @@ -178,7 +178,7 @@ func (s *CAASProvisionerSuite) TestOperatorProvisioningInfoNoStorage(c *gc.C) { s.st.operatorRepo = "somerepo" minVers := version.MustParse("2.8.0") s.st.app = &mockApplication{ - charm: &mockCharm{meta: &charm.Meta{MinJujuVersion: jujuversion.ToVersion1(minVers)}}, + charm: &mockCharm{meta: &charm.Meta{MinJujuVersion: minVers}}, } result, err := s.api.OperatorProvisioningInfo(params.Entities{Entities: []params.Entity{{"application-gitlab"}}}) c.Assert(err, jc.ErrorIsNil) @@ -199,7 +199,7 @@ func (s *CAASProvisionerSuite) TestOperatorProvisioningInfoNoStoragePool(c *gc.C s.st.operatorRepo = "somerepo" minVers := version.MustParse("2.7.0") s.st.app = &mockApplication{ - charm: &mockCharm{meta: &charm.Meta{MinJujuVersion: jujuversion.ToVersion1(minVers)}}, + charm: &mockCharm{meta: &charm.Meta{MinJujuVersion: minVers}}, } result, err := s.api.OperatorProvisioningInfo(params.Entities{Entities: []params.Entity{{"application-gitlab"}}}) c.Assert(err, jc.ErrorIsNil) diff --git a/caas/ecs/environ.go b/caas/ecs/environ.go index 56ef2d37faa..0901f8e7196 100644 --- a/caas/ecs/environ.go +++ b/caas/ecs/environ.go @@ -11,14 +11,14 @@ import ( jujuclock "github.com/juju/clock" "github.com/juju/errors" "github.com/juju/names/v4" - "github.com/juju/version" + "github.com/juju/version/v2" "github.com/juju/juju/caas" "github.com/juju/juju/core/annotations" "github.com/juju/juju/core/application" "github.com/juju/juju/core/watcher" "github.com/juju/juju/environs" - cloudspec "github.com/juju/juju/environs/cloudspec" + "github.com/juju/juju/environs/cloudspec" "github.com/juju/juju/environs/config" envcontext "github.com/juju/juju/environs/context" ) diff --git a/caas/kubernetes/provider/cloud_test.go b/caas/kubernetes/provider/cloud_test.go index 471e9ac29ed..aee83745605 100644 --- a/caas/kubernetes/provider/cloud_test.go +++ b/caas/kubernetes/provider/cloud_test.go @@ -15,8 +15,8 @@ import ( gc "gopkg.in/check.v1" "github.com/juju/juju/caas" - k8scloud "github.com/juju/juju/caas/kubernetes/cloud" k8s "github.com/juju/juju/caas/kubernetes" + k8scloud "github.com/juju/juju/caas/kubernetes/cloud" "github.com/juju/juju/caas/kubernetes/provider" "github.com/juju/juju/cloud" jujucloud "github.com/juju/juju/cloud" @@ -168,7 +168,7 @@ func (s *cloudSuite) TestFinalizeCloudMicrok8sAlreadyStorage(c *gc.C) { c.Assert(cloud, jc.DeepEquals, jujucloud.Cloud{ Name: k8s.K8sCloudMicrok8s, Type: jujucloud.CloudTypeKubernetes, - AuthTypes: k8scloud.SupportedAuthTypes(),, + AuthTypes: k8scloud.SupportedAuthTypes(), CACertificates: []string{""}, Endpoint: "http://1.1.1.1:8080", HostCloudRegion: fmt.Sprintf("%s/%s", k8s.K8sCloudMicrok8s, k8s.Microk8sRegion), diff --git a/core/charm/strategies_test.go b/core/charm/strategies_test.go index 7ece3ddf33c..b3615ce9cdc 100644 --- a/core/charm/strategies_test.go +++ b/core/charm/strategies_test.go @@ -13,7 +13,7 @@ import ( "github.com/juju/charm/v9" "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 3cb25ee9ac6..d13c11fd92d 100644 --- a/go.mod +++ b/go.mod @@ -36,7 +36,7 @@ require ( github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a github.com/juju/blobstore/v2 v2.0.0-20210302045357-edd2b24570b7 github.com/juju/bundlechanges/v5 v5.0.0-20210224113052-f5fb3bbb6c25 - github.com/juju/charm/v9 v9.0.0-20210309091641-7e600f16b30f + github.com/juju/charm/v9 v9.0.0-20210324234318-1204b46e47ee github.com/juju/charmrepo/v7 v7.0.0-20210309083437-272762c450b9 github.com/juju/clock v0.0.0-20190205081909-9c5c9712527c github.com/juju/cmd v0.0.0-20200108104440-8e43f3faa5c9 @@ -74,7 +74,6 @@ require ( github.com/juju/txn v0.0.0-20210302043154-251cea9e140a github.com/juju/utils v0.0.0-20200604140309-9d78121a29e0 github.com/juju/utils/v2 v2.0.0-20200923005554-4646bfea2ef1 - github.com/juju/version v0.0.0-20191219164919-81c1be00b9a6 github.com/juju/version/v2 v2.0.0-20210319015800-dcfac8f4f057 github.com/juju/webbrowser v1.0.0 github.com/juju/worker/v2 v2.0.0-20200916234526-d6e694f1c54a diff --git a/go.sum b/go.sum index ef6d0846c37..36921af0e22 100644 --- a/go.sum +++ b/go.sum @@ -397,8 +397,8 @@ github.com/juju/charm/v7 v7.0.0-20200625165032-ef717232a815/go.mod h1:gcqIN/pHfz github.com/juju/charm/v8 v8.0.0-20200925053015-07d39c0154ac/go.mod h1:QZwgFXYuJI/PZPnS5feY4/7Ue2v1zm1YtT8rsXHeWCg= github.com/juju/charm/v9 v9.0.0-20210125110411-23fabd67cb4c/go.mod h1:ffLfwuA4E426HlTtqgMvKZdBAWXOwbgeeHye/1ITTLc= github.com/juju/charm/v9 v9.0.0-20210304052111-31c24cedd783/go.mod h1:82L0Bk5mPMnoGOtP9hsxDumxYWKvjsrFjKiYvte6gP8= -github.com/juju/charm/v9 v9.0.0-20210309091641-7e600f16b30f h1:zHUKNECfsOIRmQlAYwxj/Rvealq8Jkypy316V4cTag0= -github.com/juju/charm/v9 v9.0.0-20210309091641-7e600f16b30f/go.mod h1:82L0Bk5mPMnoGOtP9hsxDumxYWKvjsrFjKiYvte6gP8= +github.com/juju/charm/v9 v9.0.0-20210324234318-1204b46e47ee h1:Sa+juB94sYHtCPAaEQRrckf8xZfLzE+Mhn+dSv4wrxs= +github.com/juju/charm/v9 v9.0.0-20210324234318-1204b46e47ee/go.mod h1:iMgXKAsiVw2Qd5LvT7GHzJiPpC7V4PacaD3LdAjTmuE= github.com/juju/charmrepo/v5 v5.0.0-20200424225329-cddcb4fdcd09/go.mod h1:KJGLR+Nx+PY2hw4EBNAjBWQacWlnxv1oVan1kJ9MlLM= github.com/juju/charmrepo/v5 v5.0.0-20200626080438-30e3069e6e8e/go.mod h1:cnwzYYTH1gV7V4ywqBix21av9LhFmdwbFEyE9CwpJ0s= github.com/juju/charmrepo/v7 v7.0.0-20210125112315-0c95be42cafc/go.mod h1:R9PTZ6VsweDsg/J2skiWj5ulVpxYPj7JW5IyQxBA4UU= diff --git a/state/charm.go b/state/charm.go index e33ca4a3178..6a97a9143e9 100644 --- a/state/charm.go +++ b/state/charm.go @@ -678,8 +678,7 @@ func (st *State) AddCharm(info CharmInfo) (stch *Charm, err error) { charms, closer := st.db().GetCollection(charmsC) defer closer() - minVer := info.Charm.Meta().MinJujuVersion - if err := jujuversion.CheckJujuMinVersion(jujuversion.ToVersion2(minVer), jujuversion.Current); err != nil { + if err := jujuversion.CheckJujuMinVersion(info.Charm.Meta().MinJujuVersion, jujuversion.Current); err != nil { return nil, errors.Trace(err) } model, err := st.Model() diff --git a/state/dashboard.go b/state/dashboard.go index be579776580..0b6d1c65add 100644 --- a/state/dashboard.go +++ b/state/dashboard.go @@ -7,7 +7,7 @@ import ( "github.com/juju/errors" "github.com/juju/mgo/v2" "github.com/juju/mgo/v2/bson" - "github.com/juju/version" + "github.com/juju/version/v2" ) // dashboardSettingsDoc represents the Juju Dashboard settings in MongoDB. diff --git a/state/state.go b/state/state.go index 2f6e41c0488..8a1e6d71394 100644 --- a/state/state.go +++ b/state/state.go @@ -1038,8 +1038,7 @@ func (st *State) AddApplication(args AddApplicationArgs) (_ *Application, err er return nil, errors.Errorf("AttachStorage is non-empty but NumUnits is %d, must be 1", args.NumUnits) } - minver := args.Charm.Meta().MinJujuVersion - if err := jujuversion.CheckJujuMinVersion(jujuversion.ToVersion2(minver), jujuversion.Current); err != nil { + if err := jujuversion.CheckJujuMinVersion(args.Charm.Meta().MinJujuVersion, jujuversion.Current); err != nil { return nil, errors.Trace(err) } diff --git a/version/version.go b/version/version.go index 348b773e798..b1452fd5e46 100644 --- a/version/version.go +++ b/version/version.go @@ -15,7 +15,6 @@ import ( "strings" "github.com/juju/errors" - semversion1 "github.com/juju/version" semversion "github.com/juju/version/v2" ) @@ -31,7 +30,7 @@ const UserAgentVersion = "Juju/" + version const ( // TreeStateDirty when the build was made with a dirty checkout. TreeStateDirty = "dirty" - // TreeStateClean when the build was made with a clean checkout. + // TreeStateClean when the build was made with a clean checkout.kubernetes/provider/cloud_test.go TreeStateClean = "clean" // TreeStateArchive when the build was made outside of a git checkout. TreeStateArchive = "archive" @@ -133,31 +132,3 @@ func IsMinVersionError(err error) bool { _, ok := errors.Cause(err).(minJujuVersionErr) return ok } - -// TODO(juju3) - remove these once juju/charm and juju/description -// have been updated to use juju/version/v2 - -// The following are for compatibility with upstream repos that have -// not yet been updated to use juju/version/v2. - -// ToVersion2 converts version number v1 to v2. -func ToVersion2(v semversion1.Number) semversion.Number { - return semversion.Number{ - Major: v.Major, - Minor: v.Minor, - Tag: v.Tag, - Patch: v.Patch, - Build: v.Build, - } -} - -// ToVersion1 converts version number v2 to v1. -func ToVersion1(v semversion.Number) semversion1.Number { - return semversion1.Number{ - Major: v.Major, - Minor: v.Minor, - Tag: v.Tag, - Patch: v.Patch, - Build: v.Build, - } -}