Skip to content

Commit b1a93f6

Browse files
authored
Merge pull request #131 from phase2/develop
2.1.0
2 parents 9794851 + 7f4c4be commit b1a93f6

31 files changed

+621
-337
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
dist
22
build
33
vendor
4+
vendor.orig
45
.idea
56
.outrigger.yml
67
.DS_Store

.goreleaser.rc.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# One release file to rule them all
2+
project_name: outrigger-cli
3+
4+
# Platforms/architectures to target
5+
builds:
6+
- binary: rig
7+
main: ./cmd/main.go
8+
env:
9+
- CGO_ENABLED=0
10+
goos:
11+
- windows
12+
- darwin
13+
- linux
14+
goarch:
15+
- amd64
16+
17+
# Generating the archives
18+
archive:
19+
name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
20+
format: tar.gz
21+
format_overrides:
22+
- goos: windows
23+
format: zip
24+
replacements:
25+
darwin: macOS
26+
27+
# Publishing releases to GitHub
28+
release:
29+
github:
30+
owner: phase2
31+
name: rig
32+
prerelease: true
33+
34+
# Build linux packages
35+
fpm:
36+
vendor: Phase2
37+
homepage: https://outrigger.sh/
38+
maintainer: Outrigger <outrigger@phase2technology.com>
39+
description: Containerized development environment for projects. See https://docs.outrigger.sh for documentation.
40+
license: MIT
41+
formats:
42+
- deb
43+
- rpm
44+
dependencies:
45+
- docker-ce

CONTRIBUTING.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# CONTRIBUTING
2+
3+
Thank you for considering contributing to the Outrigger CLI!
4+
5+
## Quality Contributions
6+
7+
* Make sure your branch will compile.
8+
* Make sure your branch passes our static analysis checks.
9+
* Make sure your branch conforms with go fmt standards.
10+
* Manually test your changes.
11+
12+
## User Interactions
13+
14+
One of the key goals of this project is to promote a positive developer
15+
experience. Every interaction should be thought of with the following points:
16+
17+
* Are you providing the user with enough context about what's being asked or being done?
18+
* Does the user expect to wait? Might the user think the tool stalled?
19+
* Is there black box business happening that could be made more transparent?
20+
21+
We have a slightly complex logging API to support addressing these concerns.
22+
(See ./util/logging.go)
23+
24+
Here are a few conventions:
25+
26+
* **Starting a task that could take more than 5 seconds:**
27+
* `cmd.out.Spin("Preparing the sauce")`
28+
* **Use the correct method to log operational results: (Pick one)**
29+
* `cmd.out.Info("Sauce is Ready.")`
30+
* `cmd.out.Warning("Sauce is burnt on the bottom.")`
31+
* `cmd.out.Error("Discard this sauce and try again.")`
32+
* **Going to send some contextual notes to the user**:
33+
1. `cmd.out.NoSpin()` if currently using the spinner.
34+
2. `cmd.out.Info("Sauce exists.")`
35+
4. `cmd.out.Verbose("The ingredients of the sauce include tomato, salt, black pepper, garlic...")`
36+
* **Command has executed and is successful. Please no notification:**
37+
```
38+
cmd.out.Info("Enjoy your dinner.")
39+
return cmd.Success("")
40+
```
41+
* **Command has executed and is successful. Get a notification too!**
42+
```
43+
return cmd.Success("Enjoy your dinner.")
44+
```
45+
* **Command failed:**
46+
```
47+
message := "Cooking sauce is hard, we failed"
48+
cmd.out.Error("%s: %s", message, err.Error())
49+
return cmd.Failure(message)
50+
```
51+
52+
## Development Environment Setup
53+
54+
### Developing with Docker
55+
56+
You can use the Docker integration within this repository to facilitate development in lieu of setting up a
57+
local golang environment. Using docker-compose, run the following commands:
58+
59+
```bash
60+
docker-compose run --rm install
61+
docker-compose run --rm compile
62+
```
63+
64+
This will produce a working OSX binary at `build/darwin/rig`.
65+
66+
If you change a dependency in `Gopkg.toml` you can update an individual package dependency with:
67+
68+
```bash
69+
docker-compose run --rm update [package]
70+
```
71+
72+
If you want to update all packages use:
73+
74+
```bash
75+
docker-compose run --rm update
76+
```
77+
78+
If you want to run the static analysis checks:
79+
80+
```bash
81+
docker-compose run --rm lint
82+
```
83+
84+
If you want to run go fmt against the codebase:
85+
```bash
86+
docker-compose run --rm base go fmt ./...
87+
```
88+
89+
### Developing Locally
90+
91+
Install go from homebrew using the flag to include common cross-compiler targets (namely Darwin, Linux, and Windows)
92+
93+
```bash
94+
brew install go --with-cc-common
95+
brew install dep
96+
brew tap goreleaser/tap
97+
brew install goreleaser/tap/goreleaser
98+
```
99+
100+
Setup `$GOPATH` and `$PATH` in your favorite shell (`~/.bashrc` or `~/.zshrc`)
101+
102+
```bash
103+
export GOPATH=$HOME/Projects
104+
export PATH=$PATH:$GOPATH/bin
105+
```
106+
107+
Checkout the code into your `$GOPATH` in `$GOPATH/src/github.com/phase2/rig`
108+
109+
Get all the dependencies
110+
111+
```bash
112+
# Install the project dependencies into $GOPATH
113+
cd $GOPATH/src/github.com/phase2/rig
114+
dep ensure
115+
```
116+
117+
#### Building Rig
118+
119+
If you want to build `rig` locally for your target platform, simply run the following command:
120+
121+
```bash
122+
GOARCH=amd64 GOOS=darwin go build -o build/darwin/rig cmd/main.go
123+
```
124+
125+
This command targets an OS/Architecture (Darwin/Mac and 64bit) and puts the resultant file in the `build/darwin/`
126+
with the name `rig`. Change `GOARCH` and `GOOS` if you need to target a different platform

Gopkg.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,7 @@
5353
name = "github.com/martinlindhe/notify"
5454
branch = "master"
5555

56+
[[constraint]]
57+
name = "github.com/slok/gospinner"
58+
version = "0.1.0"
59+

README.md

Lines changed: 32 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,52 @@
11
# Rig - Outrigger CLI [![Build Status](https://travis-ci.org/phase2/rig.svg?branch=develop)](https://travis-ci.org/phase2/rig)
22

3-
> A CLI for managing the Outrigger container-driven development stack.
3+
> A CLI for managing the Outrigger's container-driven development stack.
44
55
See the [documentation for more details](http://docs.outrigger.sh).
6+
See the [CONTRIBUTING.md](./CONTRIBUTING.md) for developer documentation.
67

7-
Use this readme when you want to develop the Outrigger CLI.
8+
## Built on Dependencies
89

9-
Setup
10-
------
11-
12-
Install go from homebrew using the flag to include common cross-compiler targets (namely Darwin, Linux, and Windows)
13-
14-
```bash
15-
brew install go --with-cc-common
16-
brew install dep
17-
brew tap goreleaser/tap
18-
brew install goreleaser/tap/goreleaser
19-
```
20-
21-
Setup `$GOPATH` and `$PATH` in your favorite shell (`~/.bashrc` or `~/.zshrc`)
22-
23-
```bash
24-
export GOPATH=$HOME/Projects
25-
export PATH=$PATH:$GOPATH/bin
26-
```
27-
28-
Checkout the code into your `$GOPATH` in `$GOPATH/src/github.com/phase2/rig`
29-
30-
Get all the dependencies
31-
32-
```bash
33-
# Install the project dependencies into $GOPATH
34-
cd $GOPATH/src/github.com/phase2/rig
35-
dep ensure
36-
```
37-
38-
Developing Locally
39-
-------------------
40-
41-
If you want to build `rig` locally for your target platform, simply run the following command:
42-
43-
```bash
44-
GOARCH=amd64 GOOS=darwin go build -o build/darwin/rig cmd/main.go
45-
```
46-
47-
This command targets an OS/Architecture (Darwin/Mac and 64bit) and puts the resultant file in the `build/darwin/`
48-
with the name `rig`. Change `GOARCH` and `GOOS` if you need to target a different platform
49-
50-
Developing with Docker
51-
-----------------------
52-
53-
You can use the Docker integration within this repository to facilitate development in lieu of setting up a
54-
local golang environment. Using docker-compose, run the following commands:
55-
56-
```bash
57-
docker-compose run --rm install
58-
docker-compose run --rm compile
59-
```
60-
61-
This will produce a working OSX binary at `build/darwin/rig`.
62-
63-
If you change a dependency in `Gopkg.toml` you can update an individual package dependency with:
64-
65-
```bash
66-
docker-compose run --rm update [package]
67-
```
68-
69-
If you want to update all packages use:
70-
71-
```bash
72-
docker-compose run --rm update
73-
```
10+
We make use of a few key libraries to do all the fancy stuff that the `rig` CLI will do.
7411

12+
* https://github.com/urfave/cli
13+
* The entire CLI framework from helps text to flags.
14+
This was an easy cli to build b/c of this library.
15+
* https://github.com/fatih/color
16+
* All the fancy terminal color output
17+
* https://github.com/bitly/go-simplejson
18+
* The JSON parse and access library used primarily with the output
19+
of `docker-machine inspect`
20+
* https://gopkg.in/yaml.v2
21+
* The YAML library for parsing/reading YAML files
22+
* https://github.com/martinlindhe/notify
23+
* Cross-platform desktop notifications
7524

76-
Release
77-
-------
25+
## Release Instructions
7826

7927
We use [GoReleaser](https://goreleaser.com) to handle nearly all of our release concerns. GoReleaser will handle
8028

8129
* Building for all target platforms
82-
* Create a GitHub release on our project page based on tag
83-
* Create archive file for each target platform and attach it to the GitHub release
84-
* Update the Homebrew formula and publish it
85-
* Create .deb and .rpm packages for linux installations
30+
* Creating a GitHub release on our project page based on tag
31+
* Creating archive files for each target platform and attach it to the GitHub release
32+
* Creating .deb and .rpm packages for linux installations and attaching those to the GitHub release
33+
* Updating the Homebrew formula and publish it
34+
35+
### To create a new release of rig:
8636

87-
To create a new release of rig:
8837
* Get all the code committed to `master`
89-
* Tag master with the new version number
38+
* Tag master with the new version number `git tag 2.1.0 && git push --tags`
9039
* Run `docker-compose run --rm goreleaser`
9140
* ...
9241
* Profit!
9342

43+
### To create a new release candidate (RC) of rig:
9444

95-
Dependencies
96-
-------------
45+
If we want to roll out an RC to GitHub for folks to test, we simply need to run with a different GoReleaser
46+
configuration that does not publish to homebrew, just to a GitHub release that is marked preproduction.
9747

98-
We make use of a few key libraries to do all the fancy stuff that the `rig` CLI will do.
99-
100-
* https://github.com/urfave/cli
101-
* The entire CLI framework from helps text to flags. This was an easy cli to build b/c of this library
102-
* https://github.com/fatih/color
103-
* All the fancy terminal color output
104-
* https://github.com/bitly/go-simplejson
105-
* The JSON parse and access library used primarily with the output of `docker-machine inspect`
106-
* https://gopkg.in/yaml.v2
107-
* The YAML library for parsing/reading YAML files
48+
* Get all the code committed to `develop`
49+
* Tag develop with the new version number `git tag 2.1.0-rc1 && git push --tags`
50+
* Run `docker-compose run --rm goreleaser --config .goreleaser.rc.yml`
51+
* ...
52+
* Profit!

commands/command.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,26 @@ func (cmd *BaseCommand) Before(c *cli.Context) error {
3939

4040
// Success encapsulates the functionality for reporting command success
4141
func (cmd *BaseCommand) Success(message string) error {
42+
// Handle success messaging.
4243
if message != "" {
43-
cmd.out.Info.Println(message)
44+
cmd.out.Info(message)
4445
util.NotifySuccess(cmd.context, message)
4546
}
47+
48+
// If there is an active spinner wrap it up. This is not placed before the logging above so commands can rely on
49+
// cmd.Success to set the last spinner status in lieu of an extraneous log entry.
50+
cmd.out.NoSpin()
51+
4652
return nil
4753
}
4854

49-
// Error encapsulates the functionality for reporting command failure
50-
func (cmd *BaseCommand) Error(message string, errorName string, exitCode int) error {
55+
// Failure encapsulates the functionality for reporting command failure
56+
func (cmd *BaseCommand) Failure(message string, errorName string, exitCode int) error {
57+
// Make sure any running spinner halts.
58+
cmd.out.NoSpin()
59+
// Handle error messaging.
5160
util.NotifyError(cmd.context, message)
61+
5262
return cli.NewExitError(fmt.Sprintf("ERROR: %s [%s] (%d)", message, errorName, exitCode), exitCode)
5363
}
5464

@@ -64,6 +74,6 @@ func (cmd *BaseCommand) NewContext(name string, flags []cli.Flag, parent *cli.Co
6474
// SetContextFlag set a flag on the provided context
6575
func (cmd *BaseCommand) SetContextFlag(ctx *cli.Context, name string, value string) {
6676
if err := ctx.Set(name, value); err != nil {
67-
cmd.out.Error.Fatal(err)
77+
cmd.out.Channel.Error.Fatal(err)
6878
}
6979
}

commands/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (cmd *Config) Run(c *cli.Context) error {
5353
os.Stdout.Write(output)
5454
}
5555
} else {
56-
return cmd.Error(fmt.Sprintf("No machine named '%s' exists.", cmd.machine.Name), "MACHINE-NOT-FOUND", 12)
56+
return cmd.Failure(fmt.Sprintf("No machine named '%s' exists.", cmd.machine.Name), "MACHINE-NOT-FOUND", 12)
5757
}
5858

5959
return cmd.Success("")

0 commit comments

Comments
 (0)