3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
|
# File 'lib/aws_s3_website_sync/runner.rb', line 3
def self.run(
aws_access_key_id:,
aws_secret_access_key:,
aws_default_region:,
s3_bucket:,
auto_approve:,
distribution_id:,
build_dir:,
output_changset_path:,
ignore_files:,
silent:
)
$logger.info "Runner.run"
AwsS3WebsiteSync::Plan.run(
output_changeset_path: output_changset_path,
build_dir: build_dir,
aws_access_key_id: aws_access_key_id,
aws_secret_access_key: aws_secret_access_key,
s3_bucket: s3_bucket,
aws_default_region: aws_default_region,
ignore_files: ignore_files
)
AwsS3WebsiteSync::Preview.run(
changeset_path: output_changset_path,
silent: silent
)
json = File.read output_changset_path
data = JSON.parse json
items = data.select{|t| %w{create update delete}.include?(t["action"]) }
if items.count.zero?
puts "no changes to apply, quitting....."
else
puts "Execute the plan? Type: yes or no"
if auto_approve == "true"
AwsS3WebsiteSync::Apply.run(
changeset_path: output_changset_path,
build_dir: build_dir,
aws_access_key_id: aws_access_key_id,
aws_secret_access_key: aws_secret_access_key,
s3_bucket: s3_bucket,
aws_default_region: aws_default_region,
distribution_id: distribution_id,
caller_reference: File.basename(output_changset_path,'.json')
)
else
print "> "
case (STDIN.gets.chomp)
when 'yes'
AwsS3WebsiteSync::Apply.run(
changeset_path: output_changset_path,
build_dir: build_dir,
aws_access_key_id: aws_access_key_id,
aws_secret_access_key: aws_secret_access_key,
s3_bucket: s3_bucket,
aws_default_region: aws_default_region,
distribution_id: distribution_id,
caller_reference: File.basename(output_changset_path,'.json')
)
when 'no'
puts "quitting...."
end
end
end
end
|