Skip to content

Commit 06f848e

Browse files
authored
Merge pull request #221 from reidmv/code-sync-status
Create sample plan to display code sync status
2 parents 234cbc4 + 24d93eb commit 06f848e

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

plans/util/code_sync_status.pp

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# @api private
2+
plan peadm::util::code_sync_status (
3+
Peadm::SingleTargetSpec $targets,
4+
) {
5+
$data = run_task('peadm::code_sync_status', $targets).first.value
6+
7+
# Print a table of summary status
8+
out::message(
9+
format::table({
10+
title => 'Summary',
11+
rows => $data['environments'].reduce([['Overall sync status', $data['sync']]]) |$memo, $val| {
12+
$memo << ["${val[0]} environment in sync", $val[1]['sync']] }}))
13+
14+
# Print a server status table, one for each environment
15+
$data['environments'].each |$env, $_| {
16+
out::message(
17+
format::table({
18+
title => "Server sync status - ${env}",
19+
head => ['Server', 'In Sync', 'Commit'],
20+
rows => $data['environments'][$env]['servers'].reduce([]) |$memo, $val| {
21+
$memo << [$val[0], $val[1]['sync'], $val[1]['commit']] }}))
22+
}
23+
24+
return('Done')
25+
}

tasks/code_sync_status.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,12 @@ def sync_status
9898
environmentstocheck.each do |environment|
9999
results[environment] = check_environment_code(environment, servers, status_call)
100100
end
101+
101102
# Confirm are all environments being checked in sync
102-
results['sync'] = results.all? { |_k, v| v['sync'] == true }
103-
results
103+
{
104+
'environments' => results,
105+
'sync' => results.all? { |_k, v| v['sync'] == true },
106+
}
104107
end
105108
end
106109
# Run the task unless an environment flag has been set, signaling not to. The

0 commit comments

Comments
 (0)