Class: Pipedream::Schedule
Constant Summary
Dsl::Schedule::PROPERTIES
Instance Method Summary
collapse
Methods included from Evaluate
#evaluate
#cron, #rate, #rule_event
Constructor Details
#initialize(options = {}) ⇒ Schedule
Returns a new instance of Schedule.
6
7
8
9
10
|
# File 'lib/pipedream/schedule.rb', line 6
def initialize(options={})
@options = options
@schedule_path = options[:schedule_path] || get_schedule_path
@properties = default_properties
end
|
Instance Method Details
#default_properties ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/pipedream/schedule.rb', line 45
def default_properties
description = "CodePipeline #{@options[:full_pipeline_name]}"
name = description.gsub(" ", "-").downcase
{
description: description,
name: name,
state: "ENABLED",
targets: [{
arn: "arn:aws:codepipeline:#{aws.region}:#{aws.account}:#{@options[:full_pipeline_name]}",
role_arn: { "Fn::GetAtt": "EventsRuleRole.Arn" }, id: "CodePipelineTarget",
}]
}
end
|
#run ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/pipedream/schedule.rb', line 12
def run
return unless File.exist?(@schedule_path)
old_properties = @properties.clone
evaluate(@schedule_path)
@properties[:schedule_expression] = @schedule_expression if @schedule_expression
set_rule_event! if @rule_event_props
return if old_properties == @properties
resource = {
events_rule: {
type: "AWS::Events::Rule",
properties: @properties
},
events_rule_role: events_rule_role,
}
CfnCamelizer.transform(resource)
end
|
#set_rule_event! ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/pipedream/schedule.rb', line 32
def set_rule_event!
props = @rule_event_props
if props.key?(:detail)
description = props.key?(:description) ? props.delete(:description) : rule_description
rule_props = { event_pattern: props, description: description }
else props[:description] ||= rule_description
rule_props = props
end
@properties.merge!(rule_props)
end
|