diff --git a/api/facadeversions.go b/api/facadeversions.go index 16d3ba22b3f..6a534f44e44 100644 --- a/api/facadeversions.go +++ b/api/facadeversions.go @@ -127,7 +127,7 @@ var facadeVersions = map[string][]int{ "Subnets": {5}, "Undertaker": {1}, "UnitAssigner": {1}, - "Uniter": {18}, + "Uniter": {18, 19}, "Upgrader": {1}, "UpgradeSeries": {3}, "UpgradeSteps": {2}, diff --git a/apiserver/facades/agent/uniter/register.go b/apiserver/facades/agent/uniter/register.go index 069f2cd777a..a6ed822e6c1 100644 --- a/apiserver/facades/agent/uniter/register.go +++ b/apiserver/facades/agent/uniter/register.go @@ -20,10 +20,21 @@ import ( // Register is called to expose a package of facades onto a given registry. func Register(registry facade.FacadeRegistry) { registry.MustRegister("Uniter", 18, func(ctx facade.Context) (facade.Facade, error) { + return newUniterAPIv18(ctx) + }, reflect.TypeOf((*UniterAPIv18)(nil))) + registry.MustRegister("Uniter", 19, func(ctx facade.Context) (facade.Facade, error) { return newUniterAPI(ctx) }, reflect.TypeOf((*UniterAPI)(nil))) } +func newUniterAPIv18(context facade.Context) (*UniterAPIv18, error) { + api, err := newUniterAPI(context) + if err != nil { + return nil, errors.Trace(err) + } + return &UniterAPIv18{*api}, nil +} + // newUniterAPI creates a new instance of the core Uniter API. func newUniterAPI(context facade.Context) (*UniterAPI, error) { authorizer := context.Auth() diff --git a/apiserver/facades/agent/uniter/uniter.go b/apiserver/facades/agent/uniter/uniter.go index bcaf7796c3a..34a04e72907 100644 --- a/apiserver/facades/agent/uniter/uniter.go +++ b/apiserver/facades/agent/uniter/uniter.go @@ -38,9 +38,6 @@ import ( var logger = loggo.GetLogger("juju.apiserver.uniter") -// TODO (manadart 2020-10-21): Remove the ModelUUID method -// from the next version of this facade. - // UniterAPI implements the latest version (v18) of the Uniter API. type UniterAPI struct { *common.LifeGetter @@ -81,6 +78,13 @@ type UniterAPI struct { cloudSpecer cloudspec.CloudSpecer } +// UniterAPIv18 Implements version 18 of the uniter API, which includes methods +// ModelUUID and OpenedApplicationPortRangesByEndpoint that were removed from +// later versions. +type UniterAPIv18 struct { + UniterAPI +} + // OpenedMachinePortRangesByEndpoint returns the port ranges opened by each // unit on the provided machines grouped by application endpoint. func (u *UniterAPI) OpenedMachinePortRangesByEndpoint(args params.Entities) (params.OpenPortRangesByEndpointResults, error) { @@ -179,7 +183,7 @@ func (u *UniterAPI) OpenedPortRangesByEndpoint() (params.OpenPortRangesByEndpoin } // OpenedApplicationPortRangesByEndpoint returns the port ranges opened by each application. -func (u *UniterAPI) OpenedApplicationPortRangesByEndpoint(entity params.Entity) (params.ApplicationOpenedPortsResults, error) { +func (u *UniterAPIv18) OpenedApplicationPortRangesByEndpoint(entity params.Entity) (params.ApplicationOpenedPortsResults, error) { result := params.ApplicationOpenedPortsResults{ Results: make([]params.ApplicationOpenedPortsResult, 1), } @@ -758,8 +762,7 @@ func (u *UniterAPI) SetWorkloadVersion(args params.EntityWorkloadVersions) (para // ModelUUID returns the model UUID that this unit resides in. // It is implemented here directly as a result of removing it from // embedded APIAddresser *without* bumping the facade version. -// It should be blanked when this facade version is next incremented. -func (u *UniterAPI) ModelUUID() params.StringResult { +func (u *UniterAPIv18) ModelUUID() params.StringResult { return params.StringResult{Result: u.m.UUID()} } diff --git a/apiserver/facades/agent/uniter/uniter_test.go b/apiserver/facades/agent/uniter/uniter_test.go index 8d600a46a51..68f09be50ee 100644 --- a/apiserver/facades/agent/uniter/uniter_test.go +++ b/apiserver/facades/agent/uniter/uniter_test.go @@ -3739,7 +3739,8 @@ func (s *uniterSuite) TestOpenedApplicationPortRangesByEndpoint(c *gc.C) { uniterAPI := s.newUniterAPI(c, st, s.authorizer) - result, err := uniterAPI.OpenedApplicationPortRangesByEndpoint(arg) + api := &uniter.UniterAPIv18{UniterAPI: *uniterAPI} + result, err := api.OpenedApplicationPortRangesByEndpoint(arg) c.Assert(err, jc.ErrorIsNil) c.Assert(result, gc.DeepEquals, params.ApplicationOpenedPortsResults{ Results: []params.ApplicationOpenedPortsResult{ diff --git a/apiserver/facades/schema.json b/apiserver/facades/schema.json index e685833c5bc..cf02cdeb4b3 100644 --- a/apiserver/facades/schema.json +++ b/apiserver/facades/schema.json @@ -46229,7 +46229,7 @@ { "Name": "Uniter", "Description": "UniterAPI implements the latest version (v18) of the Uniter API.", - "Version": 18, + "Version": 19, "AvailableTo": [ "controller-machine-agent", "machine-agent", @@ -46757,15 +46757,6 @@ }, "description": "ModelConfig returns the current model's configuration." }, - "ModelUUID": { - "type": "object", - "properties": { - "Result": { - "$ref": "#/definitions/StringResult" - } - }, - "description": "ModelUUID returns the model UUID that this unit resides in.\nIt is implemented here directly as a result of removing it from\nembedded APIAddresser *without* bumping the facade version.\nIt should be blanked when this facade version is next incremented." - }, "NetworkInfo": { "type": "object", "properties": { @@ -46778,18 +46769,6 @@ }, "description": "NetworkInfo returns network interfaces/addresses for specified bindings." }, - "OpenedApplicationPortRangesByEndpoint": { - "type": "object", - "properties": { - "Params": { - "$ref": "#/definitions/Entity" - }, - "Result": { - "$ref": "#/definitions/ApplicationOpenedPortsResults" - } - }, - "description": "OpenedApplicationPortRangesByEndpoint returns the port ranges opened by each application." - }, "OpenedMachinePortRangesByEndpoint": { "type": "object", "properties": { @@ -47689,58 +47668,6 @@ "scope" ] }, - "ApplicationOpenedPorts": { - "type": "object", - "properties": { - "endpoint": { - "type": "string" - }, - "port-ranges": { - "type": "array", - "items": { - "$ref": "#/definitions/PortRange" - } - } - }, - "additionalProperties": false, - "required": [ - "endpoint", - "port-ranges" - ] - }, - "ApplicationOpenedPortsResult": { - "type": "object", - "properties": { - "application-port-ranges": { - "type": "array", - "items": { - "$ref": "#/definitions/ApplicationOpenedPorts" - } - }, - "error": { - "$ref": "#/definitions/Error" - } - }, - "additionalProperties": false, - "required": [ - "application-port-ranges" - ] - }, - "ApplicationOpenedPortsResults": { - "type": "object", - "properties": { - "results": { - "type": "array", - "items": { - "$ref": "#/definitions/ApplicationOpenedPortsResult" - } - } - }, - "additionalProperties": false, - "required": [ - "results" - ] - }, "ApplicationStatusResult": { "type": "object", "properties": {