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



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
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/core/plugin/plan_action.rb', line 31

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'
    ]

    # Loading additional registered resource plugin options
    Nucleon.loaded_plugins(:CM, :resource).each do |resource, data|
      data[:class].options(myself)
    end

    yield if block_given?
  end
end

#execute(&block) ⇒ Object


Operations



99
100
101
102
103
# File 'lib/core/plugin/plan_action.rb', line 99

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

#initialize_planObject


Utilities



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/core/plugin/plan_action.rb', line 108

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



92
93
94
# File 'lib/core/plugin/plan_action.rb', line 92

def plan
  @plan
end

#strict?Boolean


Checks

Returns:

  • (Boolean)


24
25
26
# File 'lib/core/plugin/plan_action.rb', line 24

def strict?
  false
end