imagemaster3000 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 996e77fb0c4428397770762578ac29cdc1dae5a3
4
- data.tar.gz: 7f2951d4136f4131e02b69040054accdf66654f7
3
+ metadata.gz: aca6a562b884c32fe727aea3f82fd5d4ff370524
4
+ data.tar.gz: 2f95e621cee42e6cfa9886672173dd4bf85fe18a
5
5
  SHA512:
6
- metadata.gz: 66df3e15cfba256c630f5504341a369ae04df60878a2acf5af4a7407bcf16e1f3fc46ad830a768eaf680b6d6b7eef49e0818d43290fcc778e137037f4fd15042
7
- data.tar.gz: ecdad85ef7c738b2377f012f3d4dd59cb8aadd106a7e140b2fa9e6bb0c84ef7b76531c6bd51f82bb6c04269175819ec1a97c8bf001c65993e79cae14ed140e4b
6
+ metadata.gz: 882f848abfc0e3a7dc4194e90ccab8149f04902e87ed64d1405ca66f46ed6350262d36369f89500d9ac7e531f6a09eca20fb5ca2e86e7c72832a35f8ac67de93
7
+ data.tar.gz: cce26a9e491ad3067d5cec5a7ac20187ad51d0895a2c75e3f3dc967e4df1327fef8b079e285cdbf2a9fb1193834341c16d06087f0a8b8e9b7660d461c14f32ae
@@ -1,5 +1,7 @@
1
1
  imagemaster3000:
2
- definitions-git-repo: # Definitions in this git repository are used to download and modify images
2
+ definitions:
3
+ repository: # Repository from which image definitions will be downloaded
4
+ branch: # Repository branch that will be used
3
5
  image-dir: /var/spool/imagemaster3000/ # Directory where to temporarily store images
4
6
  image-list: /var/spool/imagemaster3000/imagemaster3000.list # Name and path of generated image list
5
7
  endpoint: http://localhost/ # Endpoint where image list will be available
@@ -17,11 +17,15 @@ module Imagemaster3000
17
17
  type: :boolean,
18
18
  desc: 'Runs in debug mode'
19
19
 
20
- method_option :'definitions-git-repo',
21
- default: Imagemaster3000::Settings['definitions-git-repo'],
20
+ method_option :'definitions-repository',
21
+ default: Imagemaster3000::Settings['definitions']['repository'],
22
22
  type: :string,
23
23
  required: true,
24
- desc: 'Definitions in this git repository are used to download and modify images'
24
+ desc: 'Repository from which image definitions will be downloaded'
25
+ method_option :'definitions-branch',
26
+ default: Imagemaster3000::Settings['definitions']['branch'],
27
+ type: :string,
28
+ desc: 'Repository branch that will be used'
25
29
  method_option :'image-dir',
26
30
  default: Imagemaster3000::Settings['image-dir'],
27
31
  type: :string,
@@ -4,19 +4,12 @@ require 'tmpdir'
4
4
  module Imagemaster3000
5
5
  module Definitions
6
6
  class Downloader
7
- def initialize(git_repository)
8
- @dir = Dir.mktmpdir 'imagemaster3000-'
9
- logger.debug "Downloading definitions repository #{git_repository}"
10
- @git = Git.clone(git_repository, 'definitions', path: @dir)
11
- end
12
-
13
- def path
14
- @git.dir.path
15
- end
16
-
17
- def clean
18
- logger.debug "Cleaning definitions #{@dir}"
19
- FileUtils.remove_entry @dir
7
+ def self.download_definitions
8
+ tmp_dir = Dir.mktmpdir 'imagemaster3000-'
9
+ logger.debug "Downloading definitions repository #{Imagemaster3000::Settings['definitions-repository']}"
10
+ Imagemaster3000::Entities::Definitions.new(Git.clone(Imagemaster3000::Settings['definitions-repository'],
11
+ File.basename(tmp_dir),
12
+ path: File.dirname(tmp_dir)))
20
13
  end
21
14
  end
22
15
  end
@@ -0,0 +1,27 @@
1
+ module Imagemaster3000
2
+ module Entities
3
+ class Definitions
4
+ def initialize(repository)
5
+ @repository = repository
6
+
7
+ self.branch = Imagemaster3000::Settings['definitions-branch'] if Imagemaster3000::Settings['definitions-branch']
8
+ end
9
+
10
+ def path
11
+ @repository.dir.path
12
+ end
13
+
14
+ def branch=(branch)
15
+ raise Imagemaster3000::Errors::ArgumentError, "no such branch #{branch.inspect}" unless @repository.is_branch? branch
16
+
17
+ logger.debug "Changing branch to #{branch}"
18
+ @repository.checkout branch
19
+ end
20
+
21
+ def clean
22
+ logger.debug "Cleaning definitions #{@directory}"
23
+ FileUtils.remove_entry path
24
+ end
25
+ end
26
+ end
27
+ end
@@ -2,5 +2,6 @@ module Imagemaster3000
2
2
  module Entities
3
3
  autoload :Image, 'imagemaster3000/entities/image'
4
4
  autoload :Downloadable, 'imagemaster3000/entities/downloadable'
5
+ autoload :Definitions, 'imagemaster3000/entities/definitions'
5
6
  end
6
7
  end
@@ -9,15 +9,14 @@ module Imagemaster3000
9
9
  generate_image_list
10
10
  Imagemaster3000::Cleaner.clean
11
11
  ensure
12
- Imagemaster3000::Cleaner.write_clean_file images.map(&:local_filename)
13
- definitions.clean
12
+ Imagemaster3000::Cleaner.write_clean_file images.map(&:local_filename) if images
13
+ definitions.clean if definitions
14
14
  end
15
15
 
16
16
  private
17
17
 
18
18
  def process_definitions
19
- logger.debug "Download definitions from #{Imagemaster3000::Settings['definitions-git-repo'].inspect}"
20
- @definitions = Imagemaster3000::Definitions::Downloader.new Imagemaster3000::Settings['definitions-git-repo']
19
+ @definitions = Imagemaster3000::Definitions::Downloader.download_definitions
21
20
  Imagemaster3000::Settings['definitions-dir'] = definitions.path
22
21
  logger.debug 'Loading images from definitions'
23
22
  @images = Imagemaster3000::Definitions::Parser.parse_image_definitions
@@ -1,3 +1,3 @@
1
1
  module Imagemaster3000
2
- VERSION = '0.4.2'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imagemaster3000
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Kimle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-14 00:00:00.000000000 Z
11
+ date: 2017-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -301,6 +301,7 @@ files:
301
301
  - lib/imagemaster3000/definitions/parser.rb
302
302
  - lib/imagemaster3000/definitions/schemas/imagemaster3000-definition-schema.json
303
303
  - lib/imagemaster3000/entities.rb
304
+ - lib/imagemaster3000/entities/definitions.rb
304
305
  - lib/imagemaster3000/entities/downloadable.rb
305
306
  - lib/imagemaster3000/entities/image.rb
306
307
  - lib/imagemaster3000/errors.rb