github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/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-unstable" 11 "gopkg.in/juju/names.v2" 12 13 "github.com/juju/juju/apiserver/params" 14 "github.com/juju/juju/network" 15 ) 16 17 // ErrRestrictedContext indicates a method is not implemented in the given context. 18 var ErrRestrictedContext = errors.NotImplementedf("not implemented for restricted context") 19 20 // RestrictedContext is a base implementation for restricted contexts to embed, 21 // so that an error is returned for methods that are not explicitly 22 // implemented. 23 type RestrictedContext struct{} 24 25 // ConfigSettings implements jujuc.Context. 26 func (*RestrictedContext) ConfigSettings() (charm.Settings, error) { return nil, ErrRestrictedContext } 27 28 // UnitStatus implements jujuc.Context. 29 func (*RestrictedContext) UnitStatus() (*StatusInfo, error) { return nil, ErrRestrictedContext } 30 31 // SetUnitStatus implements jujuc.Context. 32 func (*RestrictedContext) SetUnitStatus(StatusInfo) error { return ErrRestrictedContext } 33 34 // ApplicationStatus implements jujuc.Context. 35 func (*RestrictedContext) ApplicationStatus() (ApplicationStatusInfo, error) { 36 return ApplicationStatusInfo{}, ErrRestrictedContext 37 } 38 39 // SetApplicationStatus implements jujuc.Context. 40 func (*RestrictedContext) SetApplicationStatus(StatusInfo) error { return ErrRestrictedContext } 41 42 // AvailabilityZone implements jujuc.Context. 43 func (*RestrictedContext) AvailabilityZone() (string, error) { return "", ErrRestrictedContext } 44 45 // RequestReboot implements jujuc.Context. 46 func (*RestrictedContext) RequestReboot(prio RebootPriority) error { return ErrRestrictedContext } 47 48 // PublicAddress implements jujuc.Context. 49 func (*RestrictedContext) PublicAddress() (string, error) { return "", ErrRestrictedContext } 50 51 // PrivateAddress implements jujuc.Context. 52 func (*RestrictedContext) PrivateAddress() (string, error) { return "", ErrRestrictedContext } 53 54 // OpenPorts implements jujuc.Context. 55 func (*RestrictedContext) OpenPorts(protocol string, fromPort, toPort int) error { 56 return ErrRestrictedContext 57 } 58 59 // ClosePorts implements jujuc.Context. 60 func (*RestrictedContext) ClosePorts(protocol string, fromPort, toPort int) error { 61 return ErrRestrictedContext 62 } 63 64 // OpenedPorts implements jujuc.Context. 65 func (*RestrictedContext) OpenedPorts() []network.PortRange { return nil } 66 67 // NetworkConfig implements jujuc.Context. 68 func (*RestrictedContext) NetworkConfig(bindingName string) ([]params.NetworkConfig, error) { 69 return nil, ErrRestrictedContext 70 } 71 72 // IsLeader implements jujuc.Context. 73 func (*RestrictedContext) IsLeader() (bool, error) { return false, ErrRestrictedContext } 74 75 // LeaderSettings implements jujuc.Context. 76 func (*RestrictedContext) LeaderSettings() (map[string]string, error) { 77 return nil, ErrRestrictedContext 78 } 79 80 // WriteLeaderSettings implements jujuc.Context. 81 func (*RestrictedContext) WriteLeaderSettings(map[string]string) error { return ErrRestrictedContext } 82 83 // AddMetric implements jujuc.Context. 84 func (*RestrictedContext) AddMetric(string, string, time.Time) error { return ErrRestrictedContext } 85 86 // StorageTags implements jujuc.Context. 87 func (*RestrictedContext) StorageTags() ([]names.StorageTag, error) { return nil, ErrRestrictedContext } 88 89 // Storage implements jujuc.Context. 90 func (*RestrictedContext) Storage(names.StorageTag) (ContextStorageAttachment, error) { 91 return nil, ErrRestrictedContext 92 } 93 94 // HookStorage implements jujuc.Context. 95 func (*RestrictedContext) HookStorage() (ContextStorageAttachment, error) { 96 return nil, ErrRestrictedContext 97 } 98 99 // AddUnitStorage implements jujuc.Context. 100 func (*RestrictedContext) AddUnitStorage(map[string]params.StorageConstraints) error { 101 return ErrRestrictedContext 102 } 103 104 // Relation implements jujuc.Context. 105 func (*RestrictedContext) Relation(id int) (ContextRelation, error) { 106 return nil, ErrRestrictedContext 107 } 108 109 // RelationIds implements jujuc.Context. 110 func (*RestrictedContext) RelationIds() ([]int, error) { return nil, ErrRestrictedContext } 111 112 // HookRelation implements jujuc.Context. 113 func (*RestrictedContext) HookRelation() (ContextRelation, error) { 114 return nil, ErrRestrictedContext 115 } 116 117 // RemoteUnitName implements jujuc.Context. 118 func (*RestrictedContext) RemoteUnitName() (string, error) { return "", ErrRestrictedContext } 119 120 // ActionParams implements jujuc.Context. 121 func (*RestrictedContext) ActionParams() (map[string]interface{}, error) { 122 return nil, ErrRestrictedContext 123 } 124 125 // UpdateActionResults implements jujuc.Context. 126 func (*RestrictedContext) UpdateActionResults(keys []string, value string) error { 127 return ErrRestrictedContext 128 } 129 130 // SetActionMessage implements jujuc.Context. 131 func (*RestrictedContext) SetActionMessage(string) error { return ErrRestrictedContext } 132 133 // SetActionFailed implements jujuc.Context. 134 func (*RestrictedContext) SetActionFailed() error { return ErrRestrictedContext } 135 136 // Component implements jujc.Context. 137 func (*RestrictedContext) Component(string) (ContextComponent, error) { 138 return nil, ErrRestrictedContext 139 } 140 141 // UnitWorkloadVersion implements jujuc.Context. 142 func (*RestrictedContext) UnitWorkloadVersion() (string, error) { 143 return "", ErrRestrictedContext 144 } 145 146 // SetUnitWorkloadVersion implements jujuc.Context. 147 func (*RestrictedContext) SetUnitWorkloadVersion(string) error { 148 return ErrRestrictedContext 149 }