This repository has been archived by the owner on Jan 9, 2020. It is now read-only.
forked from juju/juju
/
restricted.go
129 lines (95 loc) · 4.63 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
// Copyright 2012-2014 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package jujuc
import (
"time"
"github.com/juju/errors"
"github.com/juju/names"
"gopkg.in/juju/charm.v6-unstable"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/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 jujuc.Context.
func (*RestrictedContext) ConfigSettings() (charm.Settings, error) { return nil, ErrRestrictedContext }
// UnitStatus implements jujuc.Context.
func (*RestrictedContext) UnitStatus() (*StatusInfo, error) { return nil, ErrRestrictedContext }
// SetUnitStatus implements jujuc.Context.
func (*RestrictedContext) SetUnitStatus(StatusInfo) error { return ErrRestrictedContext }
// ServiceStatus implements jujuc.Context.
func (*RestrictedContext) ServiceStatus() (ServiceStatusInfo, error) {
return ServiceStatusInfo{}, ErrRestrictedContext
}
// SetServiceStatus implements jujuc.Context.
func (*RestrictedContext) SetServiceStatus(StatusInfo) error { return ErrRestrictedContext }
// AvailabilityZone implements jujuc.Context.
func (*RestrictedContext) AvailabilityZone() (string, error) { return "", ErrRestrictedContext }
// RequestReboot implements jujuc.Context.
func (*RestrictedContext) RequestReboot(prio RebootPriority) error { return ErrRestrictedContext }
// PublicAddress implements jujuc.Context.
func (*RestrictedContext) PublicAddress() (string, error) { return "", ErrRestrictedContext }
// PrivateAddress implements jujuc.Context.
func (*RestrictedContext) PrivateAddress() (string, error) { return "", ErrRestrictedContext }
// OpenPorts implements jujuc.Context.
func (*RestrictedContext) OpenPorts(protocol string, fromPort, toPort int) error {
return ErrRestrictedContext
}
// ClosePorts implements jujuc.Context.
func (*RestrictedContext) ClosePorts(protocol string, fromPort, toPort int) error {
return ErrRestrictedContext
}
// OpenedPorts implements jujuc.Context.
func (*RestrictedContext) OpenedPorts() []network.PortRange { return nil }
// IsLeader implements jujuc.Context.
func (*RestrictedContext) IsLeader() (bool, error) { return false, ErrRestrictedContext }
// LeaderSettings implements jujuc.Context.
func (*RestrictedContext) LeaderSettings() (map[string]string, error) {
return nil, ErrRestrictedContext
}
// WriteLeaderSettings implements jujuc.Context.
func (*RestrictedContext) WriteLeaderSettings(map[string]string) error { return ErrRestrictedContext }
// AddMetric implements jujuc.Context.
func (*RestrictedContext) AddMetric(string, string, time.Time) error { return ErrRestrictedContext }
// StorageTags implements jujuc.Context.
func (*RestrictedContext) StorageTags() ([]names.StorageTag, error) { return nil, ErrRestrictedContext }
// Storage implements jujuc.Context.
func (*RestrictedContext) Storage(names.StorageTag) (ContextStorageAttachment, error) {
return nil, ErrRestrictedContext
}
// HookStorage implements jujuc.Context.
func (*RestrictedContext) HookStorage() (ContextStorageAttachment, error) {
return nil, ErrRestrictedContext
}
// AddUnitStorage implements jujuc.Context.
func (*RestrictedContext) AddUnitStorage(map[string]params.StorageConstraints) error {
return ErrRestrictedContext
}
// Relation implements jujuc.Context.
func (*RestrictedContext) Relation(id int) (ContextRelation, error) {
return nil, ErrRestrictedContext
}
// RelationIds implements jujuc.Context.
func (*RestrictedContext) RelationIds() ([]int, error) { return nil, ErrRestrictedContext }
// HookRelation implements jujuc.Context.
func (*RestrictedContext) HookRelation() (ContextRelation, error) {
return nil, ErrRestrictedContext
}
// RemoteUnitName implements jujuc.Context.
func (*RestrictedContext) RemoteUnitName() (string, error) { return "", ErrRestrictedContext }
// ActionParams implements jujuc.Context.
func (*RestrictedContext) ActionParams() (map[string]interface{}, error) {
return nil, ErrRestrictedContext
}
// UpdateActionResults implements jujuc.Context.
func (*RestrictedContext) UpdateActionResults(keys []string, value string) error {
return ErrRestrictedContext
}
// SetActionMessage implements jujuc.Context.
func (*RestrictedContext) SetActionMessage(string) error { return ErrRestrictedContext }
// SetActionFailed implements jujuc.Context.
func (*RestrictedContext) SetActionFailed() error { return ErrRestrictedContext }