Git Product home page Git Product logo

cli's Introduction

Cloud Foundry CLI written in Go Build Status

Background

Project to rewrite the Cloud Foundry CLI tool using Go. This project should currently be considered alpha quality software and should not be used in production environments. If you need something more stable, please check out the RubyGem.

For a view on the current status of the project, check cftracker.

Cloning the repository

  1. Install Go brew install go --cross-compile-common
  2. Clone (Fork before hand for development).
  3. Run git submodule update --init --recursive

Downloading Edge

The latest binary builds and installers are published to Amazon S3 buckets.

Binaries:

Installers:

Building

  1. Run ./bin/build
  2. The binary will be built into the out directory.

Development

NOTE: Currently only development on OSX 10.8 is supported

  1. Write a test.
  2. Run bin/test and watch test fail.
  3. Make test pass.
  4. Submit a pull request.

If you want to run the benchmark tests

./bin/go test -bench . -benchmem cf/...

Releasing

Upon a successful test run, binaries built for each supported architecture and OS on CI are uploaded and bundled with the latest installers.

Contributing

Rough overview of the architecture

The app (in src/cf/app/app.go) declares the list of available commands. Help and flags are defined there. It will instantiate a command, and run it using the runner (in src/cf/commands/runner.go).

A command has requirements, and a run function. Requirements are used as filters before running the command. If any of them fails, the command will not run (see src/cf/requirements for examples of requirements).

When the command is run, it communicates with api using repositories (they are in src/cf/api).

Repositories are injected into the command, so tests can inject a fake.

Repositories communicate with the api endpoints through a Gateway (see src/cf/net).

Repositories return a Domain Object and an ApiResponse object.

Domain objects are data structures related to Cloud Foundry (see src/cf/domain).

ApiResponse objects convey a variety of important error conditions (see src/cf/net/api_status).

Managing dependencies

Command dependencies are managed by the commands factory. The app uses the command factory (in src/cf/commands/factory.go) to instantiate them, this allows not sharing the knowledge of their dependencies with the app itself.

As for repositories, we use the repository locator to handle their dependencies. You can find it in src/cf/api/repository_locator.go.

Example command

Create Space is a good example of command. Its tests include checking arguments, having requirements, and the actual command itself. You will find it in src/cf/commands/space/create_space.go.

Current Conventions

Creating Commands

Resources that include several commands have been broken out into their own sub-package using the Resource name. An example of this convention is the Space resource and package.

In addition, command file and methods naming follows a CRUD like convention. For example, the Space resource includes commands such a CreateSpace, ListSpaces, etc.

Creating Repositories

Although not ideal, we use the name "Repository" for API related operations as opposed to "Service". Repository was chosen to avoid confusion with Service domain objects (i.e. creating Services and Service Instances within Cloud Foundry).

By convention, Repository methods return a Domain object and an ApiResponse. Domain objects are used in both Commands and Repositories to model Cloud Foundry data. ApiResponse objects are used to communicate application errors, runtime errors, whether the resource was found, etc. This convention provides a consistent method signature across repositories.

cli's People

Contributors

acrmp avatar cdavisafc avatar cf-frontend avatar dam5s avatar danielgrippi avatar dbailey avatar drnic avatar knolleary avatar mark-rushakoff avatar matthewmcnew avatar mheath avatar michael-odell avatar mikegehard avatar oppegard avatar pmuellr avatar sclevine avatar scottruitt avatar tildewill avatar tjarratt avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.