github.com/mattyw/juju@v0.0.0-20140610034352-732aecd63861/state/api/charmrevisionupdater/updater.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package charmrevisionupdater 5 6 import ( 7 "github.com/juju/juju/state/api/base" 8 "github.com/juju/juju/state/api/params" 9 ) 10 11 // State provides access to a worker's view of the state. 12 type State struct { 13 caller base.Caller 14 } 15 16 // NewState returns a version of the state that provides functionality required by the worker. 17 func NewState(caller base.Caller) *State { 18 return &State{caller} 19 } 20 21 // UpdateLatestRevisions retrieves charm revision info from a repository 22 // and updates the revision info in state. 23 func (st *State) UpdateLatestRevisions() error { 24 result := new(params.ErrorResult) 25 err := st.caller.Call("CharmRevisionUpdater", "", "UpdateLatestRevisions", nil, result) 26 if err != nil { 27 return err 28 } 29 if result.Error != nil { 30 return result.Error 31 } 32 return nil 33 }