tvdinner 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/libexec/_sub ADDED
@@ -0,0 +1,60 @@
1
+ #!/bin/bash
2
+
3
+ if [[ "${BASH_SOURCE##*/}" != "_sub" ]]; then
4
+ shome="$(unset CDPATH; cd -P -- "$(dirname -- "$BASH_SOURCE")/.." && pwd -P)"
5
+ source "$shome/libexec/_jason"
6
+ set -- "$BASH_SOURCE" "$@"
7
+ fi
8
+
9
+ if [[ "$(type -t main)" != "function" ]]; then
10
+ function main {
11
+ if [[ "$#" > 0 ]]; then
12
+ logger_fatal "Command $sub_base $1 not implemented"
13
+ else
14
+ logger_fatal "Command $sub_base not implemented"
15
+ fi
16
+ exit 1
17
+ }
18
+ fi
19
+
20
+ function sub {
21
+ local bsource="$1"; shift
22
+ local sub_base="$(basename "$bsource")"
23
+ local bsource_cmd="$shome/libexec/${sub_base}"
24
+
25
+ if [[ "$bsource_cmd" = "$bsource" ]]; then
26
+ FLAGS_SUB="$FLAGS_TRUE"
27
+ parse_command_line "$@" || exit $?
28
+ eval set -- "${FLAGS_ARGV}"
29
+ fi
30
+
31
+ if [[ "$#" > 0 ]]; then
32
+ if [[ ! "$1" =~ ^- ]]; then
33
+ local sub_cmd="$shome/libexec/${sub_base}-$1"
34
+
35
+ if [[ ! -x "$sub_cmd" ]]; then
36
+ sub_cmd="$(type -P "${sub_base}-$1" || true)"
37
+ fi
38
+
39
+ if [[ -x "$sub_cmd" ]]; then
40
+ shift
41
+ exec "$sub_cmd" "$@"
42
+ fi
43
+ fi
44
+ fi
45
+
46
+ if [[ -x "$bsource_cmd" && "$bsource_cmd" != "$bsource" ]]; then
47
+ exec "$bsource_cmd" "$@"
48
+ else
49
+ if [[ "$(type -t main)" = "function" ]]; then
50
+ main "$@"
51
+ else
52
+ logger_fatal "Can't run $sub_base, missing main function"
53
+ exit 1
54
+ fi
55
+ fi
56
+ }
57
+
58
+ if [[ "$#" > 0 ]]; then
59
+ sub "$@"
60
+ fi
data/libexec/compare ADDED
@@ -0,0 +1,100 @@
1
+ #!/bin/bash
2
+
3
+ #/ NAME
4
+ #/ compare -- Compare two noop chef runs
5
+ #/
6
+ #/ SYNOPSIS
7
+ #/
8
+ #/ compare RNA VERSION [VERSION]
9
+ #/ The right VERSION defaults to the current branch
10
+
11
+ # figure out the project root under which bin, lib live
12
+ shome="$(cd -P -- "$(dirname -- "$0")/.." && pwd -P)"
13
+
14
+ # load a meat library
15
+ source "$shome/libexec/_jason" "$@"
16
+
17
+ DEFINE_boolean make "$FLAGS_TRUE" "Run make"
18
+
19
+ # entry point
20
+ function main {
21
+ case "$#" in
22
+ 0)
23
+ logger_fatal "missing RNA"
24
+ exit 1
25
+ ;;
26
+ 1|2|3)
27
+ true
28
+ ;;
29
+ 4)
30
+ logger_fatal "too many arguments ($*), only need RNA [VERSION] [VERSION]"
31
+ exit 1
32
+ ;;
33
+ esac
34
+
35
+ local nm_current_branch="$(git branch | awk '$1 == "*" { print $2 }')"
36
+
37
+ local pth_rna="$1"; shift
38
+
39
+ local ver_left="$nm_current_branch"
40
+ if [[ "$#" > 0 ]]; then
41
+ ver_left="${1#origin/}"; shift
42
+ fi
43
+
44
+ local ver_right="$nm_current_branch"
45
+ if [[ "$#" > 0 ]]; then
46
+ ver_right="${1#origin/}"; shift
47
+ fi
48
+
49
+ if [[ "$(git show-ref $ver_left | grep -v refs/tags/ | wc -l | awk '{print $1}')" != 0 ]]; then
50
+ if [[ "$ver_left" != "$nm_current_branch" ]]; then
51
+ git fetch origin $ver_left:$ver_left
52
+ fi
53
+ ver_left="origin/$ver_left"
54
+ fi
55
+
56
+ if [[ "$(git show-ref $ver_right | grep -v refs/tags/ | wc -l | awk '{print $1}')" != 0 ]]; then
57
+ if [[ "$ver_right" != "$nm_current_branch" ]]; then
58
+ git fetch origin $ver_right:$ver_right
59
+ fi
60
+ ver_right="origin/$ver_right"
61
+ fi
62
+
63
+ local opt_make=""
64
+ if [[ "$FLAGS_make" = "$FLAGS_FALSE" ]]; then
65
+ opt_make="no"
66
+ fi
67
+
68
+ $shome/libexec/run-noop --${opt_make}make tmp/a $ver_left $pth_rna
69
+ $shome/libexec/run-noop --${opt_make}make tmp/b $ver_right $pth_rna
70
+
71
+ local incomplete="$FLAGS_FALSE"
72
+ for a in $shome/tmp/{a,b}; do
73
+ for f in chef.{log,json}; do
74
+ if [[ ! -f "$a/$f" ]]; then
75
+ logger_fatal "missing $a/$f"
76
+ incomplete="$FLAGS_TRUE"
77
+ fi
78
+ done
79
+ done
80
+
81
+ if [[ "$incomplete" = "$FLAGS_TRUE" ]]; then
82
+ exit 1
83
+ fi
84
+
85
+ mark_output
86
+
87
+ logger_info "diff tmp/[ab]/chef.log"
88
+ mark_log "chef-log"
89
+ echo
90
+ diff $shome/tmp/{a,b}/chef.log || true
91
+ echo
92
+
93
+ logger_info "diff tmp/[ab]/chef.json"
94
+ mark_log "chef-node"
95
+ echo
96
+ diff $shome/tmp/{a,b}/chef.json || true
97
+ echo
98
+ }
99
+
100
+ require sub "$BASH_SOURCE" "$@"
data/libexec/run ADDED
@@ -0,0 +1,60 @@
1
+ #!/bin/bash
2
+
3
+ if [[ "${BASH_SOURCE##*/}" != "_sub" ]]; then
4
+ shome="$(unset CDPATH; cd -P -- "$(dirname -- "$BASH_SOURCE")/.." && pwd -P)"
5
+ source "$shome/libexec/_jason"
6
+ set -- "$BASH_SOURCE" "$@"
7
+ fi
8
+
9
+ if [[ "$(type -t main)" != "function" ]]; then
10
+ function main {
11
+ if [[ "$#" > 0 ]]; then
12
+ logger_fatal "Command $sub_base $1 not implemented"
13
+ else
14
+ logger_fatal "Command $sub_base not implemented"
15
+ fi
16
+ exit 1
17
+ }
18
+ fi
19
+
20
+ function sub {
21
+ local bsource="$1"; shift
22
+ local sub_base="$(basename "$bsource")"
23
+ local bsource_cmd="$shome/libexec/${sub_base}"
24
+
25
+ if [[ "$bsource_cmd" = "$bsource" ]]; then
26
+ FLAGS_SUB="$FLAGS_TRUE"
27
+ parse_command_line "$@" || exit $?
28
+ eval set -- "${FLAGS_ARGV}"
29
+ fi
30
+
31
+ if [[ "$#" > 0 ]]; then
32
+ if [[ ! "$1" =~ ^- ]]; then
33
+ local sub_cmd="$shome/libexec/${sub_base}-$1"
34
+
35
+ if [[ ! -x "$sub_cmd" ]]; then
36
+ sub_cmd="$(type -P "${sub_base}-$1" || true)"
37
+ fi
38
+
39
+ if [[ -x "$sub_cmd" ]]; then
40
+ shift
41
+ exec "$sub_cmd" "$@"
42
+ fi
43
+ fi
44
+ fi
45
+
46
+ if [[ -x "$bsource_cmd" && "$bsource_cmd" != "$bsource" ]]; then
47
+ exec "$bsource_cmd" "$@"
48
+ else
49
+ if [[ "$(type -t main)" = "function" ]]; then
50
+ main "$@"
51
+ else
52
+ logger_fatal "Can't run $sub_base, missing main function"
53
+ exit 1
54
+ fi
55
+ fi
56
+ }
57
+
58
+ if [[ "$#" > 0 ]]; then
59
+ sub "$@"
60
+ fi
data/libexec/run-noop ADDED
@@ -0,0 +1,71 @@
1
+ #!/bin/bash
2
+
3
+ #/ NAME
4
+ #/ run-noop -- Run noop chef in separate workarea
5
+ #/
6
+ #/ SYNOPSIS
7
+ #/
8
+ #/ run-noop DIR VERSION DNA
9
+
10
+
11
+ # figure out the project root under which bin, lib live
12
+ shome="$(cd -P -- "$(dirname -- "$0")/.." && pwd -P)"
13
+
14
+ # load a meat library
15
+ source "$shome/libexec/_jason" "$@"
16
+
17
+ DEFINE_boolean make "$FLAGS_FALSE" "Run make"
18
+
19
+ # entry point
20
+ function main {
21
+ case "$#" in
22
+ 0)
23
+ logger_fatal "missing DIR VERSION DNA"
24
+ exit 1
25
+ ;;
26
+ 1)
27
+ logger_fatal "missing VERSION DNA"
28
+ exit 1
29
+ ;;
30
+ 2)
31
+ logger_fatal "missing DNA"
32
+ exit 1
33
+ ;;
34
+ 3)
35
+ true
36
+ ;;
37
+ *)
38
+ logger_fatal "too many args"
39
+ exit 1
40
+ ;;
41
+ esac
42
+
43
+ local pth_workarea="$1"; shift
44
+ local ver_repo="$1"; shift
45
+
46
+ rm -f "$pth_workarea"/chef.{log,json}
47
+
48
+ local pth_rna="rna/output/base.json"
49
+ if [[ "$#" > 0 ]]; then
50
+ pth_rna="$1"; shift
51
+ fi
52
+
53
+ if [[ ! -d "$pth_workarea/.git" ]]; then
54
+ git clone . "$pth_workarea"
55
+ FLAGS_make="$FLAGS_TRUE"
56
+ fi
57
+
58
+ cd "$pth_workarea"
59
+ git fetch
60
+ git fetch --tags
61
+ git reset --hard "$ver_repo"
62
+ if [[ "$FLAGS_make" = "$FLAGS_TRUE" ]]; then
63
+ make
64
+ fi
65
+
66
+ bundle exec chef-local --noop -c etc/chef/solo.rb -j $pth_rna > "var/chef/reports/chef.log"
67
+ (set +f; $shome/libexec/sanitize node "var/chef/reports/"chef*.json > "chef.json")
68
+ $shome/libexec/sanitize log "var/chef/reports/chef.log" > "chef.log"
69
+ }
70
+
71
+ require sub "$BASH_SOURCE" "$@"
data/libexec/sanitize ADDED
@@ -0,0 +1,60 @@
1
+ #!/bin/bash
2
+
3
+ if [[ "${BASH_SOURCE##*/}" != "_sub" ]]; then
4
+ shome="$(unset CDPATH; cd -P -- "$(dirname -- "$BASH_SOURCE")/.." && pwd -P)"
5
+ source "$shome/libexec/_jason"
6
+ set -- "$BASH_SOURCE" "$@"
7
+ fi
8
+
9
+ if [[ "$(type -t main)" != "function" ]]; then
10
+ function main {
11
+ if [[ "$#" > 0 ]]; then
12
+ logger_fatal "Command $sub_base $1 not implemented"
13
+ else
14
+ logger_fatal "Command $sub_base not implemented"
15
+ fi
16
+ exit 1
17
+ }
18
+ fi
19
+
20
+ function sub {
21
+ local bsource="$1"; shift
22
+ local sub_base="$(basename "$bsource")"
23
+ local bsource_cmd="$shome/libexec/${sub_base}"
24
+
25
+ if [[ "$bsource_cmd" = "$bsource" ]]; then
26
+ FLAGS_SUB="$FLAGS_TRUE"
27
+ parse_command_line "$@" || exit $?
28
+ eval set -- "${FLAGS_ARGV}"
29
+ fi
30
+
31
+ if [[ "$#" > 0 ]]; then
32
+ if [[ ! "$1" =~ ^- ]]; then
33
+ local sub_cmd="$shome/libexec/${sub_base}-$1"
34
+
35
+ if [[ ! -x "$sub_cmd" ]]; then
36
+ sub_cmd="$(type -P "${sub_base}-$1" || true)"
37
+ fi
38
+
39
+ if [[ -x "$sub_cmd" ]]; then
40
+ shift
41
+ exec "$sub_cmd" "$@"
42
+ fi
43
+ fi
44
+ fi
45
+
46
+ if [[ -x "$bsource_cmd" && "$bsource_cmd" != "$bsource" ]]; then
47
+ exec "$bsource_cmd" "$@"
48
+ else
49
+ if [[ "$(type -t main)" = "function" ]]; then
50
+ main "$@"
51
+ else
52
+ logger_fatal "Can't run $sub_base, missing main function"
53
+ exit 1
54
+ fi
55
+ fi
56
+ }
57
+
58
+ if [[ "$#" > 0 ]]; then
59
+ sub "$@"
60
+ fi
@@ -0,0 +1,30 @@
1
+ #!/bin/bash
2
+
3
+ #/ NAME
4
+ #/ sanitize-log -- Sanitizes chef run output for comparison
5
+ #/
6
+ #/ SYNOPSIS
7
+ #/
8
+ #/ sanitize-log
9
+
10
+
11
+ # figure out the project root under which bin, lib live
12
+ shome="$(cd -P -- "$(dirname -- "$0")/.." && pwd -P)"
13
+
14
+ # load a meat library
15
+ source "$shome/libexec/_jason" "$@"
16
+
17
+ # entry point
18
+ function main {
19
+ local pth_log="$1"; shift
20
+
21
+ cat "$pth_log" | \
22
+ perl -pe 's{^\[\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d-\d\d:\d\d\]\s*}{}' | \
23
+ perl -pe 'm{^(INFO: Chef Run complete|Run options|Finished tests)} && s{\d+}{XXX}g' | \
24
+ perl -pe 's{line \d+[)]$}{line XXX)}' | \
25
+ perl -pe 's{/tmp/[ab]/}{/}g'
26
+ }
27
+
28
+ require sub "$BASH_SOURCE" "$@"
29
+
30
+
@@ -0,0 +1,23 @@
1
+ #!/bin/bash
2
+
3
+ #/ NAME
4
+ #/ run-noop -- Run noop chef in separate workarea
5
+ #/
6
+ #/ SYNOPSIS
7
+ #/
8
+ #/ run-noop DIR VERSION
9
+
10
+
11
+ # figure out the project root under which bin, lib live
12
+ shome="$(cd -P -- "$(dirname -- "$0")/.." && pwd -P)"
13
+
14
+ # load a meat library
15
+ source "$shome/libexec/_jason" "$@"
16
+
17
+ # entry point
18
+ function main {
19
+ bundle exec ruby "$shome/libexec/sanitize-node.rb" "$@" | \
20
+ perl -pe 's{/tmp/[ab]/}{/}g'
21
+ }
22
+
23
+ require sub "$BASH_SOURCE" "$@"
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/ruby
2
+
3
+ class Hash
4
+ alias hkeys keys
5
+
6
+ def keys
7
+ hkeys.sort {|a,b| a.to_s <=> b.to_s }
8
+ end
9
+
10
+ def each
11
+ keys.each { |k| yield k, self[k] }
12
+ end
13
+ end
14
+
15
+ require 'rubygems'
16
+ require 'bundler/setup'
17
+ require 'json'
18
+ require 'yaml'
19
+
20
+ node = JSON.load(File.read(ARGV[0]).gsub("json_class","json_klass")).to_hash
21
+
22
+ node.delete "all_resources"
23
+ node.delete "updated_resources"
24
+ node.delete "elapsed_time"
25
+ node.delete "start_time"
26
+ node.delete "end_time"
27
+ node["node"].delete "automatic"
28
+
29
+
30
+ puts node.to_yaml
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tvdinner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,10 +9,10 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-31 00:00:00.000000000 Z
12
+ date: 2013-06-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: tvdinner
15
+ name: chef
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
@@ -41,6 +41,17 @@ files:
41
41
  - lib/tvdinner.rb
42
42
  - lib/tvdinner/noop.rb
43
43
  - lib/tvdinner/version.rb
44
+ - libexec/_jason
45
+ - libexec/_log4sh
46
+ - libexec/_shflags
47
+ - libexec/_sub
48
+ - libexec/compare
49
+ - libexec/run
50
+ - libexec/run-noop
51
+ - libexec/sanitize
52
+ - libexec/sanitize-log
53
+ - libexec/sanitize-node
54
+ - libexec/sanitize-node.rb
44
55
  - bin/chef-local
45
56
  - LICENSE
46
57
  - NOTICE