pi_build_modifier 0.4.0.pre.alpha → 0.5.0.pre.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/CODE_OF_CONDUCT.md +1 -1
- data/README.md +55 -20
- data/Rakefile +6 -5
- data/docs/concept.md +0 -18
- data/docs/incubation.md +3 -14
- data/pi_build_modifier/Gemfile.lock +50 -0
- data/pi_build_modifier/lib/pi_build_modifier.rb +4 -7
- data/pi_build_modifier/lib/pi_build_modifier/modify/configs.rb +335 -0
- data/pi_build_modifier/lib/pi_build_modifier/modify/modifiers.rb +281 -0
- data/pi_build_modifier/lib/pi_build_modifier/{locale → modify}/templates/00-debconf.erb +1 -1
- data/pi_build_modifier/lib/pi_build_modifier/{boot-files → modify}/templates/07-resize-init.diff.erb +1 -1
- data/pi_build_modifier/lib/pi_build_modifier/{net-tweaks → modify}/templates/wpa_supplicant.conf.erb +1 -1
- data/pi_build_modifier/lib/pi_build_modifier/{config → utils}/logex.rb +5 -1
- data/pi_build_modifier/lib/pi_build_modifier/version.rb +1 -1
- data/pi_build_modifier/spec/pi_build_modifier/modify/modify_spec.rb +306 -0
- data/pi_build_modifier/spec/pi_build_modifier_spec.rb +3 -3
- data/pi_build_modifier/spec/spec_helper.rb +1 -0
- data/pi_customizer/Gemfile.lock +47 -0
- data/pi_customizer/lib/pi_customizer.rb +15 -9
- data/pi_customizer/lib/pi_customizer/build/builder/build_executor.rb +12 -24
- data/pi_customizer/lib/pi_customizer/build/builder/builder.rb +17 -13
- data/pi_customizer/{spec/pi_customizer/environment/environment_builder_factory_spec.rb → lib/pi_customizer/build/config/build_config.rb} +27 -18
- data/pi_customizer/lib/pi_customizer/build/{workspace → config}/local_workspace.rb +8 -8
- data/pi_customizer/lib/pi_customizer/build/{workspace → config}/remote_workspace.rb +1 -1
- data/pi_customizer/lib/pi_customizer/build/environment/docker/docker.rb +1 -1
- data/pi_customizer/lib/pi_customizer/build/environment/environment.rb +1 -1
- data/pi_customizer/lib/pi_customizer/build/{builder/start_prepare_execute_builder.rb → environment/environment_factory.rb} +27 -16
- data/pi_customizer/lib/pi_customizer/build/environment/vagrant/templates/Vagrantfile.erb +2 -2
- data/pi_customizer/lib/pi_customizer/build/environment/vagrant/vagrant.rb +3 -8
- data/pi_customizer/lib/pi_customizer/build/environment/vagrant/vagrant_file.rb +3 -3
- data/pi_customizer/lib/pi_customizer/version.rb +1 -1
- data/pi_customizer/lib/pi_customizer/write/image_writer.rb +3 -2
- data/pi_customizer/spec/pi_customizer/build/builder/builder_spec.rb +122 -0
- data/pi_customizer/spec/pi_customizer/{environment/aws_spec.rb → build/config/build_config_spec.rb} +20 -25
- data/pi_customizer/spec/pi_customizer/{workspace/local_workspace_spec.rb → build/config/local_workspace_config_spec.rb} +10 -10
- data/pi_customizer/spec/pi_customizer/{workspace → build/config}/remote_workspace_spec.rb +2 -2
- data/pi_customizer/spec/pi_customizer/{environment/vagrant/vagrant_spec.rb → build/environment/environment_builder_factory_spec.rb} +17 -13
- data/pi_customizer/spec/pi_customizer/{environment → build/environment}/environment_spec.rb +1 -1
- data/pi_customizer/spec/pi_customizer/{environment → build/environment}/vagrant/vagrant_file_spec.rb +7 -7
- data/pi_customizer/spec/pi_customizer/build/environment/vagrant/vagrant_spec.rb +80 -0
- data/pi_customizer/spec/pi_customizer_spec.rb +19 -14
- data/pi_customizer/spec/spec_helper.rb +21 -0
- data/version.rb +1 -1
- metadata +23 -42
- data/Vagrantfile +0 -27
- data/pi_build_modifier/.gitignore +0 -12
- data/pi_build_modifier/lib/pi_build_modifier/boot-files/boot.rb +0 -64
- data/pi_build_modifier/lib/pi_build_modifier/locale/locale_debconf.rb +0 -66
- data/pi_build_modifier/lib/pi_build_modifier/modifier/erb_mapper.rb +0 -72
- data/pi_build_modifier/lib/pi_build_modifier/modifier/mapper.rb +0 -49
- data/pi_build_modifier/lib/pi_build_modifier/modifier/pi_modifier.rb +0 -81
- data/pi_build_modifier/lib/pi_build_modifier/modifier_task.rb +0 -79
- data/pi_build_modifier/lib/pi_build_modifier/net-tweaks/wifi_network.rb +0 -124
- data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/run_modifier.rb +0 -63
- data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/ssh.rb +0 -61
- data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/templates/ssh.sh.erb +0 -8
- data/pi_build_modifier/lib/pi_build_modifier/system/system_type.rb +0 -84
- data/pi_build_modifier/spec/pi_build_modifier/boot/boot_spec.rb +0 -103
- data/pi_build_modifier/spec/pi_build_modifier/locale/locale_spec.rb +0 -87
- data/pi_build_modifier/spec/pi_build_modifier/modifier/mapper_spec.rb +0 -105
- data/pi_build_modifier/spec/pi_build_modifier/modifier/modifier_spec.rb +0 -83
- data/pi_build_modifier/spec/pi_build_modifier/modifier_task_spec.rb +0 -63
- data/pi_build_modifier/spec/pi_build_modifier/net-tweaks/wifi_network_spec.rb +0 -91
- data/pi_build_modifier/spec/pi_build_modifier/sys_tweaks/run_modifier_spec.rb +0 -74
- data/pi_build_modifier/spec/pi_build_modifier/sys_tweaks/ssh_spec.rb +0 -73
- data/pi_build_modifier/spec/pi_build_modifier/system/system_spec.rb +0 -66
- data/pi_customizer/lib/pi_customizer/build/builder/prepare_start_execute_builder.rb +0 -43
- data/pi_customizer/lib/pi_customizer/build/environment/aws/aws.rb +0 -76
- data/pi_customizer/lib/pi_customizer/build/environment/environment_builder_factory.rb +0 -81
- data/pi_customizer/spec/pi_customizer/builder/build_executor_spec.rb +0 -64
@@ -11,7 +11,7 @@ SCRIPT
|
|
11
11
|
|
12
12
|
$install_modifier_gem = <<SCRIPT
|
13
13
|
# install gem
|
14
|
-
<% if config.modifier_gem_path.nil? %>gem install pi_build_modifier --pre <% else %>gem install /home/
|
14
|
+
<% if config.modifier_gem_path.nil? %>gem install pi_build_modifier --pre <% else %>gem install /home/vagrant/pi_build_modifier.gem<% end %>
|
15
15
|
SCRIPT
|
16
16
|
|
17
17
|
$prepare = <<SCRIPT
|
@@ -44,7 +44,7 @@ Vagrant.configure('2') do |config|
|
|
44
44
|
# Prepare environment by updating the dependencies
|
45
45
|
config.vm.provision 'shell', inline: $dependencies
|
46
46
|
|
47
|
-
<% unless config.modifier_gem_path.nil? %>config.vm.provision 'file', source: '<%= config.modifier_gem_path.to_s %>', destination: '/home/
|
47
|
+
<% unless config.modifier_gem_path.nil? %>config.vm.provision 'file', source: '<%= config.modifier_gem_path.to_s %>', destination: '/home/vagrant/pi_build_modifier.gem' <% end %>
|
48
48
|
|
49
49
|
# Modifier gem is installed
|
50
50
|
config.vm.provision 'shell', inline: $install_modifier_gem
|
@@ -27,16 +27,15 @@ module PiCustomizer
|
|
27
27
|
module Environment
|
28
28
|
class Vagrant < EnvironmentControl
|
29
29
|
|
30
|
-
VAGRANT_SOURCE = File.join(File.dirname(__FILE__), '/templates')
|
31
|
-
|
32
30
|
def check
|
33
31
|
$logger.info '[Check] Pre-flight checks are executing...'
|
34
|
-
|
32
|
+
check_vagrant
|
35
33
|
end
|
36
34
|
|
37
35
|
def prepare
|
38
36
|
$logger.info '[Prepare] pi-image in vagrant environment'
|
39
37
|
VagrantFileRenderer.new(VagrantFile.new(@config, @workspace)).create_from_template
|
38
|
+
system 'vagrant box update' # cleanup old environment
|
40
39
|
end
|
41
40
|
|
42
41
|
def start
|
@@ -54,10 +53,6 @@ module PiCustomizer
|
|
54
53
|
end
|
55
54
|
end
|
56
55
|
|
57
|
-
def clean_up
|
58
|
-
$logger.info '[Clean Up] pi-image in local vagrant environment'
|
59
|
-
end
|
60
|
-
|
61
56
|
def stop
|
62
57
|
$logger.info '[Stop] pi-image in local vagrant environment'
|
63
58
|
Dir.chdir(@config.workspace_directory) do
|
@@ -65,7 +60,7 @@ module PiCustomizer
|
|
65
60
|
end
|
66
61
|
end
|
67
62
|
|
68
|
-
def
|
63
|
+
def check_vagrant
|
69
64
|
unless system 'vagrant -v'
|
70
65
|
raise 'Vagrant not installed. Please ensure that vagrant is installed correctly.'
|
71
66
|
end
|
@@ -20,8 +20,8 @@
|
|
20
20
|
|
21
21
|
require 'erb'
|
22
22
|
require 'fileutils'
|
23
|
-
require 'pi_customizer/build/
|
24
|
-
require 'pi_customizer/build/
|
23
|
+
require 'pi_customizer/build/config/remote_workspace'
|
24
|
+
require 'pi_customizer/build/config/local_workspace'
|
25
25
|
|
26
26
|
module PiCustomizer
|
27
27
|
module Environment
|
@@ -38,7 +38,7 @@ module PiCustomizer
|
|
38
38
|
@disk_size = '60GB'
|
39
39
|
@config_file_destination = '/vagrant/config.json'
|
40
40
|
@config = if config.nil?
|
41
|
-
Workspace::
|
41
|
+
Workspace::LocalWorkspaceConfig.new
|
42
42
|
else
|
43
43
|
config
|
44
44
|
end
|
@@ -40,6 +40,7 @@ module PiCustomizer
|
|
40
40
|
end
|
41
41
|
|
42
42
|
private def dispatch_write(image, device)
|
43
|
+
puts "Note: Writing #{image} to #{device} requires sudo privileges"
|
43
44
|
extension = File.extname(image)
|
44
45
|
if @zip_formats.include? extension
|
45
46
|
write_zip(image, device)
|
@@ -51,11 +52,11 @@ module PiCustomizer
|
|
51
52
|
end
|
52
53
|
|
53
54
|
private def write_zip(image, device)
|
54
|
-
run("unzip -p #{image} | dd of=#{device} bs=4M conv=fsync")
|
55
|
+
run("unzip -p #{image} | sudo dd of=#{device} bs=4M conv=fsync")
|
55
56
|
end
|
56
57
|
|
57
58
|
private def write_img(image, device)
|
58
|
-
run("dd if=#{image} of=#{device} bs=4M conv=fsync")
|
59
|
+
run("sudo dd if=#{image} of=#{device} bs=4M conv=fsync")
|
59
60
|
end
|
60
61
|
|
61
62
|
private def run(command)
|
@@ -0,0 +1,122 @@
|
|
1
|
+
# Copyright (c) 2017-2019 Beate Ottenwälder
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
|
21
|
+
require_relative '../../../spec_helper'
|
22
|
+
require 'rspec'
|
23
|
+
require 'pi_customizer/build/builder/builder'
|
24
|
+
require 'pi_customizer/build/config/build_config'
|
25
|
+
require 'pi_customizer/build/environment/environment_factory'
|
26
|
+
|
27
|
+
describe PiCustomizer::Builder do
|
28
|
+
|
29
|
+
context 'Builder' do
|
30
|
+
|
31
|
+
it 'triggers the build executor' do
|
32
|
+
expect_any_instance_of(PiCustomizer::Builder::BuildExecutor).to receive(:check)
|
33
|
+
expect_any_instance_of(PiCustomizer::Builder::BuildExecutor).to receive(:stop)
|
34
|
+
builder = PiCustomizer::Builder::PiBuilder.new
|
35
|
+
builder.build(PiCustomizer::Environment::environment_factory(PiCustomizer::Environment::ENV_ECHO, nil, nil), PiCustomizer::Config::BuildConfig.new([]))
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'BuildExecutor' do
|
41
|
+
|
42
|
+
it 'honors skipping the build step prepare' do
|
43
|
+
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('', ''), PiCustomizer::Config::BuildConfig.new([:prepare]))
|
44
|
+
expect(build_exec.env).not_to receive(:prepare)
|
45
|
+
build_exec.prepare
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'honors skipping the build step start' do
|
49
|
+
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('', ''), PiCustomizer::Config::BuildConfig.new([:start]))
|
50
|
+
expect(build_exec.env).not_to receive(:start)
|
51
|
+
build_exec.start
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'honors skipping the build step' do
|
55
|
+
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('', ''), PiCustomizer::Config::BuildConfig.new([:build_image]))
|
56
|
+
expect(build_exec.env).not_to receive(:build_image)
|
57
|
+
build_exec.build_image
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'honors skipping the publish step' do
|
61
|
+
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('', ''), PiCustomizer::Config::BuildConfig.new([:publish]))
|
62
|
+
expect(build_exec.env).not_to receive(:publish)
|
63
|
+
build_exec.publish
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'honors skipping the build step clean' do
|
67
|
+
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('', ''), PiCustomizer::Config::BuildConfig.new([:clean_up]))
|
68
|
+
expect(build_exec.env).not_to receive(:clean_up)
|
69
|
+
build_exec.clean_up
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'honors skipping the build step stop' do
|
73
|
+
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('', ''), PiCustomizer::Config::BuildConfig.new([:stop]))
|
74
|
+
expect(build_exec.env).not_to receive(:stop)
|
75
|
+
build_exec.stop
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'honors not skipping the build step check' do
|
79
|
+
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('', ''), PiCustomizer::Config::BuildConfig.new([]))
|
80
|
+
expect(build_exec.env).to receive(:check)
|
81
|
+
build_exec.check
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'honors not skipping the build step prepare' do
|
85
|
+
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('', ''), PiCustomizer::Config::BuildConfig.new([]))
|
86
|
+
expect(build_exec.env).to receive(:prepare)
|
87
|
+
build_exec.prepare
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'honors not skipping the build step start' do
|
91
|
+
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('', ''), PiCustomizer::Config::BuildConfig.new([]))
|
92
|
+
expect(build_exec.env).to receive(:start)
|
93
|
+
build_exec.start
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'honors not skipping the build step' do
|
97
|
+
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('', ''), PiCustomizer::Config::BuildConfig.new([]))
|
98
|
+
expect(build_exec.env).to receive(:build_image)
|
99
|
+
build_exec.build_image
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'honors not skipping the publish step' do
|
103
|
+
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('', ''), PiCustomizer::Config::BuildConfig.new([]))
|
104
|
+
expect(build_exec.env).to receive(:publish)
|
105
|
+
build_exec.publish
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'honors not skipping the build step clean' do
|
109
|
+
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('', ''), PiCustomizer::Config::BuildConfig.new([]))
|
110
|
+
expect(build_exec.env).to receive(:clean_up)
|
111
|
+
build_exec.clean_up
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'honors not skipping the build step stop' do
|
115
|
+
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('', ''), PiCustomizer::Config::BuildConfig.new([]))
|
116
|
+
expect(build_exec.env).to receive(:stop)
|
117
|
+
build_exec.stop
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
data/pi_customizer/spec/pi_customizer/{environment/aws_spec.rb → build/config/build_config_spec.rb}
RENAMED
@@ -18,40 +18,35 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
19
|
# SOFTWARE.
|
20
20
|
|
21
|
-
require_relative '
|
22
|
-
require 'pi_customizer/build/
|
23
|
-
require 'fileutils'
|
24
|
-
require 'pathname'
|
21
|
+
require_relative '../../../spec_helper'
|
22
|
+
require 'pi_customizer/build/config/build_config'
|
25
23
|
|
26
24
|
module PiCustomizer
|
27
|
-
module
|
28
|
-
RSpec.describe
|
25
|
+
module Config
|
26
|
+
RSpec.describe BuildConfig do
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
AWS.new(nil, '').create_keys(key_name)
|
34
|
-
expect(Pathname.new("ssh/#{key_name}.pem")).to be_file
|
35
|
-
expect(Pathname.new("ssh/#{key_name}.pub")).to be_file
|
28
|
+
it 'has a default config where no build steps are skipped' do
|
29
|
+
build_config = BuildConfig.new
|
30
|
+
expect(build_config.skip_build_steps.count).to eq 0
|
36
31
|
end
|
37
32
|
|
38
|
-
it '
|
39
|
-
|
40
|
-
|
41
|
-
|
33
|
+
it 'allows us to specify build steps that need to be skipped' do
|
34
|
+
build_config = BuildConfig.new(['test'])
|
35
|
+
expect(build_config.skip_build_steps.count).to eq 1
|
36
|
+
expect(build_config.skip_build_steps).to include :test
|
37
|
+
expect(build_config.skip_build_steps).not_to include('test')
|
38
|
+
end
|
42
39
|
|
43
|
-
|
44
|
-
|
40
|
+
it 'allows us to query for individually skipped build steps' do
|
41
|
+
build_config = BuildConfig.new(['test'])
|
42
|
+
expect(build_config.skip? :test).to be true
|
45
43
|
end
|
46
44
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
51
|
-
if File.file?("ssh/#{key_name}.pub")
|
52
|
-
FileUtils.rm "ssh/#{key_name}.pub"
|
53
|
-
end
|
45
|
+
it 'allows us to query for build steps that are not skipped' do
|
46
|
+
build_config = BuildConfig.new(['test'])
|
47
|
+
expect(build_config.skip? :foo).to be false
|
54
48
|
end
|
49
|
+
|
55
50
|
end
|
56
51
|
end
|
57
52
|
end
|
@@ -18,19 +18,19 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
19
|
# SOFTWARE.
|
20
20
|
|
21
|
-
require_relative '
|
22
|
-
require 'pi_customizer/build/
|
21
|
+
require_relative '../../../spec_helper'
|
22
|
+
require 'pi_customizer/build/config/local_workspace'
|
23
23
|
require 'fileutils'
|
24
24
|
require 'pathname'
|
25
25
|
|
26
26
|
module PiCustomizer
|
27
27
|
module Workspace
|
28
|
-
RSpec.describe
|
28
|
+
RSpec.describe LocalWorkspaceConfig do
|
29
29
|
|
30
30
|
it 'uses default values for config_path and tmp_directory when no path is specified' do
|
31
31
|
#Given
|
32
32
|
#When
|
33
|
-
local_config =
|
33
|
+
local_config = LocalWorkspaceConfig.new('', '', '')
|
34
34
|
#Then
|
35
35
|
expect(local_config.config_path.to_s).to eq DEFAULT_CONFIG_PATH
|
36
36
|
expect(local_config.workspace_directory.to_s).to eq DEFAULT_LOCAL_WORKSPACE_DIRECTORY
|
@@ -43,7 +43,7 @@ module PiCustomizer
|
|
43
43
|
expected_tmp = '/home/test/tmp'
|
44
44
|
expected_mod = '/home/test/mod.gem'
|
45
45
|
#When
|
46
|
-
local_config =
|
46
|
+
local_config = LocalWorkspaceConfig.new(expected_cfg, expected_tmp, expected_mod)
|
47
47
|
#Then
|
48
48
|
expect(local_config.config_path.to_s).to eq expected_cfg
|
49
49
|
expect(local_config.workspace_directory.to_s).to eq expected_tmp
|
@@ -51,21 +51,21 @@ module PiCustomizer
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'accepts relative paths for config_path and stores them as absolute paths' do
|
54
|
-
local_config =
|
54
|
+
local_config = LocalWorkspaceConfig.new('a', 'b', 'c')
|
55
55
|
expect(local_config.config_path.to_s).to eq File.join(Dir.pwd, '/a')
|
56
56
|
expect(local_config.workspace_directory.to_s).to eq File.join(Dir.pwd, '/b')
|
57
57
|
expect(local_config.modifier_gem_path.to_s).to eq File.join(Dir.pwd, '/c')
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'allows us to check for value equality' do
|
61
|
-
local_config_1 =
|
62
|
-
local_config_2 =
|
61
|
+
local_config_1 = LocalWorkspaceConfig.new('a', 'b', 'c')
|
62
|
+
local_config_2 = LocalWorkspaceConfig.new('a', 'b', 'c')
|
63
63
|
expect(local_config_1==local_config_2).to be true
|
64
64
|
end
|
65
65
|
|
66
66
|
it 'allows us to check for value inequality' do
|
67
|
-
local_config_1 =
|
68
|
-
local_config_2 =
|
67
|
+
local_config_1 = LocalWorkspaceConfig.new('a', 'b', 'c')
|
68
|
+
local_config_2 = LocalWorkspaceConfig.new('e', 'f', 'g')
|
69
69
|
expect(local_config_1==local_config_2).to be false
|
70
70
|
end
|
71
71
|
|
@@ -18,10 +18,10 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
19
|
# SOFTWARE.
|
20
20
|
|
21
|
-
require_relative '
|
21
|
+
require_relative '../../../spec_helper'
|
22
22
|
require 'fileutils'
|
23
23
|
require 'pathname'
|
24
|
-
require 'pi_customizer/build/
|
24
|
+
require 'pi_customizer/build/config/remote_workspace'
|
25
25
|
|
26
26
|
|
27
27
|
RSpec.describe PiCustomizer::Workspace::RemoteWorkspace do
|
@@ -19,23 +19,27 @@
|
|
19
19
|
# SOFTWARE.
|
20
20
|
|
21
21
|
require_relative '../../../spec_helper'
|
22
|
-
require '
|
23
|
-
require '
|
22
|
+
require 'rspec'
|
23
|
+
require 'pi_customizer/build/environment/environment_factory'
|
24
|
+
require 'pi_customizer/build/environment/environment'
|
25
|
+
require 'pi_customizer/build/environment/docker/docker'
|
24
26
|
require 'pi_customizer/build/environment/vagrant/vagrant'
|
25
27
|
|
26
|
-
|
27
|
-
module Environment
|
28
|
-
RSpec.describe Vagrant do
|
28
|
+
RSpec.describe 'environment_factory' do
|
29
29
|
|
30
|
-
|
30
|
+
it 'creates a vagrant environment when ENV_VAGRANT is specified' do
|
31
|
+
env = PiCustomizer::Environment::environment_factory(PiCustomizer::Environment::ENV_VAGRANT, '', '')
|
32
|
+
expect(env).to be_a PiCustomizer::Environment::Vagrant
|
33
|
+
end
|
31
34
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
35
|
+
it 'creates a docker environment when ENV_DOCKER is specified' do
|
36
|
+
env = PiCustomizer::Environment::environment_factory(PiCustomizer::Environment::ENV_DOCKER, '', '')
|
37
|
+
expect(env).to be_a PiCustomizer::Environment::Docker
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
+
it 'creates an echo environment when ENV_ECHO is specified' do
|
41
|
+
env = PiCustomizer::Environment::environment_factory(PiCustomizer::Environment::ENV_DOCKER, '', '')
|
42
|
+
expect(env).to be_a PiCustomizer::Environment::Docker
|
40
43
|
end
|
44
|
+
|
41
45
|
end
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
19
|
# SOFTWARE.
|
20
20
|
|
21
|
-
require_relative '
|
21
|
+
require_relative '../../../spec_helper'
|
22
22
|
require 'rspec'
|
23
23
|
require 'pi_customizer/build/environment/environment'
|
24
24
|
require 'pi_customizer/utils/logex'
|
data/pi_customizer/spec/pi_customizer/{environment → build/environment}/vagrant/vagrant_file_spec.rb
RENAMED
@@ -18,9 +18,9 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
19
|
# SOFTWARE.
|
20
20
|
|
21
|
-
require_relative '
|
21
|
+
require_relative '../../../../spec_helper'
|
22
22
|
require 'pi_customizer/build/environment/vagrant/vagrant_file'
|
23
|
-
require 'pi_customizer/build/
|
23
|
+
require 'pi_customizer/build/config/local_workspace'
|
24
24
|
require 'fileutils'
|
25
25
|
require 'pathname'
|
26
26
|
|
@@ -29,28 +29,28 @@ module PiCustomizer
|
|
29
29
|
RSpec.describe Environment::VagrantFileRenderer do
|
30
30
|
|
31
31
|
let(:tmp_dir) {'tmp_vagrant_file'}
|
32
|
-
let(:vagrant_file) {Environment::VagrantFile.new(Workspace::
|
32
|
+
let(:vagrant_file) {Environment::VagrantFile.new(Workspace::LocalWorkspaceConfig.new('', tmp_dir, ''), nil)}
|
33
33
|
let(:vagrant_file_builder) {Environment::VagrantFileRenderer.new(vagrant_file)}
|
34
34
|
let(:test_vagrant_file) {File.dirname(__FILE__) + '/../../../fixtures/TestVagrantfile'}
|
35
35
|
|
36
36
|
after(:each) do
|
37
|
-
|
37
|
+
FileUtils.rm_rf tmp_dir
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'renders a Vagrantfile in the given temporary directory' do
|
41
41
|
vagrant_file_builder.create_from_template
|
42
|
-
expect(Pathname.new(tmp_dir+'/Vagrantfile')).to be_file
|
42
|
+
expect(Pathname.new(tmp_dir + '/Vagrantfile')).to be_file
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'renders a Vagrantfile which copies a gem to the vagrant box when the modifier_gem_path is given' do
|
46
46
|
#Given
|
47
47
|
gem_name = 'my_gem.gem'
|
48
|
-
v_file = Environment::VagrantFile.new(Workspace::
|
48
|
+
v_file = Environment::VagrantFile.new(Workspace::LocalWorkspaceConfig.new('', tmp_dir, gem_name), nil)
|
49
49
|
v_file_builder = Environment::VagrantFileRenderer.new(v_file)
|
50
50
|
#When
|
51
51
|
v_file_builder.create_from_template
|
52
52
|
#Then
|
53
|
-
expect(File.read(tmp_dir+'/Vagrantfile').to_s).to match(/config.vm.provision 'file', source: [-a-zA-Z0-9'\/_]+#{gem_name}/)
|
53
|
+
expect(File.read(tmp_dir + '/Vagrantfile').to_s).to match(/config.vm.provision 'file', source: [-a-zA-Z0-9'\/_]+#{gem_name}/)
|
54
54
|
#expect(File.read(tmp_dir+'/Vagrantfile').to_s).to eq File.read(test_vagrant_file).to_s
|
55
55
|
end
|
56
56
|
|