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.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +24 -0
  3. data/.travis.yml +28 -0
  4. data/CODE_OF_CONDUCT.md +74 -0
  5. data/LICENSE +1 -1
  6. data/README.md +208 -2
  7. data/Rakefile +134 -6
  8. data/Vagrantfile +13 -2
  9. data/docs/concept.md +27 -0
  10. data/docs/incubation.md +38 -0
  11. data/pi_build_modifier/.gitignore +12 -0
  12. data/{.rspec → pi_build_modifier/.rspec} +0 -0
  13. data/pi_build_modifier/Gemfile +6 -0
  14. data/pi_build_modifier/LICENSE.txt +21 -0
  15. data/pi_build_modifier/README.md +3 -0
  16. data/pi_build_modifier/Rakefile +13 -0
  17. data/pi_build_modifier/bin/pi_build_modifier +25 -0
  18. data/pi_build_modifier/lib/pi_build_modifier.rb +53 -0
  19. data/pi_build_modifier/lib/pi_build_modifier/boot-files/boot.rb +64 -0
  20. data/pi_build_modifier/lib/pi_build_modifier/boot-files/templates/07-resize-init.diff.erb +5 -0
  21. data/pi_build_modifier/lib/pi_build_modifier/config/logex.rb +25 -0
  22. data/pi_build_modifier/lib/pi_build_modifier/locale/locale_debconf.rb +66 -0
  23. data/pi_build_modifier/lib/pi_build_modifier/locale/templates/00-debconf.erb +6 -0
  24. data/pi_build_modifier/lib/pi_build_modifier/modifier/erb_mapper.rb +72 -0
  25. data/pi_build_modifier/lib/pi_build_modifier/modifier/mapper.rb +49 -0
  26. data/pi_build_modifier/lib/pi_build_modifier/modifier/pi_modifier.rb +81 -0
  27. data/pi_build_modifier/lib/pi_build_modifier/modifier_task.rb +79 -0
  28. data/pi_build_modifier/lib/pi_build_modifier/net-tweaks/templates/wpa_supplicant.conf.erb +5 -0
  29. data/pi_build_modifier/lib/pi_build_modifier/net-tweaks/wifi_network.rb +124 -0
  30. data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/run_modifier.rb +63 -0
  31. data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/ssh.rb +61 -0
  32. data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/templates/ssh.sh.erb +8 -0
  33. data/pi_build_modifier/lib/pi_build_modifier/system/system_type.rb +84 -0
  34. data/pi_build_modifier/lib/pi_build_modifier/version.rb +23 -0
  35. data/pi_build_modifier/pi_build_modifier.gemspec +32 -0
  36. data/pi_build_modifier/spec/fixtures/config.json +26 -0
  37. data/pi_build_modifier/spec/pi_build_modifier/boot/boot_spec.rb +103 -0
  38. data/pi_build_modifier/spec/pi_build_modifier/locale/locale_spec.rb +87 -0
  39. data/pi_build_modifier/spec/pi_build_modifier/modifier/mapper_spec.rb +105 -0
  40. data/pi_build_modifier/spec/pi_build_modifier/modifier/modifier_spec.rb +83 -0
  41. data/pi_build_modifier/spec/pi_build_modifier/modifier_task_spec.rb +63 -0
  42. data/pi_build_modifier/spec/pi_build_modifier/net-tweaks/wifi_network_spec.rb +91 -0
  43. data/pi_build_modifier/spec/pi_build_modifier/sys_tweaks/run_modifier_spec.rb +74 -0
  44. data/pi_build_modifier/spec/pi_build_modifier/sys_tweaks/ssh_spec.rb +73 -0
  45. data/pi_build_modifier/spec/pi_build_modifier/system/system_spec.rb +66 -0
  46. data/pi_build_modifier/spec/pi_build_modifier_spec.rb +73 -0
  47. data/pi_build_modifier/spec/spec_helper.rb +10 -0
  48. data/pi_customizer/.rspec +2 -0
  49. data/{Gemfile → pi_customizer/Gemfile} +0 -0
  50. data/pi_customizer/LICENSE +21 -0
  51. data/pi_customizer/README.md +3 -0
  52. data/pi_customizer/Rakefile +13 -0
  53. data/pi_customizer/Vagrantfile +16 -0
  54. data/{bin → pi_customizer/bin}/pi_customizer +1 -1
  55. data/{envs → pi_customizer/envs}/aws/outputs.tf +0 -0
  56. data/{envs → pi_customizer/envs}/aws/pi-build-env.tf +0 -0
  57. data/{envs → pi_customizer/envs}/aws/variables.tf +0 -0
  58. data/{envs → pi_customizer/envs}/docker/Dockerfile +0 -0
  59. data/{envs → pi_customizer/envs}/sh/build-pi-img.sh +0 -0
  60. data/{lib → pi_customizer/lib}/pi_customizer.rb +7 -6
  61. data/{lib → pi_customizer/lib}/pi_customizer/build/builder/build_executor.rb +31 -2
  62. data/{lib → pi_customizer/lib}/pi_customizer/build/builder/builder.rb +4 -2
  63. data/{lib → pi_customizer/lib}/pi_customizer/build/builder/prepare_start_execute_builder.rb +1 -1
  64. data/{lib → pi_customizer/lib}/pi_customizer/build/builder/start_prepare_execute_builder.rb +1 -1
  65. data/{lib → pi_customizer/lib}/pi_customizer/build/environment/aws/aws.rb +1 -1
  66. data/{lib → pi_customizer/lib}/pi_customizer/build/environment/docker/docker.rb +1 -1
  67. data/{lib → pi_customizer/lib}/pi_customizer/build/environment/environment.rb +1 -1
  68. data/{lib → pi_customizer/lib}/pi_customizer/build/environment/environment_builder_factory.rb +9 -3
  69. data/{lib → pi_customizer/lib}/pi_customizer/build/environment/vagrant/templates/Vagrantfile.erb +3 -7
  70. data/{lib → pi_customizer/lib}/pi_customizer/build/environment/vagrant/vagrant.rb +1 -1
  71. data/{lib → pi_customizer/lib}/pi_customizer/build/environment/vagrant/vagrant_file.rb +2 -2
  72. data/{lib → pi_customizer/lib}/pi_customizer/build/workspace/local_workspace.rb +1 -1
  73. data/{lib → pi_customizer/lib}/pi_customizer/build/workspace/remote_workspace.rb +14 -4
  74. data/{lib → pi_customizer/lib}/pi_customizer/utils/logex.rb +1 -1
  75. data/{lib → pi_customizer/lib}/pi_customizer/version.rb +2 -2
  76. data/{lib → pi_customizer/lib}/pi_customizer/write/image_writer.rb +1 -1
  77. data/{pi_customizer.gemspec → pi_customizer/pi_customizer.gemspec} +5 -5
  78. data/pi_customizer/spec/fixtures/TestVagrantfile +61 -0
  79. data/pi_customizer/spec/fixtures/image.img +1 -0
  80. data/pi_customizer/spec/fixtures/image.zip +0 -0
  81. data/pi_customizer/spec/pi_customizer/builder/build_executor_spec.rb +64 -0
  82. data/pi_customizer/spec/pi_customizer/environment/aws_spec.rb +57 -0
  83. data/pi_customizer/spec/pi_customizer/environment/environment_builder_factory_spec.rb +48 -0
  84. data/pi_customizer/spec/pi_customizer/environment/environment_spec.rb +75 -0
  85. data/pi_customizer/spec/pi_customizer/environment/vagrant/vagrant_file_spec.rb +63 -0
  86. data/pi_customizer/spec/pi_customizer/environment/vagrant/vagrant_spec.rb +41 -0
  87. data/pi_customizer/spec/pi_customizer/version_spec.rb +29 -0
  88. data/pi_customizer/spec/pi_customizer/workspace/local_workspace_spec.rb +74 -0
  89. data/pi_customizer/spec/pi_customizer/workspace/remote_workspace_spec.rb +51 -0
  90. data/pi_customizer/spec/pi_customizer/write/image_writer_spec.rb +59 -0
  91. data/pi_customizer/spec/pi_customizer_spec.rb +93 -0
  92. data/pi_customizer/spec/spec_helper.rb +10 -0
  93. data/version.rb +21 -0
  94. metadata +102 -41
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2017-2018 Beate Ottenwälder
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
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2017-2018 Beate Ottenwälder
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-2018 Beate Ottenwälder
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
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2017-2018 Beate Ottenwälder
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.0-alpha'
26
+ VERSION = '0.3.1.pre.alpha'
27
27
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2017-2018 Beate Ottenwälder
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
@@ -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', '~> 1.15'
25
- spec.add_development_dependency 'rake', '~> 10.0'
26
- spec.add_development_dependency 'rspec', '~> 3.0'
27
- spec.add_development_dependency 'simplecov', '~> 0.15'
28
- spec.add_development_dependency 'rdoc', '~> 5.1'
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
@@ -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