github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/worker/caasunitprovisioner/client.go (about) 1 // Copyright 2017 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package caasunitprovisioner 5 6 import ( 7 apicaasunitprovisioner "github.com/juju/juju/api/caasunitprovisioner" 8 "github.com/juju/juju/apiserver/params" 9 "github.com/juju/juju/core/application" 10 "github.com/juju/juju/core/life" 11 "github.com/juju/juju/core/status" 12 "github.com/juju/juju/core/watcher" 13 ) 14 15 // Client provides an interface for interacting with the 16 // CAASUnitProvisioner API. Subsets of this should be passed 17 // to the CAASUnitProvisioner worker. 18 type Client interface { 19 ApplicationGetter 20 ApplicationUpdater 21 ProvisioningInfoGetter 22 LifeGetter 23 UnitUpdater 24 ProvisioningStatusSetter 25 } 26 27 // ApplicationGetter provides an interface for 28 // watching for the lifecycle state changes 29 // (including addition) of applications in the 30 // model, and fetching their details. 31 type ApplicationGetter interface { 32 WatchApplications() (watcher.StringsWatcher, error) 33 ApplicationConfig(string) (application.ConfigAttributes, error) 34 WatchApplicationScale(string) (watcher.NotifyWatcher, error) 35 ApplicationScale(string) (int, error) 36 } 37 38 // ApplicationUpdater provides an interface for updating 39 // Juju applications from changes in the cloud. 40 type ApplicationUpdater interface { 41 UpdateApplicationService(arg params.UpdateApplicationServiceArg) error 42 } 43 44 // ProvisioningInfoGetter provides an interface for 45 // watching and getting the pod spec and other info 46 // needed to provision an application. 47 type ProvisioningInfoGetter interface { 48 ProvisioningInfo(appName string) (*apicaasunitprovisioner.ProvisioningInfo, error) 49 WatchPodSpec(appName string) (watcher.NotifyWatcher, error) 50 } 51 52 // LifeGetter provides an interface for getting the 53 // lifecycle state value for an application or unit. 54 type LifeGetter interface { 55 Life(string) (life.Value, error) 56 } 57 58 // UnitUpdater provides an interface for updating 59 // Juju units from changes in the cloud. 60 type UnitUpdater interface { 61 UpdateUnits(arg params.UpdateApplicationUnits) error 62 } 63 64 // ProvisioningStatusSetter provides an interface for 65 // setting status information. 66 type ProvisioningStatusSetter interface { 67 // SetOperatorStatus sets the status for the application operator. 68 SetOperatorStatus(appName string, status status.Status, message string, data map[string]interface{}) error 69 }