sle2docker 0.1.4 → 0.2.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: e55c98b03880649eebf4e52e7c6d42ef78f021f5
4
- data.tar.gz: 8b6e1ff04152fa335cec4630fc968e2e3cfcb762
3
+ metadata.gz: 3ba4bc4ef832b69bf18ec9d3ba0fd0b5518ae3d6
4
+ data.tar.gz: 712d2fb95e42161a359a2eb0286f2922f22ae054
5
5
  SHA512:
6
- metadata.gz: bc35d46a8497871fee7aaef46b06a06a748cc39dd027065b74b8721d47e39685f1e48d5f3f993220d124da89bd24399778c8a494e15e8d18160cfa50384b7427
7
- data.tar.gz: 8e77d6ab0d8ca19f5893bbbdd190091a2f5c9cf8b5974ec4002fa0623f2ee7213ea8f104f95d08e76ac0fb2b09a53b4aebbcd429b249e5af9882b829fc42c352
6
+ metadata.gz: adf5fa4931a457bcfd3e2d284ed61632f5289fd7a97940b1e9bf68bf21a31773e5b903727ad242374777ffd4053cd221117284d5fdf189647e0de2919cd8d10a
7
+ data.tar.gz: e4ccfa007af3e0c836261cd659a7f1a92c1a32de21b792990978d06c539ec0c89c183f870927e320722b1f84f5009f1bcc0559d11c05b7f82996d7edb457fd4a
data/Changelog CHANGED
@@ -1,3 +1,9 @@
1
+ Wed Sep 10 22:04:10 CEST 2014 Flavio Castelli <flavio@castelli.name>
2
+
3
+ * Version 0.2.0:
4
+ - Handle cli switches using the Thor
5
+ - Syntax changed
6
+
1
7
  Tue Sep 09 15:42:26 CEST 2014 Flavio Castelli <fcastelli@suse.com>
2
8
 
3
9
  * Version 0.1.4: minor fixes to gemspec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org/'
2
+
3
+ # Specify your gem's dependencies in dister.gemspec
4
+ gemspec
data/README.md CHANGED
@@ -62,13 +62,20 @@ system.
62
62
  To build a template just use the following command:
63
63
 
64
64
  ```
65
- sle2docker <template name>
65
+ sle2docker build TEMPLATE
66
66
  ```
67
67
 
68
68
  A list of the available templates can be obtained by running:
69
69
 
70
70
  ```
71
- sle2docker -l
71
+ sle2docker list
72
+ ```
73
+
74
+ A templated rendered with user provided data can be printed by using the
75
+ following command:
76
+
77
+ ```
78
+ sle2docker show TEMPLATE
72
79
  ```
73
80
 
74
81
  ## SUSE Customer Center integration
@@ -79,7 +86,7 @@ his credentials. It is possible to start a build in a non interactive way by
79
86
  using the following command:
80
87
 
81
88
  ```
82
- sle2docker -u USERNAME -p PASSWORD TEMPLATE_NAME
89
+ sle2docker build -u USERNAME -p PASSWORD TEMPLATE_NAME
83
90
  ```
84
91
 
85
92
 
@@ -89,7 +96,7 @@ It is possible to download all the reuiqred packages from a local
89
96
  Subscription Management Tool (SMT) instance:
90
97
 
91
98
  ```
92
- sle2docker -s SMT_SERVER_HOSTNAME TEMPLATE_NAME
99
+ sle2docker build -s SMT_SERVER_HOSTNAME TEMPLATE
93
100
  ```
94
101
 
95
102
  By default sle2docker assumes the contents of the SMT server are served over
@@ -97,7 +104,7 @@ HTTPS. To force the retrieval of the package over plain HTTP use the
97
104
  following command:
98
105
 
99
106
  ```
100
- sle2docker -s SMT_SERVER_HOSTNAME --disable-https TEMPLATE_NAME
107
+ sle2docker build -s SMT_SERVER_HOSTNAME --disable-https TEMPLATE
101
108
  ```
102
109
 
103
110
  By default sle2docker expects the SMT instance to not require any form of
@@ -105,7 +112,7 @@ authentication. However it is possible to specify the access credentials by
105
112
  using the following command:
106
113
 
107
114
  ```
108
- sle2docker -s SMT_SERVER_HOSTNAME -u USERNAME -p PASSWORD TEMPLATE_NAME
115
+ sle2docker build -s SMT_SERVER_HOSTNAME -u USERNAME -p PASSWORD TEMPLATE
109
116
  ```
110
117
 
111
118
 
data/bin/sle2docker CHANGED
@@ -1,9 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  require_relative '../lib/sle2docker'
3
3
 
4
- container = Sle2Docker::Cli.new.start()
5
- puts "Container created, it can be imported by running the following command:"
6
- puts " docker import - <desired image name> < #{container}"
7
- puts "\nThen the '#{File.expand_path(File.join(File.dirname(container), '..'))}' directory and all its contents can be removed."
8
- puts "Note well: KIWI created some of these files while running as root user, " +
9
- "hence root privileges are required to remove them."
4
+ Sle2Docker::Cli.start(ARGV)
5
+
data/lib/sle2docker.rb CHANGED
@@ -2,6 +2,7 @@ require 'erb'
2
2
  require 'fileutils'
3
3
  require 'io/console'
4
4
  require 'optparse'
5
+ require 'thor'
5
6
  require 'tmpdir'
6
7
 
7
8
  require_relative 'sle2docker/cli'
@@ -1,83 +1,96 @@
1
1
  module Sle2Docker
2
2
 
3
- class Cli
3
+ class Cli < Thor
4
+
5
+ #def initialize
6
+ # @options, @template_dir = parse_options()
7
+ #end
8
+
9
+ #def start
10
+ # builder = Builder.new(@options)
11
+ # builder.create(@template_dir)
12
+ #rescue ConfigNotFoundError => e
13
+ # $stderr.printf(e.message + "\n")
14
+ # exit(1)
15
+ #end
16
+
17
+ desc "list", "List the available templates"
18
+ def list
19
+ puts "Available templates:"
20
+ Template.list.each {|template| puts " - #{template}"}
21
+ end
4
22
 
5
- def initialize
6
- @options, @template_dir = parse_options()
23
+ map "-v" => :version
24
+ desc "version", "Display version"
25
+ def version
26
+ puts Sle2Docker::VERSION
7
27
  end
8
28
 
9
- def start
10
- builder = Builder.new(@options)
11
- builder.create(@template_dir)
29
+ desc "show TEMPLATE", "Print the rendered TEMPLATE"
30
+ method_option :username, :aliases => "-u", :type => :string,
31
+ :default => nil,
32
+ :desc => "Username required to access repositories"
33
+ method_option :password, :aliases => "-p", :type => :string,
34
+ :default => "",
35
+ :desc => "Password required to access repositories"
36
+ method_option :smt_host, :aliases => ["-s", "--smt-host"], :type => :string,
37
+ :default => nil,
38
+ :desc => "SMT machine hosting the repositories"
39
+ method_option :disable_https, :aliases => ["--disable-https"],
40
+ :type => :boolean,
41
+ :default => false,
42
+ :desc => "Do not use HTTPS when accessing repositories"
43
+ def show(template_name)
44
+ template_dir = Template.template_dir(template_name)
45
+ builder = Builder.new(options)
46
+ template_file = builder.find_template_file(template_dir)
47
+ if template_file.end_with?('.erb')
48
+ template = builder.render_template(template_file)
49
+ puts "\n\n"
50
+ puts template
51
+ end
12
52
  rescue ConfigNotFoundError => e
13
53
  $stderr.printf(e.message + "\n")
14
54
  exit(1)
55
+ rescue TemplateNotFoundError => ex
56
+ $stderr.printf(ex.message + "\n")
57
+ $stderr.printf("To list the available templates use:\n")
58
+ $stderr.printf(" sle2docker list\n")
59
+ exit(1)
15
60
  end
16
61
 
17
- private
18
-
19
- def parse_options()
20
- options = {}
21
-
22
- optparse = OptionParser.new do|opts|
23
- opts.banner = "Usage: sle2docker [options] TEMPLATE"
24
-
25
- options[:username] = nil
26
- opts.on('-u', '--username USERNAME',
27
- 'Username required to access repositories' ) do |u|
28
- options[:username] = u
29
- end
30
-
31
- options[:password] = ""
32
- opts.on('-p', '--password PASSWORD',
33
- 'Password required to access repositories' ) do |p|
34
- options[:password] = p
35
- end
36
-
37
- options[:smt_host] = nil
38
- opts.on('-s', '--smt-host SMT_HOST',
39
- 'SMT machine hosting the repositories' ) do |smt_host|
40
- options[:smt_host] = smt_host
41
- end
42
-
43
- options[:disable_https] = false
44
- opts.on('--disable-https',
45
- 'Do not use HTTPS when accessing repositories' ) do
46
- options[:disable_https] = true
47
- end
48
-
49
- opts.on('-l', '--list-templates', 'List the available templates' ) do
50
- puts "Available templates:"
51
- Template.list.each {|template| puts " - #{template}"}
52
- exit
53
- end
54
-
55
-
56
- opts.on('-h', '--help', 'Display this screen' ) do
57
- puts opts
58
- exit
59
- end
60
-
61
- opts.on('-v', '--version', 'Display version' ) do
62
- puts Sle2Docker::VERSION
63
- exit
64
- end
65
-
66
- end
67
-
68
- optparse.parse!
69
-
70
- if ARGV.count != 1
71
- $stderr.printf("Template not provided\n")
72
- exit(1)
73
- end
74
-
75
- [options, Template.template_dir(ARGV[0])]
62
+ desc "build TEMPLATE", "Use TEMPLATE to build a SLE Docker image"
63
+ method_option :username, :aliases => "-u", :type => :string,
64
+ :default => nil,
65
+ :desc => "Username required to access repositories"
66
+ method_option :password, :aliases => "-p", :type => :string,
67
+ :default => "",
68
+ :desc => "Password required to access repositories"
69
+ method_option :smt_host, :aliases => ["-s", "--smt-host"], :type => :string,
70
+ :default => nil,
71
+ :desc => "SMT machine hosting the repositories"
72
+ method_option :disable_https, :aliases => ["--disable-https"],
73
+ :type => :boolean,
74
+ :default => false,
75
+ :desc => "Do not use HTTPS when accessing repositories"
76
+ def build(template_name)
77
+ template_dir = Template.template_dir(template_name)
78
+ builder = Builder.new(options)
79
+ container = builder.create(template_dir)
80
+ puts "Container created, it can be imported by running the following command:"
81
+ puts " docker import - <desired image name> < #{container}"
82
+ puts "\nThen the '#{File.expand_path(File.join(File.dirname(container), '..'))}' directory and all its contents can be removed."
83
+ puts "Note well: KIWI created some of these files while running as root user, " +
84
+ "hence root privileges are required to remove them."
85
+ rescue ConfigNotFoundError => e
86
+ $stderr.printf(e.message + "\n")
87
+ exit(1)
76
88
  rescue TemplateNotFoundError => ex
77
89
  $stderr.printf(ex.message + "\n")
78
90
  $stderr.printf("To list the available templates use:\n")
79
- $stderr.printf(" sle2docker -l\n")
91
+ $stderr.printf(" sle2docker list\n")
80
92
  exit(1)
81
93
  end
94
+
82
95
  end
83
96
  end
@@ -1,5 +1,5 @@
1
1
  module Sle2Docker
2
2
 
3
- VERSION = "0.1.4"
3
+ VERSION = "0.2.0"
4
4
 
5
5
  end
data/sle2docker.gemspec CHANGED
@@ -25,6 +25,7 @@ EOD
25
25
  s.required_rubygems_version = ">= 1.3.6"
26
26
  s.rubyforge_project = "sle2docker"
27
27
 
28
+ s.add_runtime_dependency "thor"
28
29
  s.add_development_dependency "bundler"
29
30
  s.add_development_dependency "yard"
30
31
  s.files = `git ls-files`.split("\n")
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sle2docker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flavio Castelli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-09 00:00:00.000000000 Z
11
+ date: 2014-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -55,6 +69,7 @@ extra_rdoc_files: []
55
69
  files:
56
70
  - .gitignore
57
71
  - Changelog
72
+ - Gemfile
58
73
  - LICENSE
59
74
  - README.md
60
75
  - Rakefile