Skip to content

Instantly share code, notes, and snippets.

@tedsuo
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tedsuo/2df8b650084d0da63fb8 to your computer and use it in GitHub Desktop.
Save tedsuo/2df8b650084d0da63fb8 to your computer and use it in GitHub Desktop.

This is a minimal-ish set of instruction to set up a freshly imaged OS X workstation for working on Diego. If you've already used the Pivotal sprout recipes to provision your machine, you might have a bad time.

Pivotal Workstation Conveniences

These are nice for the core developer team, feel free to skip this section:

  • Download Chrome using Safari, and install it.
  • Download Wraparound from the web.
  • Download ShiftIt.zip from github.com/onsi/shiftit.
  • Get Flycut from the App Store.
  • Download iTerm 2 from the web.

Homebrew

  • Download Homebrew using a browser, and install it.
  • This will prompt you to accept installation of Xcode developer tools as well.

Bash

  • touch ~/.bash_profile if it does not already exist

GIT

  • brew install git
  • brew install bash-git-prompt and follow homebrew directions.

Sublime

  • Download Sublime Text 3 from the web.
  • To enable the subl command line tool, you'll need to create a symlink. Google it.

Languages and Databases

  • brew install go
  • brew install ruby
  • brew install mysql
  • brew install postgresql

MySQL and PostgreSQL are needed for work on Cloud Controller, the BOSH micro CLI plugin, and maybe other things. To ensure MySQL and PostgreSQL services are always running, you'll need to do the following (true at the time this was written):

$ ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
$ launchctl load -w ~/Library/LaunchAgents/*mysql*
$ ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
$ launchctl load -w ~/Library/LaunchAgents/*postgresql*

In order to work with Cloud Controller, you will need to create a postgres role in the database with the appropriate permissions:

$ createdb
$ psql
> create role postgres with createdb login superuser

You need some similar setup with MySQL:

$ mysql -u root
> set password for 'root'@'localhost' = password('password');

Direnv

We use direnv to make setting the PATH and GOPATH easier as we switch between projects. You can get it with brew install direnv. If you cd into a directory using an .envrc, you will be asked to explicitly allow it, so it will automatically alter your environment without your consent.

Git Aliases and Bash Profile

For convenience, you can create/update your ~/.gitconfig and ~/.bash_profile to look like the two other files in this Gist. Create a ~/.git-authors file if you're using the git-duet gem to pair authors and committers on commits. The one below shows a sample of what it will start to look like.

Checkman

Follow the README instructions at github.com/cppforlife/checkman to install it. This tool allows you to monitor the status of builds in a "Checkfile". The Diego checkfile is in a private repository.

Repositories

  • Clone git@github.com:pivotal-cf/diego-checkman.git into the ~/Checkman directory. This will allow Checkman to show you the status of the Diego builds.
  • Create a directory ~/workspace and clone cloudfoundry/cf-release, cloudfoundry-incubator/diego-release, cloudfoundry/bosh-lite and concourse/concourse in your workspace.

The code we work on will be in the diego-release and cf-release repositories (and their submodules). bosh-lite provides a local environment to which we can deploy both release and run acceptance tests. concourse will provide the fly CLI, enabling us to run builds using a local VM running the Concourse CI system.

Vagrant and Virtualbox

Get them from the web.

Get BOSH Lite working

  • gem install bosh_cli
  • Follow the README instructions in the repo to get the box up and running
  • You may need to brew install wget to download a warden stemcell to use for your BOSH Lite deployments

Concourse

  • Make a directory (e.g. ~/deployments/concourse, cd into it, issue a vagrant init concourse/lite and then vagrant up.
  • export ATC_URL=http://192.168.100.4:8080
  • Go to the ~/workspace/concourse directory, and go install github.com/concourse/fly.

Spiff

Some of our older scripts use spiff to generate deployment manifests for cf-release and diego-release. Download the latest release from Github at https://github.com/cloudfoundry-incubator/spiff.

## GIT ALIASES
alias gst='git status'
alias duet='git duet --global'
alias solo='git solo --global'
## BUNDLE ALIASES
alias be='bundle exec'
alias bx='be'
## DIEGO ENV
export HISTTIMEFORMAT="%F %T "
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$PATH
export PATH=$HOME/workspace/concourse/bin:$PATH # for 'fly'
export EDITOR=vim
export GIT_EDITOR=vim
eval "$(direnv hook bash)"
## TERMINAL CTRL SEQUENCES
stty -ixon # disable START/STOP output control; frees up CTRL+S for bash history forward search
stty discard undef # enables CTRL+O; see http://apple.stackexchange.com/questions/3253/ctrl-o-behavior-in-terminal-app
## HOMEBREW ENV (PATH)
function path_without_usr_local_bin () {
IFS=':'
t=($PATH)
unset IFS
t=(${t[@]%%*/usr/local/bin*})
IFS=':'
echo "${t[*]}"
unset IFS
}
export PATH=/usr/local/bin:`path_without_usr_local_bin`
unset path_without_usr_local_bin
## MORE GO ENV STUFF ?
# see https://github.com/go-lang-plugin-org/go-lang-idea-plugin/blob/master/Missing%20ENV.md
launchctl setenv GOPATH $(go env GOPATH | sed 's/[^"]*"\([^"]*\).*/\1/')
launchctl setenv GOROOT $(go env GOROOT | sed 's/[^"]*"\([^"]*\).*/\1/')
## FILE NAVIGATION CONVENIENCE
function goto {
local p
local f
for p in `echo $GOPATH | tr ':' '\n'`; do
f=`find ${p}/src -type d -not -path '*/.*' | grep "${1}" | awk '{ print length, $0 }' | sort -n | cut -d" " -f2- | head -n 1`
if [ -n "$f" ]; then
cd $f
return
fi
done
workto "$@"
}
function workto {
local p
local f
f=`find ~/workspace -type d -not -path '*/.*' | grep "${1}" | awk '{ print length, $0 }' | sort -n | cut -d" " -f2- | head -n 1`
if [ -n "$f" ]; then
cd $f
return
fi
}
[core]
pager = less -FXRS -x2
[alias]
st = status
co = checkout
ci = duet-commit
plog = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
ps = push --recurse-submodules=check
[apply]
whitespace = nowarn
[color]
branch = auto
diff = auto
interactive = auto
status = auto
ui = auto
[branch]
autosetupmerge = true
[rebase]
autosquash = true
[push]
default = simple
[credential]
helper = cache --timeout=32400
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
trustExitCode = true
[url "git@github.com:"]
pushInsteadOf = https://github.com/
[user]
name = Amit Gupta
email = amitkgupta84@gmail.com
authors:
sp: Some Pivot; spivot
ag: Another Guy; aguy
dm: Dojo Member
email:
domain: pivotal.io
email_addresses:
dm: dojo-member@some-company.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment