Class: Nucleon::Plugin::PlanAction

Inherits:
Object
  • Object
show all
Includes:
Mixin::Action::Project
Defined in:
lib/core/plugin/plan_action.rb

Instance Method Summary collapse

Instance Method Details

#configureObject


Property accessor / modifiers



24
25
26
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/core/plugin/plan_action.rb', line 24

def configure
  super do
    register_plan_provider :plan_provider, Nucleon.type_default(:CM, :plan), [
      'cm.action.plan.base.options.plan',
      'cm.action.plan.base.errors.plan'
    ]
    register_str :plan_path, Dir.pwd, 'cm.action.plan.base.options.plan_path'

    register_configuration_provider :manifest_provider, :file, [
      'cm.action.plan.base.options.manifest_provider',
      'cm.action.plan.base.errors.manifest_provider'
    ]
    register_str :manifest, 'plan.yaml', 'cm.action.plan.base.options.manifest'

    register_configuration_provider :config_provider, :directory, [
      'cm.action.plan.base.options.config_provider',
      'cm.action.plan.base.errors.config_provider'
    ]
    register_str :config_path, Dir.pwd, 'cm.action.plan.base.options.config_path'

    register_configuration_provider :token_provider, :file, [
      'cm.action.plan.base.options.token_provider',
      'cm.action.plan.base.errors.token_provider'
    ]
    register_directory :token_path, Dir.pwd, [
      'cm.action.plan.base.options.token_path',
      'cm.action.plan.base.errors.token_path'
    ]
    register_str :token_file, 'tokens.json', 'cm.action.plan.base.options.token_file'

    register_directory :key_path, Dir.pwd, [
      'cm.action.plan.base.options.key_path',
      'cm.action.plan.base.errors.key_path'
    ]
    register_bool :trap, false, 'cm.action.plan.options.trap'

    register_sequence_provider :sequence_provider, Nucleon.type_default(:CM, :sequence), [
      'cm.action.plan.base.options.sequence_provider',
      'cm.action.plan.base.errors.sequence_provider'
    ]
    register_batch_provider :batch_provider, Nucleon.type_default(:CM, :batch), [
      'cm.action.plan.base.options.batch_provider',
      'cm.action.plan.base.errors.batch_provider'
    ]
    register_resource_provider :default_resource_provider, Nucleon.type_default(:CM, :resource), [
      'cm.action.plan.base.options.default_resource_provider',
      'cm.action.plan.base.errors.default_resource_provider'
    ]

    yield if block_given?
  end
end

#execute(&block) ⇒ Object


Operations



87
88
89
90
91
# File 'lib/core/plugin/plan_action.rb', line 87

def execute(&block)
  super do
    block.call if initialize_plan
  end
end

#initialize_planObject


Utilities



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/core/plugin/plan_action.rb', line 96

def initialize_plan
  @plan = CM.plan(plugin_name, extended_config(:plan, {
    :action_settings           => Nucleon::Config.ensure(settings).export,
    :path                      => settings[:plan_path],
    :config_provider           => settings[:config_provider],
    :config_path               => settings[:config_path],
    :key_directory             => settings[:key_path],
    :manifest_provider         => settings[:manifest_provider],
    :manifest_file             => settings[:manifest],
    :token_provider            => settings[:token_provider],
    :token_directory           => settings[:token_path],
    :token_file                => settings[:token_file],
    :trap                      => settings[:trap],
    :sequence_provider         => settings[:sequence_provider],
    :batch_provider            => settings[:batch_provider],
    :default_resource_provider => settings[:default_resource_provider]
  }), settings[:plan_provider])
end

#normalize(reload) ⇒ Object


Constuctor / Destructor



15
16
17
18
19
# File 'lib/core/plugin/plan_action.rb', line 15

def normalize(reload)
  super do
    yield if block_given?
  end
end

#planObject


Properties



80
81
82
# File 'lib/core/plugin/plan_action.rb', line 80

def plan
  @plan
end