github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/apiserver/facade/facadetest/context.go (about)

     1  // Copyright 2016 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package facadetest
     5  
     6  import (
     7  	"github.com/juju/juju/apiserver/facade"
     8  	"github.com/juju/juju/core/cache"
     9  	"github.com/juju/juju/core/leadership"
    10  	"github.com/juju/juju/core/lease"
    11  	"github.com/juju/juju/state"
    12  )
    13  
    14  // Context implements facade.Context in the simplest possible way.
    15  type Context struct {
    16  	Auth_       facade.Authorizer
    17  	Dispose_    func()
    18  	Hub_        facade.Hub
    19  	Resources_  facade.Resources
    20  	State_      *state.State
    21  	StatePool_  *state.StatePool
    22  	Controller_ *cache.Controller
    23  	ID_         string
    24  
    25  	LeadershipClaimer_ leadership.Claimer
    26  	LeadershipChecker_ leadership.Checker
    27  	LeadershipPinner_  leadership.Pinner
    28  	SingularClaimer_   lease.Claimer
    29  	// Identity is not part of the facade.Context interface, but is instead
    30  	// used to make sure that the context objects are the same.
    31  	Identity string
    32  }
    33  
    34  // Auth is part of the facade.Context interface.
    35  func (context Context) Auth() facade.Authorizer {
    36  	return context.Auth_
    37  }
    38  
    39  // Dispose is part of the facade.Context interface.
    40  func (context Context) Dispose() {
    41  	context.Dispose_()
    42  }
    43  
    44  // Hub is part of the facade.Context interface.
    45  func (context Context) Hub() facade.Hub {
    46  	return context.Hub_
    47  }
    48  
    49  // Controller is part of the facade.Context interface.
    50  func (context Context) Controller() *cache.Controller {
    51  	return context.Controller_
    52  }
    53  
    54  // Resources is part of the facade.Context interface.
    55  func (context Context) Resources() facade.Resources {
    56  	return context.Resources_
    57  }
    58  
    59  // State is part of the facade.Context interface.
    60  func (context Context) State() *state.State {
    61  	return context.State_
    62  }
    63  
    64  // StatePool is part of of the facade.Context interface.
    65  func (context Context) StatePool() *state.StatePool {
    66  	return context.StatePool_
    67  }
    68  
    69  // ID is part of the facade.Context interface.
    70  func (context Context) ID() string {
    71  	return context.ID_
    72  }
    73  
    74  // Presence implements facade.Context.
    75  func (context Context) Presence() facade.Presence {
    76  	return context
    77  }
    78  
    79  // ModelPresence implements facade.Presence.
    80  func (context Context) ModelPresence(modelUUID string) facade.ModelPresence {
    81  	// Potentially may need to add stuff here at some stage.
    82  	return nil
    83  }
    84  
    85  // LeadershipClaimer implements facade.Context.
    86  func (context Context) LeadershipClaimer(modelUUID string) (leadership.Claimer, error) {
    87  	return context.LeadershipClaimer_, nil
    88  }
    89  
    90  // LeadershipChecker implements facade.Context.
    91  func (context Context) LeadershipChecker() (leadership.Checker, error) {
    92  	return context.LeadershipChecker_, nil
    93  }
    94  
    95  // LeadershipPinner implements facade.Context.
    96  func (context Context) LeadershipPinner(modelUUID string) (leadership.Pinner, error) {
    97  	return context.LeadershipPinner_, nil
    98  }
    99  
   100  // SingularClaimer implements facade.Context.
   101  func (context Context) SingularClaimer() (lease.Claimer, error) {
   102  	return context.SingularClaimer_, nil
   103  }