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 +4 -4
- data/config/imagemaster3000.yml +3 -1
- data/lib/imagemaster3000/cli.rb +7 -3
- data/lib/imagemaster3000/definitions/downloader.rb +6 -13
- data/lib/imagemaster3000/entities/definitions.rb +27 -0
- data/lib/imagemaster3000/entities.rb +1 -0
- data/lib/imagemaster3000/main_process.rb +3 -4
- data/lib/imagemaster3000/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aca6a562b884c32fe727aea3f82fd5d4ff370524
|
4
|
+
data.tar.gz: 2f95e621cee42e6cfa9886672173dd4bf85fe18a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 882f848abfc0e3a7dc4194e90ccab8149f04902e87ed64d1405ca66f46ed6350262d36369f89500d9ac7e531f6a09eca20fb5ca2e86e7c72832a35f8ac67de93
|
7
|
+
data.tar.gz: cce26a9e491ad3067d5cec5a7ac20187ad51d0895a2c75e3f3dc967e4df1327fef8b079e285cdbf2a9fb1193834341c16d06087f0a8b8e9b7660d461c14f32ae
|
data/config/imagemaster3000.yml
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
imagemaster3000:
|
2
|
-
definitions
|
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
|
data/lib/imagemaster3000/cli.rb
CHANGED
@@ -17,11 +17,15 @@ module Imagemaster3000
|
|
17
17
|
type: :boolean,
|
18
18
|
desc: 'Runs in debug mode'
|
19
19
|
|
20
|
-
method_option :'definitions-
|
21
|
-
default: Imagemaster3000::Settings['definitions
|
20
|
+
method_option :'definitions-repository',
|
21
|
+
default: Imagemaster3000::Settings['definitions']['repository'],
|
22
22
|
type: :string,
|
23
23
|
required: true,
|
24
|
-
desc: '
|
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
|
8
|
-
|
9
|
-
logger.debug "Downloading definitions repository #{
|
10
|
-
|
11
|
-
|
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
|
@@ -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
|
-
|
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
|
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
|
+
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-
|
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
|