github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/apiserver/facades/controller/environupgrader/backend.go (about) 1 // Copyright 2017 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package environupgrader 5 6 import ( 7 "github.com/juju/errors" 8 9 "github.com/juju/juju/cloud" 10 "github.com/juju/juju/state" 11 ) 12 13 type Backend interface { 14 Cloud(string) (cloud.Cloud, error) 15 } 16 17 type Pool interface { 18 GetModel(string) (Model, func(), error) 19 } 20 21 type Model interface { 22 CloudName() string 23 EnvironVersion() int 24 SetEnvironVersion(int) error 25 } 26 27 func NewPool(pool *state.StatePool) Pool { 28 return &statePool{pool} 29 } 30 31 type statePool struct { 32 pool *state.StatePool 33 } 34 35 func (p *statePool) GetModel(uuid string) (Model, func(), error) { 36 m, ph, err := p.pool.GetModel(uuid) 37 if err != nil { 38 return nil, nil, errors.Trace(err) 39 } 40 return m, func() { ph.Release() }, nil 41 }