Skip to content

Commit

Permalink
Make the facade names for payloads and resources consistent.
Browse files Browse the repository at this point in the history
  • Loading branch information
howbazaar committed Jun 30, 2016
1 parent d083fd1 commit 0025fd6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
14 changes: 8 additions & 6 deletions component/all/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ import (
"github.com/juju/juju/worker/uniter/runner/jujuc"
)

const payloadsHookContextFacade = payload.ComponentName + "-hook-context"
const facadeName = "Payloads"

const payloadsHookContextFacade = facadeName + "HookContext"

type payloads struct{}

Expand Down Expand Up @@ -61,11 +63,11 @@ func (c payloads) registerPublicFacade() {

const version = 1
common.RegisterStandardFacade(
payload.ComponentName,
facadeName,
version,
c.newPublicFacade,
)
api.RegisterFacadeVersion(payload.ComponentName, version)
api.RegisterFacadeVersion(facadeName, version)
}

type facadeCaller struct {
Expand All @@ -82,7 +84,7 @@ func (payloads) newListAPIClient(cmd *status.ListCommand) (status.ListAPI, error
if err != nil {
return nil, errors.Trace(err)
}
caller := base.NewFacadeCallerForVersion(apiCaller, payload.ComponentName, 1)
caller := base.NewFacadeCallerForVersion(apiCaller, facadeName, 1)

listAPI := client.NewPublicClient(&facadeCaller{
FacadeCaller: caller,
Expand Down Expand Up @@ -123,7 +125,7 @@ func (c payloads) registerHookContext() {
}

func (payloads) newUnitFacadeClient(caller base.APICaller) context.APIClient {
facadeCaller := base.NewFacadeCallerForVersion(caller, payloadsHookContextFacade, 0)
facadeCaller := base.NewFacadeCallerForVersion(caller, payloadsHookContextFacade, 1)
return internalclient.NewUnitFacadeClient(facadeCaller)
}

Expand All @@ -136,7 +138,7 @@ func (payloads) newHookContextFacade(st *state.State, unit *state.Unit) (interfa
}

func (c payloads) registerHookContextFacade() {
const version = 0
const version = 1
common.RegisterHookContextFacade(
payloadsHookContextFacade,
version,
Expand Down
4 changes: 2 additions & 2 deletions component/all/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ func (r resources) registerPublicFacade() {
}

common.RegisterStandardFacade(
resource.ComponentName,
resource.FacadeName,
server.Version,
resourceadapters.NewPublicFacade,
)
coreapi.RegisterFacadeVersion(resource.ComponentName, server.Version)
coreapi.RegisterFacadeVersion(resource.FacadeName, server.Version)

common.RegisterAPIModelEndpoint(api.HTTPEndpointPattern, apihttp.HandlerSpec{
Constraints: apihttp.HandlerConstraints{
Expand Down
3 changes: 3 additions & 0 deletions resource/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ package resource

// ComponentName is the name of the Juju component for resource management.
const ComponentName = "resources"

// FacadeName is the name of the api server facade.
const FacadeName = "Resources"
2 changes: 1 addition & 1 deletion resource/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
var logger = loggo.GetLogger("juju.resource.context")

// HookContextFacade is the name of the API facade for resources in the uniter.
const HookContextFacade = resource.ComponentName + "-hook-context"
const HookContextFacade = "ResourcesHookContext"

// APIClient exposes the uniter API functionality needed for resources.
type APIClient interface {
Expand Down
2 changes: 1 addition & 1 deletion resource/resourceadapters/apiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func NewAPIClient(newAPICaller func() (api.Connection, error)) (*client.Client,
}

func newAPIClient(apiCaller api.Connection) (*client.Client, error) {
caller := base.NewFacadeCallerForVersion(apiCaller, resource.ComponentName, server.Version)
caller := base.NewFacadeCallerForVersion(apiCaller, resource.FacadeName, server.Version)

httpClient, err := apiCaller.HTTPClient()
if err != nil {
Expand Down

0 comments on commit 0025fd6

Please sign in to comment.