Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Add DEPENDENCIES file and source Vagrant and tests versions from it.
Browse files Browse the repository at this point in the history
- One unique file to list all dependencies and dependencies' versions (except Go, currently defined in `build/Dockerfile`).
- Custom versions can now be injected into Vagrant VMs.
- Vagrant dev VMs, Vagrant test VMs, and `run-integration-tests.sh` all source from `DEPENDENCIES`, to keep things 'DRY'.
- Vagrant versions can be overriden using environment variables, like it was possible in `run-integration-tests.sh`.
  • Loading branch information
marccarre committed Feb 13, 2017
1 parent 3ce8aec commit 1b45e86
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
3 changes: 3 additions & 0 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DOCKER_VERSION=1.11.2
KUBERNETES_VERSION=1.5.2
KUBERNETES_CNI_VERSION=0.3.0.1
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
ansible.playbook = 'tools/config_management/setup_weave-net_dev.yml'
ansible.extra_vars = {
go_version: GO_VERSION
}
}.merge(ansibleize(get_dependencies_version_from_file_and_env()))
end
end

Expand Down
1 change: 1 addition & 0 deletions test/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ END
host.vm.provision 'ansible' do |ansible|
ansible.limit = 'all' # Disable default limit to connect to all the machines
ansible.playbook = '../tools/config_management/setup_weave-net_test.yml'
ansible.extra_vars = ansibleize(get_dependencies_version_from_file_and_env())
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions test/run-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ PLAYBOOK=${PLAYBOOK:-setup_weave-net_test.yml}
TESTS=${TESTS:-}
RUNNER_ARGS=${RUNNER_ARGS:-""}
# Dependencies' versions:
DOCKER_VERSION=${DOCKER_VERSION:-1.11.2}
KUBERNETES_VERSION=${KUBERNETES_VERSION:-1.5.2}
KUBERNETES_CNI_VERSION=${KUBERNETES_CNI_VERSION:-0.3.0.1}
DOCKER_VERSION=${DOCKER_VERSION:-"$(grep -oP "(?<=DOCKER_VERSION=).*" "$DIR/../DEPENDENCIES")"}
KUBERNETES_VERSION=${KUBERNETES_VERSION:-"$(grep -oP "(?<=KUBERNETES_VERSION=).*" "$DIR/../DEPENDENCIES")"}
KUBERNETES_CNI_VERSION=${KUBERNETES_CNI_VERSION:-"$(grep -oP "(?<=KUBERNETES_CNI_VERSION=).*" "$DIR/../DEPENDENCIES")"}
# Google Cloud Platform image's name & usage (only used when PROVIDER is gcp):
IMAGE_NAME=${IMAGE_NAME:-"$(echo "$APP-docker$DOCKER_VERSION-k8s$KUBERNETES_VERSION-k8scni$KUBERNETES_CNI_VERSION" | sed -e 's/[\.\_]*//g')"}
DISK_NAME_PREFIX=${DISK_NAME_PREFIX:-$NAME}
Expand Down
14 changes: 14 additions & 0 deletions vagrant-common.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
VAGRANT_IMAGE = 'bento/ubuntu-16.04'
VAGRANTFILE_API_VERSION = '2'

def get_dependencies_version_from_file_and_env()
dependencies_file = File.join(File.dirname(__FILE__), 'DEPENDENCIES')
# Read default version from the DEPENDENCIES file:
versions = File.readlines(dependencies_file).map{|line| line.strip.split('=')}.to_h
# Override with environment variables if defined:
versions.each do |k,v|
versions[k] = ENV.key?(k) ? ENV[k] : v
end
end

def ansibleize(h)
h.map{|k,v| [k.downcase, v]}.to_h
end

def get_go_version_from_build_dockerfile()
go_regexp = /FROM golang:(\S*).*?/
dockerfile_path = File.expand_path(File.join(File.dirname(__FILE__), 'build', 'Dockerfile'))
Expand Down

0 comments on commit 1b45e86

Please sign in to comment.