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

Method Execute

cf/commands/target.go:73–105  ·  view source on GitHub ↗
(c flags.FlagContext)

Source from the content-addressed store, hash-verified

71}
72
73func (cmd *Target) Execute(c flags.FlagContext) error {
74 orgName := c.String("o")
75 spaceName := c.String("s")
76
77 if orgName != "" {
78 err := cmd.setOrganization(orgName)
79 if err != nil {
80 return err
81 } else if spaceName == "" {
82 spaceList, apiErr := cmd.getSpaceList()
83 if apiErr == nil && len(spaceList) == 1 {
84 cmd.setSpace(spaceList[0].Name)
85 }
86 }
87 }
88
89 if spaceName != "" {
90 err := cmd.setSpace(spaceName)
91 if err != nil {
92 return err
93 }
94 }
95
96 err := cmd.ui.ShowConfiguration(cmd.config)
97 if err != nil {
98 return err
99 }
100 cmd.ui.NotifyUpdateIfNeeded(cmd.config)
101 if !cmd.config.IsLoggedIn() {
102 return fmt.Errorf("") // Done on purpose, do not redo this in refactor code
103 }
104 return nil
105}
106
107func (cmd Target) setOrganization(orgName string) error {
108 // setting an org necessarily invalidates any space you had previously targeted

Callers

nothing calls this directly

Calls 7

setOrganizationMethod · 0.95
getSpaceListMethod · 0.95
setSpaceMethod · 0.95
StringMethod · 0.65
ShowConfigurationMethod · 0.65
NotifyUpdateIfNeededMethod · 0.65
IsLoggedInMethod · 0.65

Tested by

no test coverage detected