github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/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/api/base"
     8  	"github.com/juju/juju/apiserver/params"
     9  )
    10  
    11  // State provides access to a worker's view of the state.
    12  type State struct {
    13  	facade base.FacadeCaller
    14  }
    15  
    16  // NewState returns a version of the state that provides functionality required by the worker.
    17  func NewState(caller base.APICaller) *State {
    18  	return &State{base.NewFacadeCaller(caller, "CharmRevisionUpdater")}
    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.facade.FacadeCall("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  }