-
Notifications
You must be signed in to change notification settings - Fork 944
Architecture Guide
Anand Gaitonde edited this page Oct 16, 2018
·
28 revisions
Page under construction.
The CF CLI master
branch contains both the V6 and V7 CLIs:
-
main.go
(Orange): Entry point into the CF CLI. - Command Lists (Grey): List of CLI commands contained in that version of the CF CLI. This is dependent on the build
tags
provided to GoLang at compile time. - Command Packages (Yellow): These packages manage the UX/UI logic for each individual command.
- Actor Packages (Teal): These packages manage the business logic for the entire CLI. The V6 CLI actors are divided by Cloud Controller API version; the push and V2/V3 actors are required to mitigate the complexity of integrating the V2 and V3 API versions. The V7 CLI utilizes the V7 Actor package for V7 specific commands.
- API Packages (Green): These packages manage the API requests made to the Cloud Controller/UAA/Networking/etc. These API requests do not contain any business logic; they are simple abstractions of individual API requests.
When a CLI command runs, the following process occurs to execute the requested action:
- All the command line arguments (aka
os.Args
) are provided to the go-flags package with the appropriate command list. - Based on the
command
tag from the command list and the command line arguments, go-flags will instantiate the correct command struct, populating thestruct
's fields based off of the providedshort
/long
flags listed in the commandstruct
's tags. - The command's
Setup
method is called with a preloaded UI and an in memory copy of the CLI config. ThisSetup
method creates all the necessary API clients and Actors required for the command. - The command's
Execute
method is called; theExecute
method [generally] runs through the following:- Validates/sanitizes the user provided input.
- API version checking based on provided input.
- Verifies API targets based on command requirements.
- Outputs "flavor" text to indicate to the user that desired action is about to be processed.
- Calls appropriate Actor function(s) to perform command's action. (See step #5 for more information)
- Displays output of Actor methods depending on command's intent.
- When an Actor function is called, one or more API calls are made to the Cloud Controller, UAA, Networking API, etc. in order to perform the desired action. Any complex logic regarding the return of these APIs are handled within the Actor function, returning the final result of said API calls or an error indicating why the Actor function could not proceed.
Outside of the command/common
package (which uses GoLang Build tags), the V7 CLI uses all the V6 packages with the addition of actor/v3action
and command/v7
:
├── actor
│ └── v7actor
└── command
├── common
│ ├── command_list_v7.go # Different Command list
│ └── internal
│ ├── help_all_display_v7.go # Different help list
│ └── help_common_display_v7.go # Different help list
└── v7 # Over written V7 versions of V6 commands
Need to fill in the following
- V6 vs V7
- Legacy vs Rewrite