deploy-context 2.13.10 → 2.13.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +4 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/context-knife-context.rb +26 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/context-manager.rb +100 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/cookbook-studio.rb +72 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/cucumber-studio.rb +45 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/cucumber-suite.rb +179 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/default-studio.rb +174 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/deploy/chef.rb +57 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/deploy/context.rb +42 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/deploy/cookbook.rb +121 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/deploy/cucumber.rb +42 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/deploy/deployer.rb +83 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/deploy/git.rb +62 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/deploy/habitat.rb +112 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/deploy/ruby.rb +138 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/deploy/vagrant.rb +7 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/habitat-studio.rb +50 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/helpers/command.rb +91 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/helpers/gemspec.rb +91 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/helpers/rake_tasks.rb +150 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/knife/default_knife_context.rb +35 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/knife/dummy_knife.rb +43 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/ruby-studio.rb +56 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/steps/deploy.rb +61 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/studio/base.rb +167 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/studio/default.rb +38 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/studio/deployer.rb +24 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context.rb +65 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-definitions/deploy-context-cucumber.rb +18 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-definitions/deploy-context-git.rb +47 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-definitions/deploy-context-habitat.rb +82 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-definitions/deploy-context-kitchen.rb +67 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-definitions/deploy-context-knife.rb +45 -0
- data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-definitions/deploy-context-rake.rb +12 -0
- data.tar.gz.sig +0 -0
- metadata +64 -6
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eedb55204296d3a40fb764fc98405ba649b9b7bd72591173d321219dff1959f2
|
4
|
+
data.tar.gz: 4d7335e2950bd7d0a23b7fcdc1491ac0018dffda89b7f85a2ed69caefa34265e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 983ab1d0979cdfb638738cec8b745fae58977dba8a8aacd1e7351fe4110d605fb8d77aa9da9624faa2be65f9a4a95f22c3a38acc05f422d84e1de5c2c6544816
|
7
|
+
data.tar.gz: 9ccfadc63cdfda64fa2f4989d31693c84825ab26ee20521575880d0a243d1d68679a92fefa6055607682c8333131dc05243a8d8cf95f295a00e6c028a24d2e6c
|
checksums.yaml.gz.sig
ADDED
@@ -0,0 +1,4 @@
|
|
1
|
+
^�ߠ�:Ж�Z���N�U�E�a����u��b�����-V�Eȫ~K�B�5��
|
2
|
+
=f��8���2��i�!���Ŀ�u?�r����,4*�t�-�p
|
3
|
+
ь5bt ��F3?k�!��[w�}s@��F� x{��FJae����ă
|
4
|
+
�@6��9�=X���1N�T+2�J��S�'\�;�!�rV��4G��$�"��9I϶I���#��d�����n�G���܇K��Ռ�s�c�xW���r���Ɔ��k��q�:�Z��#�?D�4<�E+�#��Gbw����z�f��c��>xk��J����^��1��O��P=皹��ɬ�ԟ�\G��V'P\6i&1���?՜�nT�W扑������
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
require_relative 'context-manager'
|
3
|
+
|
4
|
+
module Context
|
5
|
+
class ContextKnifeContext < DefaultStudio
|
6
|
+
banner "knife context knife context"
|
7
|
+
|
8
|
+
deps do
|
9
|
+
Knife::DefaultKnifeContext.load_deps
|
10
|
+
end
|
11
|
+
|
12
|
+
option :context,
|
13
|
+
:description => "Load an object internally on it"
|
14
|
+
|
15
|
+
def run
|
16
|
+
# Context::DeployContext.deployer.send(config[:omg])
|
17
|
+
if config[:omg]
|
18
|
+
# Oh yeah, we are pumped.
|
19
|
+
puts "OMG HELLO WORLD!!!8!!88"
|
20
|
+
else
|
21
|
+
# meh
|
22
|
+
puts "I am just a fucking example. 8"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
|
2
|
+
require_relative 'deploy-context/cucumber-studio'
|
3
|
+
|
4
|
+
module Context
|
5
|
+
class Manager < DefaultStudio
|
6
|
+
attr_reader :contexts
|
7
|
+
|
8
|
+
# 2
|
9
|
+
def do_download
|
10
|
+
super
|
11
|
+
contexts.each do |context|
|
12
|
+
context.do_download
|
13
|
+
end
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
# 3
|
18
|
+
def do_verify
|
19
|
+
super
|
20
|
+
contexts.each do |context|
|
21
|
+
context.do_verify
|
22
|
+
end
|
23
|
+
true
|
24
|
+
end
|
25
|
+
|
26
|
+
# 4
|
27
|
+
def do_clean
|
28
|
+
super
|
29
|
+
contexts.each do |context|
|
30
|
+
context.do_clean
|
31
|
+
end
|
32
|
+
true
|
33
|
+
end
|
34
|
+
|
35
|
+
# 5
|
36
|
+
def do_unpack
|
37
|
+
super
|
38
|
+
contexts.each do |context|
|
39
|
+
context.do_unpack
|
40
|
+
end
|
41
|
+
true
|
42
|
+
end
|
43
|
+
|
44
|
+
# 6
|
45
|
+
def do_prepare
|
46
|
+
super
|
47
|
+
contexts.each do |context|
|
48
|
+
context.do_prepare
|
49
|
+
end
|
50
|
+
true
|
51
|
+
end
|
52
|
+
|
53
|
+
# 7
|
54
|
+
def do_build
|
55
|
+
super
|
56
|
+
contexts.each do |context|
|
57
|
+
context.do_build
|
58
|
+
end
|
59
|
+
true
|
60
|
+
end
|
61
|
+
|
62
|
+
# 8
|
63
|
+
def do_check
|
64
|
+
super
|
65
|
+
contexts.each do |context|
|
66
|
+
context.do_check
|
67
|
+
end
|
68
|
+
true
|
69
|
+
end
|
70
|
+
|
71
|
+
# 9
|
72
|
+
def do_install
|
73
|
+
super
|
74
|
+
contexts.each do |context|
|
75
|
+
context.do_install
|
76
|
+
end
|
77
|
+
true
|
78
|
+
end
|
79
|
+
|
80
|
+
# 10
|
81
|
+
def do_strip
|
82
|
+
super
|
83
|
+
def do_install
|
84
|
+
contexts.each do |context|
|
85
|
+
context.do_strip
|
86
|
+
end
|
87
|
+
true
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# 11
|
92
|
+
def do_end
|
93
|
+
super
|
94
|
+
contexts.each do |context|
|
95
|
+
context.do_end
|
96
|
+
end
|
97
|
+
true
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require_relative 'ruby-studio'
|
2
|
+
|
3
|
+
module Context
|
4
|
+
class ContextCookbookStudio < DefaultStudio
|
5
|
+
banner "knife context cookbook studio"
|
6
|
+
|
7
|
+
deps do
|
8
|
+
Knife::DefaultKnifeContext.load_deps
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
case name_args[0]
|
13
|
+
when 'converge'
|
14
|
+
kitchen(self, name_args)
|
15
|
+
when 'verify'
|
16
|
+
kitchen(self, name_args)
|
17
|
+
when 'destroy'
|
18
|
+
kitchen(self, name_args)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# 4
|
23
|
+
def do_clean
|
24
|
+
super
|
25
|
+
delete_file_only_if_exist(get_context_file(self, 'Policyfile.lock.json'))
|
26
|
+
kitchen(%w(destroy))
|
27
|
+
true
|
28
|
+
end
|
29
|
+
|
30
|
+
# 6
|
31
|
+
def do_prepare
|
32
|
+
cookbook_build(self)
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
# 7
|
37
|
+
def do_build
|
38
|
+
cookbook_install(self)
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
42
|
+
# 8
|
43
|
+
def do_check
|
44
|
+
cookbook_test(self)
|
45
|
+
true
|
46
|
+
end
|
47
|
+
|
48
|
+
# 9
|
49
|
+
def do_install
|
50
|
+
knife_push(self)
|
51
|
+
true
|
52
|
+
end
|
53
|
+
|
54
|
+
# 10
|
55
|
+
def do_strip
|
56
|
+
super
|
57
|
+
cookbook_push(self)
|
58
|
+
true
|
59
|
+
end
|
60
|
+
|
61
|
+
# 11
|
62
|
+
def do_end
|
63
|
+
super
|
64
|
+
supermarket_push(self)
|
65
|
+
true
|
66
|
+
end
|
67
|
+
|
68
|
+
def studio_available?
|
69
|
+
is_binary_available?('kitchen') && is_binary_available?('knife') && super
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative 'habitat-studio'
|
2
|
+
|
3
|
+
module Context
|
4
|
+
class ContextCucumberStudio < DefaultStudio
|
5
|
+
banner "knife context cucumber studio"
|
6
|
+
|
7
|
+
deps do
|
8
|
+
Knife::DefaultKnifeContext.load_deps
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
case name_args[1]
|
13
|
+
when 'destroy'
|
14
|
+
execute_command(%w(knife context cookbook studio destroy)) if name_args[0] == 'kitchen'
|
15
|
+
when 'enter'
|
16
|
+
execute_command(%w(knife context habitat studio enter)) if name_args[0] == 'habitat'
|
17
|
+
when 'build'
|
18
|
+
execute_command(%w(knife context habitat studio build) + name_args) if name_args[0] == 'habitat'
|
19
|
+
else
|
20
|
+
if name_args[0]
|
21
|
+
additionnal_tag = name_args[1].nil? ? [] : ['--tags', "@#{name_args[1]}"]
|
22
|
+
case name_args[0]
|
23
|
+
when 'cycle'
|
24
|
+
cucumber(self, ['--profile', 'preinit'] + additionnal_tag)
|
25
|
+
cucumber(self, ['--profile', 'initialize'] + additionnal_tag)
|
26
|
+
cucumber(self, ['--profile', 'planning'] + additionnal_tag)
|
27
|
+
cucumber(self, ['--profile', 'execution'] + additionnal_tag)
|
28
|
+
cucumber(self, ['--profile', 'closure'] + additionnal_tag)
|
29
|
+
cucumber(self, ['--profile', 'post_mortem'] + additionnal_tag)
|
30
|
+
when 'bump'
|
31
|
+
execute_command(%w(chef exec git version-bump patch))
|
32
|
+
else
|
33
|
+
cucumber(self, ['--profile', name_args[0]] + additionnal_tag)
|
34
|
+
end
|
35
|
+
else
|
36
|
+
cucumber(self)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def studio_available?
|
42
|
+
is_binary_available?('cucumber') && super
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,179 @@
|
|
1
|
+
|
2
|
+
require_relative 'deploy/context'
|
3
|
+
require_relative 'deploy/chef'
|
4
|
+
require_relative 'deploy/cookbook'
|
5
|
+
require_relative 'deploy/cucumber'
|
6
|
+
require_relative 'deploy/deployer'
|
7
|
+
require_relative 'deploy/git'
|
8
|
+
require_relative 'deploy/habitat'
|
9
|
+
require_relative 'deploy/ruby'
|
10
|
+
require_relative 'deploy/vagrant'
|
11
|
+
|
12
|
+
module Context
|
13
|
+
module CucumberSuiteHelper
|
14
|
+
include Context::CommandHelper
|
15
|
+
include DeployHelpers::DeployerHelper
|
16
|
+
include DeployHelpers::ChefHelper
|
17
|
+
include DeployHelpers::GitHelper
|
18
|
+
include DeployHelpers::RubyHelper
|
19
|
+
include DeployHelpers::ContextHelper
|
20
|
+
include DeployHelpers::CookbookHelper
|
21
|
+
include DeployHelpers::HabitatHelper
|
22
|
+
include DeployHelpers::CucumberHelper
|
23
|
+
|
24
|
+
include Studio::Base
|
25
|
+
include Studio::Default
|
26
|
+
include Steps::Deploy
|
27
|
+
|
28
|
+
def context_suite
|
29
|
+
if @context_suite.nil?
|
30
|
+
@context_suite = OpenStruct.new
|
31
|
+
@context_suite.status_file = 'deploy-status.json'
|
32
|
+
# @context_suite.suite_kitchen = "patatae"
|
33
|
+
@context_suite.status = :initialisation
|
34
|
+
end
|
35
|
+
@context_suite
|
36
|
+
end
|
37
|
+
|
38
|
+
def verify_kitchen_status
|
39
|
+
context_suite.status = case kitchen_status['last_action']
|
40
|
+
when "verify"
|
41
|
+
kitchen_status['last_error'].nil? ? :verified : :verification_fail
|
42
|
+
when "converge"
|
43
|
+
kitchen_status['last_error'].nil? ? :converged : :converge_fail
|
44
|
+
when nil
|
45
|
+
:destroyed
|
46
|
+
else
|
47
|
+
warning_context_log("Kitchen status", kitchen_status['last_action'].inspect)
|
48
|
+
:unknown
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def dirty_branch?
|
53
|
+
`git status --porcelain`.split('\n').count > 0
|
54
|
+
end
|
55
|
+
|
56
|
+
def branch_exist?
|
57
|
+
system("git branch --list #{context_suite.branch_name}")
|
58
|
+
end
|
59
|
+
|
60
|
+
def git_commit_successfully?
|
61
|
+
system("git commit -m 'Automatic cucumber commit on branch #{context_suite.branch_name}'")
|
62
|
+
end
|
63
|
+
|
64
|
+
def merge_with_branch_successfull?(source_branch)
|
65
|
+
system("git merge #{source_branch} #{context_suite.branch_name}")
|
66
|
+
end
|
67
|
+
|
68
|
+
def merge_to_master_successfull?
|
69
|
+
merge_with_branch_successfull?(context_suite.branch_name, 'master')
|
70
|
+
end
|
71
|
+
|
72
|
+
def switch_branch_successful?
|
73
|
+
system("git checkout #{context_suite.branch_name}")
|
74
|
+
end
|
75
|
+
|
76
|
+
def kitchen_suite_exist?
|
77
|
+
system("kitchen list #{context_suite.suite_kitchen}")
|
78
|
+
end
|
79
|
+
|
80
|
+
def verify_kitchen?
|
81
|
+
system("kitchen verify #{context_suite.suite_kitchen}")
|
82
|
+
end
|
83
|
+
|
84
|
+
def verify_secret?(secret_key)
|
85
|
+
system("hab origin secret list | grep #{secret_key}")
|
86
|
+
end
|
87
|
+
|
88
|
+
def kitchen_converged_successfully?
|
89
|
+
system("kitchen converge #{context_suite.suite_kitchen}")
|
90
|
+
end
|
91
|
+
|
92
|
+
def kitchen_destroyed_correctly?
|
93
|
+
system("kitchen destroy #{context_suite.suite_kitchen}")
|
94
|
+
end
|
95
|
+
|
96
|
+
def kitchen_tested_successfully?
|
97
|
+
system("kitchen test #{context_suite.suite_kitchen}")
|
98
|
+
end
|
99
|
+
|
100
|
+
def habitat_task_different?
|
101
|
+
jop_id = last_job_status[1]
|
102
|
+
jop_id != File.read('HAB_BUILD_ID')
|
103
|
+
end
|
104
|
+
|
105
|
+
def habitat_task_completed?
|
106
|
+
jop_status = last_job_status[2]
|
107
|
+
jop_status == 'Complete'
|
108
|
+
end
|
109
|
+
|
110
|
+
def job_status_raw
|
111
|
+
`hab bldr job status --origin #{context_suite.organisation_name} | grep #{context_suite.organisation_name}/#{context_suite.application_name}`
|
112
|
+
end
|
113
|
+
|
114
|
+
def last_job_status
|
115
|
+
job_status_arr = job_status_raw.split('\n')
|
116
|
+
jop_status = job_status_arr[0].split(' ')
|
117
|
+
end
|
118
|
+
|
119
|
+
def habitat_new_task?
|
120
|
+
jop_status = last_job_status[2]
|
121
|
+
jop_status == 'Dispatching'
|
122
|
+
end
|
123
|
+
|
124
|
+
def write_build_id
|
125
|
+
jop_id = last_job_status[1]
|
126
|
+
File.write('HAB_BUILD_ID', jop_id)
|
127
|
+
end
|
128
|
+
|
129
|
+
def write_cookbook_version
|
130
|
+
short_version = Gem::Version.new(GVB.version).canonical_segments[0..2].join('.')
|
131
|
+
File.write('VERSION', short_version)
|
132
|
+
File.write('DATE', GVB.date)
|
133
|
+
File.write('habitat/plan.sh/VERSION', short_version)
|
134
|
+
File.write('habitat/plan.sh/DATE', GVB.date)
|
135
|
+
end
|
136
|
+
|
137
|
+
def verify_habitat?
|
138
|
+
system("hab studio run echo")
|
139
|
+
end
|
140
|
+
|
141
|
+
def plan_build_successfully?
|
142
|
+
system("hab studio build #{context_suite.plan_path}")
|
143
|
+
end
|
144
|
+
|
145
|
+
def context_status
|
146
|
+
JSON.parse(File.read(context_suite.status_file))[:status]
|
147
|
+
end
|
148
|
+
|
149
|
+
def kitchen_status
|
150
|
+
JSON.parse(`kitchen list #{context_suite.suite_kitchen} --json`).detect{|suite| suite['instance'].include?(context_suite.suite_kitchen)}
|
151
|
+
end
|
152
|
+
|
153
|
+
def command_available?(app_name, sub_command)
|
154
|
+
system("knife #{app_name} #{sub_command}")
|
155
|
+
end
|
156
|
+
|
157
|
+
def stop_test(message, status)
|
158
|
+
wrap_message = "#{status}:: #{message}"
|
159
|
+
update_status status
|
160
|
+
abort(wrap_message)
|
161
|
+
end
|
162
|
+
|
163
|
+
def update_status(new_status)
|
164
|
+
context_suite.status = new_status
|
165
|
+
update_status_file
|
166
|
+
end
|
167
|
+
|
168
|
+
def update_status_file
|
169
|
+
File.write(context_suite.status_file, JSON.pretty_generate({
|
170
|
+
status_file: context_suite.status_file,
|
171
|
+
kitchen_suite: context_suite.kitchen_suite,
|
172
|
+
plan_path: context_suite.plan_path,
|
173
|
+
branch_name: context_suite.branch_name,
|
174
|
+
status: context_suite.status,
|
175
|
+
}
|
176
|
+
))
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
require 'git-version-bump'
|
7
|
+
|
8
|
+
require_relative 'helpers/command'
|
9
|
+
require_relative 'helpers/rake_tasks'
|
10
|
+
|
11
|
+
require_relative 'studio/default'
|
12
|
+
require_relative 'studio/deployer'
|
13
|
+
|
14
|
+
require_relative 'steps/deploy'
|
15
|
+
|
16
|
+
require_relative 'knife/default_knife_context'
|
17
|
+
require_relative 'cucumber-suite'
|
18
|
+
|
19
|
+
# require_relative 'ruby-studio'
|
20
|
+
# require_relative 'cookbook-studio'
|
21
|
+
# require_relative 'habitat-studio'
|
22
|
+
# require_relative 'cucumber-studio'
|
23
|
+
|
24
|
+
module Context
|
25
|
+
class DefaultStudio < Knife::DefaultKnifeContext
|
26
|
+
include CucumberSuiteHelper
|
27
|
+
|
28
|
+
# attr_reader :context_name
|
29
|
+
# attr_reader :context_folder
|
30
|
+
|
31
|
+
# attr_accessor :existing_cucumber_runtime
|
32
|
+
# attr_accessor :existing_cucumber_configuration
|
33
|
+
|
34
|
+
# attr_reader :organisation_name
|
35
|
+
|
36
|
+
attr_reader :ruby_studio
|
37
|
+
attr_reader :cookbook_studio
|
38
|
+
attr_reader :habitat_studio
|
39
|
+
attr_reader :cucumber_studio
|
40
|
+
|
41
|
+
# attr_reader :context_state
|
42
|
+
|
43
|
+
banner 'knife default studio'
|
44
|
+
|
45
|
+
deps do
|
46
|
+
end
|
47
|
+
|
48
|
+
option :context_name,
|
49
|
+
:short => '-N',
|
50
|
+
:long => '--context-name',
|
51
|
+
:description => "Name of the context"
|
52
|
+
|
53
|
+
option :ruby_studio,
|
54
|
+
:short => '-B',
|
55
|
+
:long => '--ruby-studio',
|
56
|
+
:description => "Path of the ruby studio"
|
57
|
+
|
58
|
+
option :cookbook_studio,
|
59
|
+
:short => '-B',
|
60
|
+
:long => '--cookbook-studio',
|
61
|
+
:description => "Path of the cookbook studio"
|
62
|
+
|
63
|
+
option :habitat_studio,
|
64
|
+
:short => '-H',
|
65
|
+
:long => '--habitat-studio',
|
66
|
+
:description => "Path of the habitat studio"
|
67
|
+
|
68
|
+
option :cucumber_studio,
|
69
|
+
:short => '-C',
|
70
|
+
:long => '--cucumber-studio',
|
71
|
+
:description => "Path of the cucumber studio"
|
72
|
+
|
73
|
+
option :context_state,
|
74
|
+
:short => '-S',
|
75
|
+
:long => '--context-state',
|
76
|
+
:description => "Set the value of the state before run"
|
77
|
+
|
78
|
+
# def initialize(argv)
|
79
|
+
# end
|
80
|
+
|
81
|
+
# def initialize(context_organisation_name, deployer_context_name, deploycontext_folder, default_ruby_studio = nil)
|
82
|
+
# @context_name = deployer_context_name
|
83
|
+
# @context_folder = deploycontext_folder # move_folder(deploycontext_folder)
|
84
|
+
# @organisation_name = context_organisation_name
|
85
|
+
# @ruby_studio = default_ruby_studio
|
86
|
+
# end
|
87
|
+
|
88
|
+
def context_name
|
89
|
+
config[:context_name]
|
90
|
+
end
|
91
|
+
|
92
|
+
def context_folder
|
93
|
+
config[:context_folder]
|
94
|
+
end
|
95
|
+
|
96
|
+
def existing_cucumber_runtime
|
97
|
+
config[:existing_cucumber_runtime]
|
98
|
+
end
|
99
|
+
|
100
|
+
def existing_cucumber_configuration
|
101
|
+
config[:existing_cucumber_configuration]
|
102
|
+
end
|
103
|
+
|
104
|
+
def organisation_name
|
105
|
+
config[:organisation_name]
|
106
|
+
end
|
107
|
+
|
108
|
+
def ruby_studio
|
109
|
+
@ruby_studio = RubyStudio.new if @ruby_studio.nil?
|
110
|
+
@ruby_studio
|
111
|
+
end
|
112
|
+
|
113
|
+
def cookbook_studio
|
114
|
+
@cookbook_studio = CookbookStudio.new if @cookbook_studio.nil?
|
115
|
+
@cookbook_studio
|
116
|
+
end
|
117
|
+
|
118
|
+
def habitat_studio
|
119
|
+
@habitat_studio = HabitatStudio.new if @habitat_studio.nil?
|
120
|
+
@habitat_studio
|
121
|
+
end
|
122
|
+
|
123
|
+
def cucumber_studio
|
124
|
+
@cucumber_studio = CucumberStudio.new if @cucumber_studio.nil?
|
125
|
+
@cucumber_studio
|
126
|
+
end
|
127
|
+
|
128
|
+
def studio_order
|
129
|
+
[ruby_studio, cookbook_studio, habitat_studio, cucumber_studio]
|
130
|
+
end
|
131
|
+
|
132
|
+
def do_begin
|
133
|
+
# @ruby_studio = Context::RubyStudio.new(organisation_name, context_name, context_folder) if ruby_studio.nil?
|
134
|
+
|
135
|
+
# @cookbook_studio = Context::CookbookStudio.new(organisation_name, context_name, context_folder, ruby_studio) if cookbook_studio.nil?
|
136
|
+
|
137
|
+
# @habitat_studio = Context::HabitatStudio.new(organisation_name, context_name, context_folder, ruby_studio) if habitat_studio.nil?
|
138
|
+
|
139
|
+
# @cucumber_studio = Context::CucumberStudio.new(organisation_name, context_name, context_folder, ruby_studio) if cucumber_studio.nil?
|
140
|
+
|
141
|
+
studio_order
|
142
|
+
end
|
143
|
+
|
144
|
+
# 2
|
145
|
+
def do_download
|
146
|
+
git_build(self)
|
147
|
+
end
|
148
|
+
|
149
|
+
# 3
|
150
|
+
def do_verify
|
151
|
+
git_build(self)
|
152
|
+
end
|
153
|
+
|
154
|
+
# 4
|
155
|
+
def do_clean
|
156
|
+
delete_file_only_if_exist(get_context_file(self, 'respond.txt'))
|
157
|
+
true
|
158
|
+
end
|
159
|
+
|
160
|
+
# 10
|
161
|
+
def do_strip
|
162
|
+
git_build(self)
|
163
|
+
end
|
164
|
+
|
165
|
+
# 11
|
166
|
+
def do_end
|
167
|
+
git_commit(self)
|
168
|
+
end
|
169
|
+
|
170
|
+
def studio_available?
|
171
|
+
is_binary_available?('git')
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
data/home/jimboadmin/deploy-context/habitat/plan.sh/x86_64-linux/lib/deploy-context/deploy/chef.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
module Context
|
2
|
+
module DeployHelpers
|
3
|
+
module ChefHelper
|
4
|
+
def prepare_workplan
|
5
|
+
FileUtils.mkdir 'workstation-space' unless Dir.exist?('workstation-space')
|
6
|
+
prepare_chef
|
7
|
+
prepare_gem
|
8
|
+
prepare_ssh
|
9
|
+
prepare_git
|
10
|
+
end
|
11
|
+
|
12
|
+
def prepare_chef
|
13
|
+
FileUtils.cp_r '/etc/chef', 'workstation-space/chef-client'
|
14
|
+
|
15
|
+
chef_user_keys_folder = 'workstation-space/chef_user_keys'
|
16
|
+
|
17
|
+
FileUtils.mkdir chef_user_keys_folder unless Dir.exist?(chef_user_keys_folder)
|
18
|
+
|
19
|
+
FileUtils.cp File.join(ENV['HOME'],'.chef/credentials'), 'workstation-space/chef_credentials'
|
20
|
+
client_keys = File.read('workstation-space/chef_credentials').split("\n").select do |line_str|
|
21
|
+
line_str.include?('client_key')
|
22
|
+
end
|
23
|
+
client_keys.each do |key_line|
|
24
|
+
key_file = key_line.split('=')[1].strip.split("'")[1]
|
25
|
+
debug_context_log 'Knife keys', "Copy file #{key_file} to #{chef_user_keys_folder}"
|
26
|
+
FileUtils.cp key_file, File.join(chef_user_keys_folder, File.basename(key_file))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def prepare_gem
|
31
|
+
FileUtils.cp File.join(ENV['HOME'],'.local/share/gem/credentials'), 'workstation-space/gem_credentials'
|
32
|
+
end
|
33
|
+
|
34
|
+
def prepare_ssh
|
35
|
+
FileUtils.cp_r File.join(ENV['HOME'],'.ssh'), 'workstation-space/ssh'
|
36
|
+
end
|
37
|
+
|
38
|
+
def prepare_git
|
39
|
+
FileUtils.cp File.join(ENV['HOME'],'.gitconfig'), 'workstation-space/gitconfig'
|
40
|
+
end
|
41
|
+
|
42
|
+
def generate_user_json
|
43
|
+
warning_context_log 'Habitat origin secrets', JSON.pretty_generate({
|
44
|
+
HAB_STUDIO_SECRET_CHEF_SERVER_URL: 'https://api.chef.io/organizations/jimbodragon',
|
45
|
+
HAB_STUDIO_SECRET_CHEFVALIDATORKEY: File.read('workstation-space/chef-client/validation.pem'),
|
46
|
+
HAB_STUDIO_SECRET_SSHPRIVATEKEY: File.read('workstation-space/ssh/id_rsa'),
|
47
|
+
HAB_STUDIO_SECRET_SSHPUBLICKEY: File.read('workstation-space/ssh/id_rsa.pub'),
|
48
|
+
HAB_STUDIO_SECRET_CLIENT_NAME: 'jprovencher',
|
49
|
+
HAB_STUDIO_SECRET_CLIENT_KEY: File.read('workstation-space/chef_user_keys/jprovencher.pem'),
|
50
|
+
HAB_STUDIO_SECRET_GEMAPI: File.read('workstation-space/gem_credentials'),
|
51
|
+
HAB_STUDIO_SECRET_EMAIL: 'jimmy.provencher@hotmail.ca',
|
52
|
+
HAB_STUDIO_SECRET_FULLNAME: 'Jimmy Provencher'
|
53
|
+
})
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|