github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/worker/caasoperator/client.go (about) 1 // Copyright 2017 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package caasoperator 5 6 import ( 7 "github.com/juju/version" 8 "gopkg.in/juju/charm.v6" 9 10 "github.com/juju/juju/core/life" 11 "github.com/juju/juju/core/model" 12 "github.com/juju/juju/core/status" 13 "github.com/juju/juju/core/watcher" 14 ) 15 16 // Client provides an interface for interacting 17 // with the CAASOperator API. Subsets of this 18 // should be passed to the CAASOperator worker. 19 type Client interface { 20 CharmGetter 21 UnitGetter 22 UnitRemover 23 ApplicationWatcher 24 PodSpecSetter 25 StatusSetter 26 VersionSetter 27 Model() (*model.Model, error) 28 } 29 30 // CharmGetter provides an interface for getting 31 // the URL and SHA256 hash of the charm currently 32 // assigned to the application. 33 type CharmGetter interface { 34 Charm(application string) (_ *charm.URL, force bool, sha256 string, vers int, _ error) 35 } 36 37 // UnitGetter provides an interface for watching for 38 // the lifecycle state changes (including addition) 39 // of a specified application's units, and fetching 40 // their details. 41 type UnitGetter interface { 42 WatchUnits(string) (watcher.StringsWatcher, error) 43 Life(string) (life.Value, error) 44 } 45 46 // UnitRemover provides an interface for 47 // removing a unit. 48 type UnitRemover interface { 49 RemoveUnit(string) error 50 } 51 52 // ApplicationWatcher provides an interface watching 53 // for application changes. 54 type ApplicationWatcher interface { 55 Watch(string) (watcher.NotifyWatcher, error) 56 } 57 58 // PodSpecSetter provides an interface for 59 // setting the pod spec for the application. 60 type PodSpecSetter interface { 61 SetPodSpec(appName, spec string) error 62 } 63 64 // StatusSetter provides an interface for setting 65 // the status of a CAAS application. 66 type StatusSetter interface { 67 // SetStatus sets the status of an application. 68 SetStatus( 69 application string, 70 status status.Status, 71 info string, 72 data map[string]interface{}, 73 ) error 74 } 75 76 // CharmConfigGetter provides an interface for 77 // watching and getting the application's charm config settings. 78 type CharmConfigGetter interface { 79 CharmConfig(string) (charm.Settings, error) 80 WatchCharmConfig(string) (watcher.NotifyWatcher, error) 81 } 82 83 // VersionSetter provides an interface for setting 84 // the operator agent version. 85 type VersionSetter interface { 86 SetVersion(appName string, v version.Binary) error 87 }