MCPcopy Index your code
hub / github.com/cloudfoundry/cli / CheckTarget

Method CheckTarget

actor/sharedaction/check_target.go:7–31  ·  view source on GitHub ↗

CheckTarget confirms that the user is logged in. Optionally it will also check if an organization and space are targeted.

(targetedOrganizationRequired bool, targetedSpaceRequired bool)

Source from the content-addressed store, hash-verified

5// CheckTarget confirms that the user is logged in. Optionally it will also
6// check if an organization and space are targeted.
7func (actor Actor) CheckTarget(targetedOrganizationRequired bool, targetedSpaceRequired bool) error {
8 if !actor.IsLoggedIn() {
9 return actionerror.NotLoggedInError{
10 BinaryName: actor.Config.BinaryName(),
11 }
12 }
13
14 if targetedOrganizationRequired {
15 if !actor.IsOrgTargeted() {
16 return actionerror.NoOrganizationTargetedError{
17 BinaryName: actor.Config.BinaryName(),
18 }
19 }
20
21 if targetedSpaceRequired {
22 if !actor.IsSpaceTargeted() {
23 return actionerror.NoSpaceTargetedError{
24 BinaryName: actor.Config.BinaryName(),
25 }
26 }
27 }
28 }
29
30 return nil
31}
32
33func (actor Actor) RequireCurrentUser() (string, error) {
34 if !actor.IsLoggedIn() {

Callers

nothing calls this directly

Implementers 1

FakeActorcommand/v7/v7fakes/fake_actor.go

Calls 4

IsOrgTargetedMethod · 0.95
IsSpaceTargetedMethod · 0.95
IsLoggedInMethod · 0.65
BinaryNameMethod · 0.65

Tested by

no test coverage detected