lib/cloudstrap/config.rb in cloudstrap-0.42.9.pre vs lib/cloudstrap/config.rb in cloudstrap-0.43.0.pre
- old
+ new
@@ -1,9 +1,11 @@
require 'contracts'
require 'pastel'
require 'yaml'
+require_relative 'component_versions'
+
module Cloudstrap
class Config
include ::Contracts::Core
include ::Contracts::Builtin
@@ -112,10 +114,38 @@
def artifact_prefix
lookup(:artifact_prefix) { '/downloads' }
end
Contract None => String
+ def hce_prefix
+ lookup(:hce_prefix) do
+ "#{artifact_prefix}/hce"
+ end.squeeze('/')
+ end
+
+ Contract None => String
+ def hce_metadata
+ lookup(:hce_metadata) do
+ "#{hce_prefix}/dist/v2/linux-amd64.json"
+ end.squeeze('/')
+ end
+
+ Contract None => String
+ def hsm_prefix
+ lookup(:hsm_prefix) do
+ "#{artifact_prefix}/hsm"
+ end.squeeze('/')
+ end
+
+ Contract None => String
+ def hsm_metadata
+ lookup(:hsm_metadata) do
+ "#{hsm_prefix}/cli/update/linux-amd64.json"
+ end.squeeze('/')
+ end
+
+ Contract None => String
def hcp_prefix
lookup(:hcp_prefix) do
"#{artifact_prefix}/hcp"
end.squeeze('/')
end
@@ -132,11 +162,11 @@
alias hcp_origin hcp_bootstrap_origin
Contract None => String
def hcp_bootstrap_version
- lookup(:hcp_bootstrap_version) { '1.0.21-0-g77ce3d1' }
+ lookup(:hcp_bootstrap_version) { latest.hcp }
end
alias hcp_version hcp_bootstrap_version
Contract None => String
@@ -230,9 +260,14 @@
end
Contract None => String
def path
@path ||= File.expand_path [dir, file].join('/')
+ end
+
+ Contract None => ComponentVersions
+ def latest
+ @latest ||= ComponentVersions.new self
end
Contract None => Hash
def config
@settings ||= if File.exist?(path)