Class: Mofa::CLI
- Inherits:
-
Thor
- Object
- Thor
- Mofa::CLI
- Includes:
- Config, Thor::Actions
- Defined in:
- lib/mofa/cli.rb
Constant Summary collapse
- @@option_verbose =
false- @@option_debug =
false
Class Method Summary collapse
Instance Method Summary collapse
- #config ⇒ Object
- #provision(cookbook_name_or_path) ⇒ Object
- #setup ⇒ Object
- #upload(cookbook_path) ⇒ Object
- #version ⇒ Object
Methods included from Config
Class Method Details
.option_debug ⇒ Object
107 108 109 |
# File 'lib/mofa/cli.rb', line 107 def self.option_debug @@option_debug end |
.option_verbose ⇒ Object
103 104 105 |
# File 'lib/mofa/cli.rb', line 103 def self.option_verbose @@option_verbose end |
Instance Method Details
#config ⇒ Object
82 83 84 |
# File 'lib/mofa/cli.rb', line 82 def config config_print end |
#provision(cookbook_name_or_path) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/mofa/cli.rb', line 27 def provision(cookbook_name_or_path) set_verbosity cookbook_name_or_path ||= '.' target_filter = [:target] #target_filter ||= Mofa::Config.config['profiles']['default']['target'] token = MofaCmd.generate_token hostlist = Hostlist.create(target_filter, [:service_hostlist_url], [:concrete_target]) cookbook = Cookbook.create(cookbook_name_or_path, token, [:override_mofa_secrets]) runlist_map = RunlistMap.create(cookbook, hostlist, token, [:runlist]) attributes_map = AttributesMap.create(cookbook, hostlist, token, [:runlist], [:attributes]) cmd = ProvisionCmd.new(token, cookbook) cmd.hostlist = hostlist cmd.runlist_map = runlist_map cmd.attributes_map = attributes_map cmd. = cmd.prepare cmd.execute cmd.cleanup end |
#setup ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/mofa/cli.rb', line 88 def setup set_verbosity case when !File.exists?("#{ENV['HOME']}/.mofa/config.yml") begin config_create end until config_valid? else begin config_edit end until config_valid? end end |
#upload(cookbook_path) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/mofa/cli.rb', line 59 def upload(cookbook_path) set_verbosity cookbook_path ||= '.' token = MofaCmd.generate_token cookbook = Cookbook.create(cookbook_path, token) cmd = UploadCmd.new(token, cookbook) cmd.prepare cmd.execute cmd.cleanup end |
#version ⇒ Object
76 77 78 |
# File 'lib/mofa/cli.rb', line 76 def version puts VERSION end |