github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/worker/uniter/runner/jujuc/restricted.go (about) 1 // Copyright 2012-2014 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package jujuc 5 6 import ( 7 "time" 8 9 "github.com/juju/errors" 10 "gopkg.in/juju/charm.v6" 11 "gopkg.in/juju/names.v2" 12 13 "github.com/juju/juju/apiserver/params" 14 "github.com/juju/juju/core/application" 15 "github.com/juju/juju/core/network" 16 ) 17 18 // ErrRestrictedContext indicates a method is not implemented in the given context. 19 var ErrRestrictedContext = errors.NotImplementedf("not implemented for restricted context") 20 21 // RestrictedContext is a base implementation for restricted contexts to embed, 22 // so that an error is returned for methods that are not explicitly 23 // implemented. 24 type RestrictedContext struct{} 25 26 // ConfigSettings implements hooks.Context. 27 func (*RestrictedContext) ConfigSettings() (charm.Settings, error) { return nil, ErrRestrictedContext } 28 29 // GoalState implements hooks.Context. 30 func (*RestrictedContext) GoalState() (*application.GoalState, error) { 31 return &application.GoalState{}, ErrRestrictedContext 32 } 33 34 // UnitStatus implements hooks.Context. 35 func (*RestrictedContext) UnitStatus() (*StatusInfo, error) { 36 return nil, ErrRestrictedContext 37 } 38 39 // SetPodSpec implements hooks.Context. 40 func (c *RestrictedContext) SetPodSpec(specYaml string) error { 41 return ErrRestrictedContext 42 } 43 44 func (c *RestrictedContext) CloudSpec() (*params.CloudSpec, error) { 45 return nil, ErrRestrictedContext 46 } 47 48 // SetUnitStatus implements hooks.Context. 49 func (*RestrictedContext) SetUnitStatus(StatusInfo) error { return ErrRestrictedContext } 50 51 // ApplicationStatus implements hooks.Context. 52 func (*RestrictedContext) ApplicationStatus() (ApplicationStatusInfo, error) { 53 return ApplicationStatusInfo{}, ErrRestrictedContext 54 } 55 56 // SetApplicationStatus implements hooks.Context. 57 func (*RestrictedContext) SetApplicationStatus(StatusInfo) error { 58 return ErrRestrictedContext 59 } 60 61 // AvailabilityZone implements hooks.Context. 62 func (*RestrictedContext) AvailabilityZone() (string, error) { return "", ErrRestrictedContext } 63 64 // RequestReboot implements hooks.Context. 65 func (*RestrictedContext) RequestReboot(prio RebootPriority) error { 66 return ErrRestrictedContext 67 } 68 69 // PublicAddress implements hooks.Context. 70 func (*RestrictedContext) PublicAddress() (string, error) { return "", ErrRestrictedContext } 71 72 // PrivateAddress implements hooks.Context. 73 func (*RestrictedContext) PrivateAddress() (string, error) { return "", ErrRestrictedContext } 74 75 // OpenPorts implements hooks.Context. 76 func (*RestrictedContext) OpenPorts(protocol string, fromPort, toPort int) error { 77 return ErrRestrictedContext 78 } 79 80 // ClosePorts implements hooks.Context. 81 func (*RestrictedContext) ClosePorts(protocol string, fromPort, toPort int) error { 82 return ErrRestrictedContext 83 } 84 85 // OpenedPorts implements hooks.Context. 86 func (*RestrictedContext) OpenedPorts() []network.PortRange { return nil } 87 88 // NetworkInfo implements hooks.Context. 89 func (*RestrictedContext) NetworkInfo(bindingNames []string, relationId int) (map[string]params.NetworkInfoResult, error) { 90 return map[string]params.NetworkInfoResult{}, ErrRestrictedContext 91 } 92 93 // IsLeader implements hooks.Context. 94 func (*RestrictedContext) IsLeader() (bool, error) { return false, ErrRestrictedContext } 95 96 // LeaderSettings implements hooks.Context. 97 func (*RestrictedContext) LeaderSettings() (map[string]string, error) { 98 return nil, ErrRestrictedContext 99 } 100 101 // WriteLeaderSettings implements hooks.Context. 102 func (*RestrictedContext) WriteLeaderSettings(map[string]string) error { return ErrRestrictedContext } 103 104 // AddMetric implements hooks.Context. 105 func (*RestrictedContext) AddMetric(string, string, time.Time) error { return ErrRestrictedContext } 106 107 // AddMetricLabels implements hooks.Context. 108 func (*RestrictedContext) AddMetricLabels(string, string, time.Time, map[string]string) error { 109 return ErrRestrictedContext 110 } 111 112 // StorageTags implements hooks.Context. 113 func (*RestrictedContext) StorageTags() ([]names.StorageTag, error) { return nil, ErrRestrictedContext } 114 115 // Storage implements hooks.Context. 116 func (*RestrictedContext) Storage(names.StorageTag) (ContextStorageAttachment, error) { 117 return nil, ErrRestrictedContext 118 } 119 120 // HookStorage implements hooks.Context. 121 func (*RestrictedContext) HookStorage() (ContextStorageAttachment, error) { 122 return nil, ErrRestrictedContext 123 } 124 125 // AddUnitStorage implements hooks.Context. 126 func (*RestrictedContext) AddUnitStorage(map[string]params.StorageConstraints) error { 127 return ErrRestrictedContext 128 } 129 130 // Relation implements hooks.Context. 131 func (*RestrictedContext) Relation(id int) (ContextRelation, error) { 132 return nil, ErrRestrictedContext 133 } 134 135 // RelationIds implements hooks.Context. 136 func (*RestrictedContext) RelationIds() ([]int, error) { return nil, ErrRestrictedContext } 137 138 // HookRelation implements hooks.Context. 139 func (*RestrictedContext) HookRelation() (ContextRelation, error) { 140 return nil, ErrRestrictedContext 141 } 142 143 // RemoteUnitName implements hooks.Context. 144 func (*RestrictedContext) RemoteUnitName() (string, error) { return "", ErrRestrictedContext } 145 146 // ActionParams implements hooks.Context. 147 func (*RestrictedContext) ActionParams() (map[string]interface{}, error) { 148 return nil, ErrRestrictedContext 149 } 150 151 // UpdateActionResults implements hooks.Context. 152 func (*RestrictedContext) UpdateActionResults(keys []string, value string) error { 153 return ErrRestrictedContext 154 } 155 156 // SetActionMessage implements hooks.Context. 157 func (*RestrictedContext) SetActionMessage(string) error { return ErrRestrictedContext } 158 159 // SetActionFailed implements hooks.Context. 160 func (*RestrictedContext) SetActionFailed() error { return ErrRestrictedContext } 161 162 // Component implements jujc.Context. 163 func (*RestrictedContext) Component(string) (ContextComponent, error) { 164 return nil, ErrRestrictedContext 165 } 166 167 // UnitWorkloadVersion implements hooks.Context. 168 func (*RestrictedContext) UnitWorkloadVersion() (string, error) { 169 return "", ErrRestrictedContext 170 } 171 172 // SetUnitWorkloadVersion implements hooks.Context. 173 func (*RestrictedContext) SetUnitWorkloadVersion(string) error { 174 return ErrRestrictedContext 175 }