github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/worker/common/credentialinvalidator.go (about) 1 // Copyright 2018 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package common 5 6 import ( 7 "github.com/juju/juju/api/base" 8 "github.com/juju/juju/api/credentialvalidator" 9 "github.com/juju/juju/environs/context" 10 ) 11 12 // CredentialAPI exposes functionality of the credential validator API facade to a worker. 13 type CredentialAPI interface { 14 InvalidateModelCredential(reason string) error 15 } 16 17 // NewCredentialInvalidatorFacade creates an API facade capable of invalidating credential. 18 func NewCredentialInvalidatorFacade(apiCaller base.APICaller) (CredentialAPI, error) { 19 return credentialvalidator.NewFacade(apiCaller), nil 20 } 21 22 // NewCloudCallContext creates a cloud call context to be used by workers. 23 func NewCloudCallContext(c CredentialAPI, dying context.Dying) context.ProviderCallContext { 24 return &context.CloudCallContext{ 25 DyingFunc: dying, 26 InvalidateCredentialFunc: c.InvalidateModelCredential, 27 } 28 }