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