Skip to content

Instantly share code, notes, and snippets.

@EdHurtig
Created January 22, 2015 16:06
Show Gist options
  • Save EdHurtig/ff35c06e6800ef7b040b to your computer and use it in GitHub Desktop.
Save EdHurtig/ff35c06e6800ef7b040b to your computer and use it in GitHub Desktop.
Alters the `kitchen` command to easily provide a kitchen configuration to kitchen.
# Usage
# kitchen cloud test # Will run 'kitchen test' with 'KITCHEN_YAML=.kitchen.cloud.yml'
# kitchen local test # Will run 'kitchen test' with 'KITCHEN_YAML=.kitchen.local.yml'
# kitchen test # Will run 'kitchen test' without a KITCHEN_YAML specified
kitchen() {
if [[ 'cloud,local,dev,prod,stage' == *$1* ]]; then
echo "Starting kitchen with configuration file '.kitchen.$1.yml'"
if [[ -f ".kitchen.$1.yml" ]]; then
command export KITCHEN_YAML=.kitchen.cloud.yml
shift 1
command kitchen "$@"
else
echo "Could not find Configuration file '.kitchen.$1.yml', quitting"
fi
else
echo "Starting kitchen without an override 'KITCHEN_YAML'"
command unset KITCHEN_YAML
command kitchen "$@"
fi
}
@jeffbyrnes
Copy link

It should be pointed out that if a .kitchen.local.yml is present, it will automatically override as the config, unless you’ve specified the KITCHEN_YAML var. So you might not need it here… food for thought.

@jeffbyrnes
Copy link

Also, line 10 should probably be:

command export KITCHEN_YAML=".kitchen.${1}.yaml"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment