pi_customizer 0.3.0.pre.alpha → 0.3.1.pre.alpha
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
- data/.gitignore +24 -0
- data/.travis.yml +28 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/LICENSE +1 -1
- data/README.md +208 -2
- data/Rakefile +134 -6
- data/Vagrantfile +13 -2
- data/docs/concept.md +27 -0
- data/docs/incubation.md +38 -0
- data/pi_build_modifier/.gitignore +12 -0
- data/{.rspec → pi_build_modifier/.rspec} +0 -0
- data/pi_build_modifier/Gemfile +6 -0
- data/pi_build_modifier/LICENSE.txt +21 -0
- data/pi_build_modifier/README.md +3 -0
- data/pi_build_modifier/Rakefile +13 -0
- data/pi_build_modifier/bin/pi_build_modifier +25 -0
- data/pi_build_modifier/lib/pi_build_modifier.rb +53 -0
- data/pi_build_modifier/lib/pi_build_modifier/boot-files/boot.rb +64 -0
- data/pi_build_modifier/lib/pi_build_modifier/boot-files/templates/07-resize-init.diff.erb +5 -0
- data/pi_build_modifier/lib/pi_build_modifier/config/logex.rb +25 -0
- data/pi_build_modifier/lib/pi_build_modifier/locale/locale_debconf.rb +66 -0
- data/pi_build_modifier/lib/pi_build_modifier/locale/templates/00-debconf.erb +6 -0
- data/pi_build_modifier/lib/pi_build_modifier/modifier/erb_mapper.rb +72 -0
- data/pi_build_modifier/lib/pi_build_modifier/modifier/mapper.rb +49 -0
- data/pi_build_modifier/lib/pi_build_modifier/modifier/pi_modifier.rb +81 -0
- data/pi_build_modifier/lib/pi_build_modifier/modifier_task.rb +79 -0
- data/pi_build_modifier/lib/pi_build_modifier/net-tweaks/templates/wpa_supplicant.conf.erb +5 -0
- data/pi_build_modifier/lib/pi_build_modifier/net-tweaks/wifi_network.rb +124 -0
- data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/run_modifier.rb +63 -0
- data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/ssh.rb +61 -0
- data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/templates/ssh.sh.erb +8 -0
- data/pi_build_modifier/lib/pi_build_modifier/system/system_type.rb +84 -0
- data/pi_build_modifier/lib/pi_build_modifier/version.rb +23 -0
- data/pi_build_modifier/pi_build_modifier.gemspec +32 -0
- data/pi_build_modifier/spec/fixtures/config.json +26 -0
- data/pi_build_modifier/spec/pi_build_modifier/boot/boot_spec.rb +103 -0
- data/pi_build_modifier/spec/pi_build_modifier/locale/locale_spec.rb +87 -0
- data/pi_build_modifier/spec/pi_build_modifier/modifier/mapper_spec.rb +105 -0
- data/pi_build_modifier/spec/pi_build_modifier/modifier/modifier_spec.rb +83 -0
- data/pi_build_modifier/spec/pi_build_modifier/modifier_task_spec.rb +63 -0
- data/pi_build_modifier/spec/pi_build_modifier/net-tweaks/wifi_network_spec.rb +91 -0
- data/pi_build_modifier/spec/pi_build_modifier/sys_tweaks/run_modifier_spec.rb +74 -0
- data/pi_build_modifier/spec/pi_build_modifier/sys_tweaks/ssh_spec.rb +73 -0
- data/pi_build_modifier/spec/pi_build_modifier/system/system_spec.rb +66 -0
- data/pi_build_modifier/spec/pi_build_modifier_spec.rb +73 -0
- data/pi_build_modifier/spec/spec_helper.rb +10 -0
- data/pi_customizer/.rspec +2 -0
- data/{Gemfile → pi_customizer/Gemfile} +0 -0
- data/pi_customizer/LICENSE +21 -0
- data/pi_customizer/README.md +3 -0
- data/pi_customizer/Rakefile +13 -0
- data/pi_customizer/Vagrantfile +16 -0
- data/{bin → pi_customizer/bin}/pi_customizer +1 -1
- data/{envs → pi_customizer/envs}/aws/outputs.tf +0 -0
- data/{envs → pi_customizer/envs}/aws/pi-build-env.tf +0 -0
- data/{envs → pi_customizer/envs}/aws/variables.tf +0 -0
- data/{envs → pi_customizer/envs}/docker/Dockerfile +0 -0
- data/{envs → pi_customizer/envs}/sh/build-pi-img.sh +0 -0
- data/{lib → pi_customizer/lib}/pi_customizer.rb +7 -6
- data/{lib → pi_customizer/lib}/pi_customizer/build/builder/build_executor.rb +31 -2
- data/{lib → pi_customizer/lib}/pi_customizer/build/builder/builder.rb +4 -2
- data/{lib → pi_customizer/lib}/pi_customizer/build/builder/prepare_start_execute_builder.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/build/builder/start_prepare_execute_builder.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/build/environment/aws/aws.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/build/environment/docker/docker.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/build/environment/environment.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/build/environment/environment_builder_factory.rb +9 -3
- data/{lib → pi_customizer/lib}/pi_customizer/build/environment/vagrant/templates/Vagrantfile.erb +3 -7
- data/{lib → pi_customizer/lib}/pi_customizer/build/environment/vagrant/vagrant.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/build/environment/vagrant/vagrant_file.rb +2 -2
- data/{lib → pi_customizer/lib}/pi_customizer/build/workspace/local_workspace.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/build/workspace/remote_workspace.rb +14 -4
- data/{lib → pi_customizer/lib}/pi_customizer/utils/logex.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/version.rb +2 -2
- data/{lib → pi_customizer/lib}/pi_customizer/write/image_writer.rb +1 -1
- data/{pi_customizer.gemspec → pi_customizer/pi_customizer.gemspec} +5 -5
- data/pi_customizer/spec/fixtures/TestVagrantfile +61 -0
- data/pi_customizer/spec/fixtures/image.img +1 -0
- data/pi_customizer/spec/fixtures/image.zip +0 -0
- data/pi_customizer/spec/pi_customizer/builder/build_executor_spec.rb +64 -0
- data/pi_customizer/spec/pi_customizer/environment/aws_spec.rb +57 -0
- data/pi_customizer/spec/pi_customizer/environment/environment_builder_factory_spec.rb +48 -0
- data/pi_customizer/spec/pi_customizer/environment/environment_spec.rb +75 -0
- data/pi_customizer/spec/pi_customizer/environment/vagrant/vagrant_file_spec.rb +63 -0
- data/pi_customizer/spec/pi_customizer/environment/vagrant/vagrant_spec.rb +41 -0
- data/pi_customizer/spec/pi_customizer/version_spec.rb +29 -0
- data/pi_customizer/spec/pi_customizer/workspace/local_workspace_spec.rb +74 -0
- data/pi_customizer/spec/pi_customizer/workspace/remote_workspace_spec.rb +51 -0
- data/pi_customizer/spec/pi_customizer/write/image_writer_spec.rb +59 -0
- data/pi_customizer/spec/pi_customizer_spec.rb +93 -0
- data/pi_customizer/spec/spec_helper.rb +10 -0
- data/version.rb +21 -0
- metadata +102 -41
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2017-
|
1
|
+
# Copyright (c) 2017-2019 Beate Ottenwälder
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -34,14 +34,19 @@ module PiCustomizer
|
|
34
34
|
|
35
35
|
DEFAULT_GIT_PATH = 'https://github.com/ottenwbe/pi-gen.git'
|
36
36
|
|
37
|
+
##
|
38
|
+
# the default directory for the build sources
|
39
|
+
|
40
|
+
DEFAULT_GIT_TAG = 'master'
|
41
|
+
|
37
42
|
##
|
38
43
|
# The RemoteWorkspace class encapsulates the configuration of the workspace in the build environment
|
39
44
|
|
40
45
|
class RemoteWorkspace
|
41
46
|
|
42
|
-
attr_reader :git_path, :workspace_directory
|
47
|
+
attr_reader :git_path, :workspace_directory, :git_tag
|
43
48
|
|
44
|
-
def initialize(workspace_dir = '', git_path = '')
|
49
|
+
def initialize(workspace_dir = '', git_path = '', git_tag = '')
|
45
50
|
@workspace_directory = if workspace_dir.nil? or workspace_dir == ''
|
46
51
|
DEFAULT_REMOTE_WORKSPACE_DIRECTORY
|
47
52
|
else
|
@@ -52,6 +57,11 @@ module PiCustomizer
|
|
52
57
|
else
|
53
58
|
git_path.to_s
|
54
59
|
end
|
60
|
+
@git_tag = if git_tag.nil? or git_tag == ''
|
61
|
+
DEFAULT_GIT_TAG
|
62
|
+
else
|
63
|
+
git_tag.to_s
|
64
|
+
end
|
55
65
|
$logger.debug "Workspace at '#{@workspace_directory}' with sources from '#{@git_path}'"
|
56
66
|
end
|
57
67
|
|
@@ -59,7 +69,7 @@ module PiCustomizer
|
|
59
69
|
# Checks for value equality between a pair of RemoteWorkspace's attributes
|
60
70
|
|
61
71
|
def ==(other)
|
62
|
-
(@git_path == other.git_path) && (@workspace_directory == other.workspace_directory)
|
72
|
+
(@git_path == other.git_path) && (@workspace_directory == other.workspace_directory) && (@git_tag == other.git_tag)
|
63
73
|
end
|
64
74
|
|
65
75
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2017-
|
1
|
+
# Copyright (c) 2017-2019 Beate Ottenwälder
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -23,5 +23,5 @@ module PiCustomizer
|
|
23
23
|
##
|
24
24
|
# The current version of the pi_customizer gem
|
25
25
|
|
26
|
-
VERSION = '0.3.
|
26
|
+
VERSION = '0.3.1.pre.alpha'
|
27
27
|
end
|
@@ -21,10 +21,10 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f)}
|
22
22
|
spec.require_paths = ['lib']
|
23
23
|
|
24
|
-
spec.add_development_dependency 'bundler', '~>
|
25
|
-
spec.add_development_dependency 'rake', '~>
|
26
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
27
|
-
spec.add_development_dependency 'simplecov', '~> 0.
|
28
|
-
spec.add_development_dependency 'rdoc', '~>
|
24
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
25
|
+
spec.add_development_dependency 'rake', '~> 12.3'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.8'
|
27
|
+
spec.add_development_dependency 'simplecov', '~> 0.16'
|
28
|
+
spec.add_development_dependency 'rdoc', '~> 6.1'
|
29
29
|
spec.add_runtime_dependency 'thor', '~> 0.20'
|
30
30
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
$dependencies = <<SCRIPT
|
5
|
+
sudo apt update
|
6
|
+
sudo apt -y upgrade
|
7
|
+
sudo apt -y install quilt parted qemu-user-static debootstrap zerofree pxz zip dosfstools libcap2-bin bsdtar
|
8
|
+
sudo apt -y install git curl ruby-full build-essential
|
9
|
+
sudo apt -y install wpasupplicant openssl libssl-dev
|
10
|
+
SCRIPT
|
11
|
+
|
12
|
+
$install_modifier_gem = <<SCRIPT
|
13
|
+
# install gem
|
14
|
+
gem install /home/ubuntu/pi_build_modifier.gem
|
15
|
+
SCRIPT
|
16
|
+
|
17
|
+
$prepare = <<SCRIPT
|
18
|
+
rm -rf /build/pi-gen
|
19
|
+
mkdir -p /build/pi-gen
|
20
|
+
echo 'git clone to workspace'
|
21
|
+
git clone --branch master https://github.com/ottenwbe/pi-gen.git /build/pi-gen
|
22
|
+
SCRIPT
|
23
|
+
|
24
|
+
$modify = <<SCRIPT
|
25
|
+
# Execute gem with parameters
|
26
|
+
cd /build/pi-gen
|
27
|
+
pi_build_modifier modify /vagrant/config.json /build/pi-gen
|
28
|
+
sudo ./build.sh
|
29
|
+
mkdir -p /build/pi-gen/deploy
|
30
|
+
cp -r /build/pi-gen/deploy /vagrant
|
31
|
+
echo "Pi Image copied to your local workspace ~/workspace/pi-gen-environment/tmp_vagrant_file"
|
32
|
+
SCRIPT
|
33
|
+
|
34
|
+
Vagrant.configure('2') do |config|
|
35
|
+
|
36
|
+
config.vm.box = 'ubuntu/xenial64' #Note, that 'debian/stretch64' cannot be resized with the disksize plugin
|
37
|
+
|
38
|
+
unless Vagrant.has_plugin?("vagrant-disksize")
|
39
|
+
raise 'vagrant-disksize plugin is not installed! Use: vagrant plugin install vagrant-disksize'
|
40
|
+
end
|
41
|
+
|
42
|
+
config.disksize.size = '60GB'
|
43
|
+
|
44
|
+
# Prepare environment by updating the dependencies
|
45
|
+
config.vm.provision 'shell', inline: $dependencies
|
46
|
+
|
47
|
+
config.vm.provision 'file', source: '~/workspace/pi-gen-environment/my_gem.gem', destination: '/home/ubuntu/pi_build_modifier.gem'
|
48
|
+
|
49
|
+
# Modifier gem is installed
|
50
|
+
config.vm.provision 'shell', inline: $install_modifier_gem
|
51
|
+
|
52
|
+
# Copy config file
|
53
|
+
config.vm.provision 'file', source: '~/workspace/pi-gen-environment/pi_customizer/lib/pi_customizer/build/workspace/../../../../resources/config.json', destination: '/vagrant/config.json'
|
54
|
+
|
55
|
+
# Prepare the modification
|
56
|
+
config.vm.provision 'shell', inline: $prepare
|
57
|
+
|
58
|
+
# Actually modify the build sources and then build the environment
|
59
|
+
config.vm.provision 'shell', inline: $modify
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
test
|
Binary file
|
@@ -0,0 +1,64 @@
|
|
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/build_executor'
|
24
|
+
require 'pi_customizer/build/environment/environment'
|
25
|
+
|
26
|
+
describe PiCustomizer::Builder::BuildExecutor do
|
27
|
+
|
28
|
+
it 'internally converts keys of skip steps to symbols' do
|
29
|
+
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('',''), ['prepare'])
|
30
|
+
expect(build_exec.skip_build_steps).to include(:prepare)
|
31
|
+
expect(build_exec.skip_build_steps).not_to include('prepare')
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
it 'honors skipping the build step prepare' do
|
36
|
+
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('',''), [:prepare])
|
37
|
+
expect(build_exec.env).not_to receive(:prepare)
|
38
|
+
build_exec.prepare
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'honors skipping the build step start' do
|
42
|
+
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('',''), [:start])
|
43
|
+
expect(build_exec.env).not_to receive(:start)
|
44
|
+
build_exec.start
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'honors skipping the build step' do
|
48
|
+
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('',''), [:build_image])
|
49
|
+
expect(build_exec.env).not_to receive(:build_image)
|
50
|
+
build_exec.build_image
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'honors skipping the build step clean' do
|
54
|
+
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('',''), [:clean_up])
|
55
|
+
expect(build_exec.env).not_to receive(:clean_up)
|
56
|
+
build_exec.clean_up
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'honors skipping the build step stop' do
|
60
|
+
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('',''), [:stop])
|
61
|
+
expect(build_exec.env).not_to receive(:stop)
|
62
|
+
build_exec.stop
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,57 @@
|
|
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 'pi_customizer/build/environment/aws/aws'
|
23
|
+
require 'fileutils'
|
24
|
+
require 'pathname'
|
25
|
+
|
26
|
+
module PiCustomizer
|
27
|
+
module Environment
|
28
|
+
RSpec.describe AWS do
|
29
|
+
|
30
|
+
let(:key_name) {'pi-test'}
|
31
|
+
|
32
|
+
it 'creates an ssh key' do
|
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
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'deletes an existing ssh key' do
|
39
|
+
aws = AWS.new(nil, '')
|
40
|
+
aws.create_keys(key_name)
|
41
|
+
aws.del_keys(key_name)
|
42
|
+
|
43
|
+
expect(Pathname.new("ssh/#{key_name}.pem")).to_not be_file
|
44
|
+
expect(Pathname.new("ssh/#{key_name}.pub")).to_not be_file
|
45
|
+
end
|
46
|
+
|
47
|
+
after(:each) do
|
48
|
+
if File.file?("ssh/#{key_name}.pub")
|
49
|
+
FileUtils.rm "ssh/#{key_name}.pem"
|
50
|
+
end
|
51
|
+
if File.file?("ssh/#{key_name}.pub")
|
52
|
+
FileUtils.rm "ssh/#{key_name}.pub"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,48 @@
|
|
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/environment/environment_builder_factory'
|
24
|
+
require 'pi_customizer/build/environment/docker/docker'
|
25
|
+
require 'pi_customizer/build/environment/aws/aws'
|
26
|
+
|
27
|
+
module PiCustomizer
|
28
|
+
module Environment
|
29
|
+
RSpec.describe 'environment_factory' do
|
30
|
+
|
31
|
+
it 'creates a vagrant environment when ENV_VAGRANT is specified' do
|
32
|
+
env = Environment::environment_factory(ENV_VAGRANT, '', '')
|
33
|
+
expect(env).to be_a Vagrant
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'creates a docker environment when ENV_DOCKER is specified' do
|
37
|
+
env = Environment::environment_factory(ENV_DOCKER, '', '')
|
38
|
+
expect(env).to be_a Docker
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'creates an AWS environment when ENV_AWS is specified' do
|
42
|
+
env = Environment::environment_factory(ENV_AWS, '', '')
|
43
|
+
expect(env).to be_a AWS
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,75 @@
|
|
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/environment/environment'
|
24
|
+
require 'pi_customizer/utils/logex'
|
25
|
+
|
26
|
+
RSpec.describe PiCustomizer::Environment::EnvironmentControl do
|
27
|
+
|
28
|
+
let(:environment) {PiCustomizer::Environment::EnvironmentControl.new(nil,nil)}
|
29
|
+
|
30
|
+
|
31
|
+
it 'warns about skipped check steps' do
|
32
|
+
expect($logger).to receive(:warn).with(/skipped/)
|
33
|
+
environment.check
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'warns about skipped prepare steps' do
|
37
|
+
expect($logger).to receive(:warn).with(/skipped/)
|
38
|
+
environment.prepare
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'warns about skipped start steps' do
|
42
|
+
expect($logger).to receive(:warn).with(/skipped/)
|
43
|
+
environment.start
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'warns about skipped build steps' do
|
47
|
+
expect($logger).to receive(:warn).with(/skipped/)
|
48
|
+
environment.build_image
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'warns about skipped publish steps' do
|
52
|
+
expect($logger).to receive(:warn).with(/skipped/)
|
53
|
+
environment.publish
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'warns about skipped publish steps' do
|
57
|
+
expect($logger).to receive(:warn).with(/skipped/)
|
58
|
+
environment.publish
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'warns about skipped clean_up steps' do
|
62
|
+
expect($logger).to receive(:warn).with(/skipped/)
|
63
|
+
environment.clean_up
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'warns about skipped stop steps' do
|
67
|
+
expect($logger).to receive(:warn).with(/skipped/)
|
68
|
+
environment.stop
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'informs about skipped ensure steps' do
|
72
|
+
expect($logger).to receive(:info).with(/skipped/)
|
73
|
+
environment.ensure
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,63 @@
|
|
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 'pi_customizer/build/environment/vagrant/vagrant_file'
|
23
|
+
require 'pi_customizer/build/workspace/local_workspace'
|
24
|
+
require 'fileutils'
|
25
|
+
require 'pathname'
|
26
|
+
|
27
|
+
module PiCustomizer
|
28
|
+
|
29
|
+
RSpec.describe Environment::VagrantFileRenderer do
|
30
|
+
|
31
|
+
let(:tmp_dir) {'tmp_vagrant_file'}
|
32
|
+
let(:vagrant_file) {Environment::VagrantFile.new(Workspace::LocalWorkspace.new('', tmp_dir, ''), nil)}
|
33
|
+
let(:vagrant_file_builder) {Environment::VagrantFileRenderer.new(vagrant_file)}
|
34
|
+
let(:test_vagrant_file) {File.dirname(__FILE__) + '/../../../fixtures/TestVagrantfile'}
|
35
|
+
|
36
|
+
after(:each) do
|
37
|
+
#FileUtils.rm_rf tmp_dir
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'renders a Vagrantfile in the given temporary directory' do
|
41
|
+
vagrant_file_builder.create_from_template
|
42
|
+
expect(Pathname.new(tmp_dir+'/Vagrantfile')).to be_file
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'renders a Vagrantfile which copies a gem to the vagrant box when the modifier_gem_path is given' do
|
46
|
+
#Given
|
47
|
+
gem_name = 'my_gem.gem'
|
48
|
+
v_file = Environment::VagrantFile.new(Workspace::LocalWorkspace.new('', tmp_dir, gem_name), nil)
|
49
|
+
v_file_builder = Environment::VagrantFileRenderer.new(v_file)
|
50
|
+
#When
|
51
|
+
v_file_builder.create_from_template
|
52
|
+
#Then
|
53
|
+
expect(File.read(tmp_dir+'/Vagrantfile').to_s).to match(/config.vm.provision 'file', source: [-a-zA-Z0-9'\/_]+#{gem_name}/)
|
54
|
+
#expect(File.read(tmp_dir+'/Vagrantfile').to_s).to eq File.read(test_vagrant_file).to_s
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'raises an error if the Vagrantfile.erb does not exist' do
|
58
|
+
vagrant_file.vagrant_template_path = 'some/random/path'
|
59
|
+
expect {vagrant_file_builder.create_from_template}.to raise_error("'Vagrantfile.erb' template not specified. Expected template in path 'some/random/path'")
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|