Class: InfraCommand

Inherits:
PangeaCommand show all
Includes:
Constants
Defined in:
lib/pangea/cli/subcommands/infra.rb

Constant Summary collapse

NAME =
:infra

Constants included from Constants

Constants::ARTIFACT_FILE, Constants::CACHE_DIR, Constants::EXTENSIONS, Constants::PROJECT_SRC_DIRS, Constants::PROJECT_VERSION

Instance Method Summary collapse

Instance Method Details

#run(argv) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/pangea/cli/subcommands/infra.rb', line 32

def run(argv)
  Say.terminal %(planning!)
  parse(argv)

  # grab a config synth
  cfg_synth = Config.resolve_configurations

  # reject empty configurations
  if cfg_synth.empty?
    Say.terminal %(configuration empty, exiting...)
    exit
  end

  Say.terminal JSON.pretty_generate(cfg_synth)

  # preflight checks for the command execution
  # check_run
  # check_target(params[:target], cfg_synth)

  # targets = params[:target].split('.').map(&:to_sym)
  # process_target(targets, cfg_synth)

  ###########################################################################
  # modules
  # modules can be fetched from git or local path
  # modules can have a virtual environment to execute in
  ###########################################################################

  namespaces = cfg_synth[:namespace].keys.map(&:to_sym)

  namespaces.each do |namespace_name|
    namespace     = cfg_synth[:namespace][namespace_name]
    context_names = namespace.keys.map(&:to_sym)

    context_names.each do |cn|
      context = namespace[cn]
      modules = context[:modules]

      modules.each do |mod|
        PangeaModule.process(mod)
      end
    end
  end

  ###########################################################################

  # provide some kind of default exit of the command execution
  exit
end