Skip to content

Architecture Guide

Anand Gaitonde edited this page Oct 4, 2018 · 28 revisions

Page under construction.

CF CLI Architecture Diagram

CLI Architecture

Two CLIs in One Repository

In order for the CF CLI V7 to be a superset of the CF CLI V6, the CLI repository is structured in a way for both the V6 and V7 CLIs to co-exist on master. This results in certain packages (aka directories) exclusively being used by the V6 and V7 CLIs.

V6 CLI Packages

├── main.go
├── actor
│   ├── actionerror
│   ├── cfnetworkingaction
│   ├── pluginaction
│   ├── pushaction
│   ├── sharedaction
│   ├── v2action
│   ├── v2v3action
│   └── versioncheck
├── api
│   ├── cloudcontroller
│   │   ├── ccerror
│   │   ├── ccv2
│   │   ├── ccv3
│   │   ├── ccversion
│   │   └── wrapper
│   ├── plugin
│   └── uaa
├── cf
├── command
│   ├── common
│   │   ├── command_list_v6.go
│   │   ├── help_command.go
│   │   ├── install_plugin_command.go
│   │   ├── internal
│   │   │   ├── help_all_display_v6.go
│   │   │   ├── help_common_display_v6.go
│   │   │   └── help_display.go
│   │   └── version_command.go
│   ├── flag
│   ├── plugin
│   ├── translatableerror
│   └── v6
├── i18n
│   └── resources
├── plugin
├── strings
├── types
├── util
└── version

V7 CLI Packages

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:

├── main.go
├── actor
│   ├── actionerror
│   ├── cfnetworkingaction
│   ├── pluginaction
│   ├── pushaction
│   ├── sharedaction
│   ├── v2action
│   ├── v2v3action
│   ├── v3action # Additional V3 only logic
│   └── versioncheck
├── api
│   ├── cloudcontroller
│   │   ├── ccerror
│   │   ├── ccv2
│   │   ├── ccv3
│   │   ├── ccversion
│   │   └── wrapper
│   ├── plugin
│   └── uaa
├── cf
├── command
│   ├── common
│   │   ├── command_list_v7.go # Different Command list
│   │   ├── help_command.go
│   │   ├── install_plugin_command.go
│   │   ├── internal
│   │   │   ├── help_all_display_v7.go # Different help list
│   │   │   ├── help_common_display_v7.go # Different help list
│   │   │   └── help_display.go
│   │   └── version_command.go
│   ├── flag
│   ├── plugin
│   ├── translatableerror
│   ├── v6
│   └── v7 # Over written V7 versions of V6 commands
├── i18n
│   └── resources
├── plugin
├── strings
├── types
├── util
└── version

Need to fill in the following

  • V6 vs V7
  • Legacy vs Rewrite

The CLI is divided into a few major components, including but not limited to:

  1. command
  2. actor
  3. API

command

The command package is the gateway to each CLI command accessible to the CLI, using the actors to talk to the API. Each command on the CLI has 1 corresponding file in the command package. The command package is also responsible for displaying the UI.

actor

The actor package consists of one actor that handles all the logic to process the commands in the CLI. Actor functions are shared workflows that can be used by more than one command. The functions may call upon several API calls to implement their business logic.

API

The API package handles the HTTP requests to the API. The functions in this package return a resource that the actor can then parse and handle. The structures returned by this package closely resemble the return bodies of the Cloud Controller API.