Skip to content

Commit

Permalink
Adds version 19 of the uniter facades, which does not include unused
Browse files Browse the repository at this point in the history
methods ModelUUID and OpenedApplicationPortRangesByEndpoint.
  • Loading branch information
manadart committed Oct 13, 2023
1 parent 465ba2f commit 72eb542
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 82 deletions.
2 changes: 1 addition & 1 deletion api/facadeversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
11 changes: 11 additions & 0 deletions apiserver/facades/agent/uniter/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
15 changes: 9 additions & 6 deletions apiserver/facades/agent/uniter/uniter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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),
}
Expand Down Expand Up @@ -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()}
}

Expand Down
3 changes: 2 additions & 1 deletion apiserver/facades/agent/uniter/uniter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
75 changes: 1 addition & 74 deletions apiserver/facades/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Expand All @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down

0 comments on commit 72eb542

Please sign in to comment.