dh-proteus 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d58675d1b1f45f3ca5711e42b3b52ab646b19e94c387d60184495a72e962a443
4
- data.tar.gz: 39db3dcd0b1d7945ff90226ebbe42ccbb0d95020501af66a1f46ba467ed949b9
3
+ metadata.gz: 84826a1c3ec618db8cb183f9473c01f29632303c1edaf9a4891020cbbe58b0e0
4
+ data.tar.gz: 86b594f6df68cd0a5a538f907922d1bd59a5bfb04beb612c1f57e3610bd2373b
5
5
  SHA512:
6
- metadata.gz: f08aa1849fffa7c13f4ea7399d6ae4522dac58cea95926dffe36428a946c08c9bc48cc661802c783a060072ec6bf5293c3396f5af2794e6b076e0c039b0e4a2d
7
- data.tar.gz: 366e2801c64b8c9967744e716b441882bf31c18eca254926ecbd3f6e990553f53d7b202ac11b014c769db5a4fb2f7c9dabea017a15a8310739a19b9084e9d063
6
+ metadata.gz: 0cb7eac70882a21b5d9fbfef7c8e8ebd01f8418047a9b011bf1972a60a23dd147372f01b95d99827475e7a2ae6812c79093f278cd4588dac93ba2210d769d6ea
7
+ data.tar.gz: c7892a7415cee30fb7cbf93b4f1d103db1a9b1d7a714c88006e8b668106f44b1fb040896eb201da98969d024d3201905b3fa9878e919dda529fc8d3921a40f18
data/lib/proteus/app.rb CHANGED
@@ -2,6 +2,7 @@ require 'proteus/common'
2
2
  require 'proteus/generate'
3
3
  require 'proteus/init'
4
4
  require 'proteus/global_commands/validate'
5
+ require 'proteus/global_commands/version'
5
6
  require 'proteus/context_management/context'
6
7
  require 'proteus/context_management/helpers'
7
8
  require 'proteus/templates/template_binding'
@@ -82,5 +83,6 @@ module Proteus
82
83
  subcommand('init', Proteus::Init)
83
84
 
84
85
  include Proteus::GlobalCommands::Validate
86
+ include Proteus::GlobalCommands::Version
85
87
  end
86
88
  end
@@ -35,8 +35,6 @@ module Proteus
35
35
  state_remove_command = <<~STATE_REMOVE_COMMAND
36
36
  cd #{context_path(context)} && \
37
37
  terraform state rm \
38
- -var-file=#{var_file(context, environment)} \
39
- #{aws_profile} \
40
38
  %{resource_addresses}
41
39
  STATE_REMOVE_COMMAND
42
40
 
@@ -3,8 +3,6 @@ module Proteus
3
3
  module Helpers
4
4
  include Proteus::Helpers::PathHelpers
5
5
  def contexts
6
- say "loading contexts", :green
7
-
8
6
  Dir.glob(File.join(contexts_path, "*")).collect do |context_path|
9
7
  Context.new(name: File.basename(context_path))
10
8
  end
@@ -0,0 +1,19 @@
1
+ module Proteus
2
+ module GlobalCommands
3
+ module Version
4
+
5
+ def self.included(thor_class)
6
+ thor_class.class_eval do
7
+ desc "version", "Print version information"
8
+
9
+ long_desc <<-LONGDESC
10
+ Print version information
11
+ LONGDESC
12
+ def version
13
+ say Proteus::VERSION, :green
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -85,6 +85,11 @@ module Proteus
85
85
  def module_hooks_path(context, module_name)
86
86
  File.join(module_config_path(context, module_name), 'hooks')
87
87
  end
88
+
89
+ def module_data_path(context, module_name)
90
+ File.join(module_config_path(context, module_name), 'data')
91
+ end
92
+
88
93
  end
89
94
  end
90
95
  end
@@ -78,11 +78,50 @@ module Proteus
78
78
 
79
79
  if File.file?(config_file)
80
80
  @data = YAML.load_file(config_file, {}).with_indifferent_access
81
+ load_referenced_data(@data)
82
+ end
83
+ end
84
+
85
+ def i(i)
86
+ ' ' * 2 * i
87
+ end
88
+
89
+ def read(data)
90
+ if data.end_with?('.yaml')
91
+ # single file load request
92
+ file = File.join(module_data_path(@context, @name), data)
93
+ YAML.load_file(file)
94
+ else
95
+ files = Dir.glob(
96
+ File.join(module_data_path(@context, @name), data, '*.yaml')
97
+ )
98
+
99
+ files.collect do |f|
100
+ YAML.load_file(f)
101
+ end.flatten
102
+ end
103
+ end
104
+
105
+ def load_referenced_data(data, indent: 0, debug: false)
106
+ if data.is_a?(Array)
107
+ data.each_with_index do |_, index|
108
+ load_referenced_data(data[index], indent: indent + 1)
109
+ end
110
+ elsif data.is_a?(Hash)
111
+ data.each do |key, value|
112
+ if value =~ /__load: (.*)/
113
+ data[key] = read(Regexp.last_match(1))
114
+ end
115
+ load_referenced_data(data[key], indent: indent + 1)
116
+ end
117
+ elsif debug
118
+ # scalar value
81
119
  end
82
120
  end
83
121
 
84
122
  def data?
85
123
  return false unless @data
124
+
86
125
  @data.any?
87
126
  end
88
127
 
@@ -1,5 +1,5 @@
1
1
  module Proteus
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
4
4
 
5
5
  if $0 == __FILE__
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dh-proteus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Albrecht
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-22 00:00:00.000000000 Z
11
+ date: 2019-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -202,6 +202,7 @@ files:
202
202
  - lib/proteus/generators/templates/module/module.tf.erb
203
203
  - lib/proteus/generators/templates/module/validator.rb.erb
204
204
  - lib/proteus/global_commands/validate.rb
205
+ - lib/proteus/global_commands/version.rb
205
206
  - lib/proteus/helpers.rb
206
207
  - lib/proteus/helpers/path_helpers.rb
207
208
  - lib/proteus/helpers/string_helpers.rb