From 1c4a01d52c0c2986e08454afad5d6ed2177fcf52 Mon Sep 17 00:00:00 2001 From: Marc CARRE Date: Wed, 26 Oct 2016 11:16:11 +0100 Subject: [PATCH] Read Go version from Dockerfile in order to keep things 'DRY'. --- vagrant-common.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vagrant-common.rb b/vagrant-common.rb index 704d024e..9c0c6b5b 100644 --- a/vagrant-common.rb +++ b/vagrant-common.rb @@ -1,4 +1,8 @@ -$go_version = "1.5.2" +$go_regexp = /FROM golang:(\S*).*?/ +$go_version = File.readlines("build/Dockerfile").first { |line| line.match($go_regexp) }.match($go_regexp).captures.first +if $go_version.nil? + raise ArgumentError.new("Failed to read Go version from Dockerfile.") +end $go_path = "/usr/local/go/bin"