1
// Copyright 2014 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
7
"github.com/juju/errors"
8
"github.com/juju/juju/apiserver/common"
9
"github.com/juju/juju/apiserver/facade"
10
"github.com/juju/juju/state"
13
// This file contains untested shims to let us wrap state in a sensible
14
// interface and avoid writing tests that depend on mongodb. If you were
15
// to change any part of it so that it were no longer *obviously* and
16
// *trivially* correct, you would be Doing It Wrong.
19
common.RegisterStandardFacade("Backups", 1, newAPI)
22
type stateShim struct {
26
// MachineSeries implements backups.Backend
27
func (s *stateShim) MachineSeries(id string) (string, error) {
28
m, err := s.State.Machine(id)
30
return "", errors.Trace(err)
32
return m.Series(), nil
35
func newAPI(st *state.State, resources facade.Resources, authorizer facade.Authorizer) (*API, error) {
36
return NewAPI(&stateShim{st}, resources, authorizer)