github.com/cloud-green/juju@v0.0.0-20151002100041-a00291338d3d/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  	"github.com/juju/names"
    11  	"gopkg.in/juju/charm.v6-unstable"
    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  // ServiceStatus implements jujuc.Context.
    35  func (*RestrictedContext) ServiceStatus() (ServiceStatusInfo, error) {
    36  	return ServiceStatusInfo{}, ErrRestrictedContext
    37  }
    38  
    39  // SetServiceStatus implements jujuc.Context.
    40  func (*RestrictedContext) SetServiceStatus(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  // IsLeader implements jujuc.Context.
    68  func (*RestrictedContext) IsLeader() (bool, error) { return false, ErrRestrictedContext }
    69  
    70  // LeaderSettings implements jujuc.Context.
    71  func (*RestrictedContext) LeaderSettings() (map[string]string, error) {
    72  	return nil, ErrRestrictedContext
    73  }
    74  
    75  // WriteLeaderSettings implements jujuc.Context.
    76  func (*RestrictedContext) WriteLeaderSettings(map[string]string) error { return ErrRestrictedContext }
    77  
    78  // AddMetric implements jujuc.Context.
    79  func (*RestrictedContext) AddMetric(string, string, time.Time) error { return ErrRestrictedContext }
    80  
    81  // StorageTags implements jujuc.Context.
    82  func (*RestrictedContext) StorageTags() ([]names.StorageTag, error) { return nil, ErrRestrictedContext }
    83  
    84  // Storage implements jujuc.Context.
    85  func (*RestrictedContext) Storage(names.StorageTag) (ContextStorageAttachment, error) {
    86  	return nil, ErrRestrictedContext
    87  }
    88  
    89  // HookStorage implements jujuc.Context.
    90  func (*RestrictedContext) HookStorage() (ContextStorageAttachment, error) {
    91  	return nil, ErrRestrictedContext
    92  }
    93  
    94  // AddUnitStorage implements jujuc.Context.
    95  func (*RestrictedContext) AddUnitStorage(map[string]params.StorageConstraints) error {
    96  	return ErrRestrictedContext
    97  }
    98  
    99  // Relation implements jujuc.Context.
   100  func (*RestrictedContext) Relation(id int) (ContextRelation, error) {
   101  	return nil, ErrRestrictedContext
   102  }
   103  
   104  // RelationIds implements jujuc.Context.
   105  func (*RestrictedContext) RelationIds() ([]int, error) { return nil, ErrRestrictedContext }
   106  
   107  // HookRelation implements jujuc.Context.
   108  func (*RestrictedContext) HookRelation() (ContextRelation, error) {
   109  	return nil, ErrRestrictedContext
   110  }
   111  
   112  // RemoteUnitName implements jujuc.Context.
   113  func (*RestrictedContext) RemoteUnitName() (string, error) { return "", ErrRestrictedContext }
   114  
   115  // ActionParams implements jujuc.Context.
   116  func (*RestrictedContext) ActionParams() (map[string]interface{}, error) {
   117  	return nil, ErrRestrictedContext
   118  }
   119  
   120  // UpdateActionResults implements jujuc.Context.
   121  func (*RestrictedContext) UpdateActionResults(keys []string, value string) error {
   122  	return ErrRestrictedContext
   123  }
   124  
   125  // SetActionMessage implements jujuc.Context.
   126  func (*RestrictedContext) SetActionMessage(string) error { return ErrRestrictedContext }
   127  
   128  // SetActionFailed implements jujuc.Context.
   129  func (*RestrictedContext) SetActionFailed() error { return ErrRestrictedContext }