gordon 0.0.13 → 0.0.14

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: e387d6a84bd0ece96fcb121d5cced6827ef009e1
4
- data.tar.gz: e097dc48d7ba2bb4ec8ff51c99acd01fc293a8ab
3
+ metadata.gz: f96bc9082e1fa53d17474c0ad13eaf2b4724a487
4
+ data.tar.gz: c3bab3732ee745e380e937da11c8018200a706c4
5
5
  SHA512:
6
- metadata.gz: 8bc452a000d48d86f71432d503576078e81bc4fb3e565921265ff6b9b52bbadc438a231a95c3284fab283d565b1b6271448eeac08a6c17661246d91887bffb37
7
- data.tar.gz: 020661459f394a86c7ba8ab9ea701407c8ac774088ee2a254c70a1abc382cbda843e9c5179eff7e3b2e74740c108109945cd40ff6907dd83bd7aff8b934a5360
6
+ metadata.gz: 7e58da1e400b4cfec597b3203f7f9d19dc7dc865a071708af7f07e8b334a2aca3da44fe1f253d1cb2838ca5bfa6fec88f0f23afd0a4d7bed6f1c83515ee9cfb3
7
+ data.tar.gz: e8d17b489e533aa2638b9c360c10eea86c9f272ad605c91e65fa0afb0dd72bab0367b919716488ba7825645d16464e5a60f742df4504fefab5b297fc11771a3b
data/README.md CHANGED
@@ -30,9 +30,9 @@ Per example: create a user that will run app with credentials, whose $HOME is th
30
30
 
31
31
  * Apps supported:
32
32
 
33
- * Ruby Web App (resides based on Http Server of choice)
34
- * Ruby Standalone App (resides on /opt/*app_name*)
35
- * Java Web App (resides based on Web Server of choice)
33
+ * Ruby Web (resides based on Http Server of choice)
34
+ * Ruby Standalone (resides on /opt/*app_name*)
35
+ * Java Web (resides based on Web Server of choice)
36
36
 
37
37
  ## Installation
38
38
 
@@ -59,12 +59,13 @@ First, you need to vendorize all gems in deployment mode:
59
59
  Here a simple example to build a Ruby Web App that runs Nginx and uses Systemd as init process. Just enter on source folder of your app and run in your terminal:
60
60
 
61
61
  $ ruby -S gordon \
62
- --app-type ruby_web_app \
62
+ --app-type web \
63
63
  --app-name $APP_NAME \
64
64
  --app-desc $APP_DESC \
65
65
  --app-home $APP_HOME \
66
66
  --app-version $APP_VERSION \
67
67
  --app-source . \
68
+ --runtime-name ruby \
68
69
  --runtime-version $MRI_VERSION \
69
70
  --http-server-type nginx \
70
71
  --init-type systemd \
@@ -83,6 +84,15 @@ Due for conventions, remember:
83
84
 
84
85
  Sounds good?
85
86
 
87
+ ## And for Java Web applications?
88
+
89
+ First, generate war files. After, do the following steps:
90
+
91
+ * Set --app-source with the path of war file;
92
+ * Set --runtime-name to java-oracle (only for CentOS platform at this time) or java-openjdk;
93
+ * Set --runtime-version (1.7.0_60, 1.8.0_31; Gordon checks and inject correct version into package metadata).
94
+ * You can avoid --init-type because war files are handled by application server of choice (Tomcat or Jetty).
95
+
86
96
  ## Why you not use Omnibus or Heroku buildpacks?
87
97
 
88
98
  Because I want a tool able to create Linux packages that can be extensible based on my needs.
@@ -91,15 +101,18 @@ Because I want a tool able to create Linux packages that can be extensible based
91
101
 
92
102
  Because I not found a trivial way to use fpm when you need to package a application under different directories (Apache2 and Systemd per example). If you show to me, I will think to abolish templates.
93
103
 
104
+ ## Why you can't handle all recipes into a single one and abstract build and install?
105
+
106
+ Because I need to call some protected methods on FPM::Cookery::Recipe and adding dynamic mixins will be a nightmare due for complexity to maintain.
107
+
94
108
  ## Why Gordon?
95
109
 
96
110
  Because I like Gordon Ramsay.
97
111
 
98
112
  ## TODO
99
113
 
114
+ * Add Oracle JRE support for Debian (oracle-jre-installer?)
100
115
  * Validate outputs
101
- * Refactor to have only one FPM::Cookery recipe.
102
- * Integrate directly with FPM::Cookery classes
103
116
  * Debian check (gem heavly developed under CentOS environment)
104
117
 
105
118
  ## Contributing
@@ -1,9 +1,13 @@
1
1
  module Gordon
2
2
  module Application
3
3
  class Factory
4
- def self.create(application_type)
4
+ def self.create(options)
5
5
  namespace = "Application::Types"
6
6
 
7
+ runtime_name = options.runtime_name
8
+ runtime_name = :java if runtime_name =~ /java/
9
+ application_type = "#{runtime_name}_#{options.app_type}_app"
10
+
7
11
  ::Gordon::Factory.create_instance(namespace, application_type)
8
12
  end
9
13
  end
@@ -21,10 +21,10 @@ class JavaWebApp < FPM::Cookery::Recipe
21
21
 
22
22
  source $env_vars.app_source, with: :local_path
23
23
 
24
- depends *resolve_dependencies($env_vars)
24
+ depends *resolve_dependencies($env_vars, platform)
25
25
 
26
- fpm_attributes[:rpm_user] = 'tomcat'
27
- fpm_attributes[:rpm_group] = 'tomcat'
26
+ fpm_attributes["#{FPM::Cookery::Facts.target}_user".to_sym] = 'tomcat'
27
+ fpm_attributes["#{FPM::Cookery::Facts.target}_group".to_sym] = 'tomcat'
28
28
 
29
29
  def build
30
30
  web_server_path = get_skeleton_path_from_type($env_vars, $env_vars.web_server_type)
@@ -21,7 +21,7 @@ class RubyStandaloneApp < FPM::Cookery::Recipe
21
21
 
22
22
  source $env_vars.app_source, with: :local_path
23
23
 
24
- depends *resolve_dependencies($env_vars)
24
+ depends *resolve_dependencies($env_vars, platform)
25
25
 
26
26
  def build
27
27
  home_path = get_skeleton_path_from_type($env_vars, :misc)
@@ -21,7 +21,7 @@ class RubyWebApp < FPM::Cookery::Recipe
21
21
 
22
22
  source $env_vars.app_source, with: :local_path
23
23
 
24
- depends *resolve_dependencies($env_vars)
24
+ depends *resolve_dependencies($env_vars, platform)
25
25
 
26
26
  def build
27
27
  home_path = get_skeleton_path_from_type($env_vars, $env_vars.http_server_type)
@@ -1,63 +1,70 @@
1
- require 'fpm/cookery/facts'
2
-
3
1
  module Gordon
4
2
  module Cookery
5
3
  module DependencyResolver
6
4
  include Common
7
5
 
8
- def resolve_dependencies(env_vars)
9
- fragments = env_vars.app_type.split('_')
10
- app_runtime, app_type = fragments[0], fragments[1]
11
-
6
+ def resolve_dependencies(env_vars, platform)
12
7
  dependencies = []
13
- dependencies << get_runtime_package_name(app_runtime, env_vars)
14
- dependencies << get_http_server_package_name(env_vars) unless env_vars.http_server_type.empty?
15
- dependencies << get_init_package_name(env_vars) unless env_vars.init_type.empty?
16
- dependencies << get_web_server_package_name(env_vars) unless env_vars.web_server_type.empty?
8
+
9
+ dependencies << get_runtime_package_name(env_vars, platform)
10
+ dependencies << get_http_server_package_name(env_vars, platform) unless env_vars.http_server_type.empty?
11
+ dependencies << get_init_package_name(env_vars, platform) unless env_vars.init_type.empty?
12
+ dependencies << get_web_server_package_name(env_vars, platform) unless env_vars.web_server_type.empty?
17
13
 
18
14
  dependencies.collect(&:to_s)
19
15
  end
20
16
 
21
17
  private
22
18
 
23
- def get_runtime_package_name(app_runtime, env_vars)
24
- if app_runtime == 'java'
25
- # TODO: get a way to handle openjdk
26
- runtime_name = :jre
19
+ def get_runtime_package_name(env_vars, platform)
20
+ runtime_name, runtime_version = env_vars.runtime_name, env_vars.runtime_version
27
21
 
28
- if damn_oracle_8_jre?(env_vars.runtime_version)
29
- runtime_version = "#{runtime_name}#{env_vars.runtime_version}"
22
+ if runtime_name =~ /java/
23
+ package_name = get_java_package_name(runtime_name, runtime_version, platform)
24
+ else
25
+ package_name = "#{runtime_name} = #{runtime_version}"
26
+ end
27
+
28
+ package_name
29
+ end
30
+
31
+ def get_java_package_name(runtime_name, runtime_version, platform)
32
+ centos = platform == :centos
33
+
34
+ if runtime_name =~ /oracle/ && centos
35
+ if damn_oracle_8_jre?(runtime_version)
36
+ package_name = "jre#{runtime_version}"
30
37
  else
31
- runtime_version = "#{runtime_name} = #{env_vars.runtime_version}"
38
+ package_name = "jre = #{runtime_version}"
32
39
  end
33
40
  else
34
- runtime_name = app_runtime
35
-
36
- runtime_version = "#{runtime_name} = #{env_vars.runtime_version}"
41
+ if centos
42
+ package_name = "java-#{runtime_version[0..4]}-openjdk"
43
+ else
44
+ package_name = "openjdk-#{runtime_version[2]}-jre"
45
+ end
37
46
  end
38
47
 
39
- runtime_version
48
+ package_name
40
49
  end
41
50
 
42
51
  def damn_oracle_8_jre?(runtime_version)
43
52
  runtime_version[2].to_s == '8'
44
53
  end
45
54
 
46
- def get_http_server_package_name(env_vars)
47
- get_os_package_name(env_vars, :http_server_type)
55
+ def get_http_server_package_name(env_vars, platform)
56
+ get_os_package_name(env_vars, :http_server_type, platform)
48
57
  end
49
58
 
50
- def get_init_package_name(env_vars)
51
- get_os_package_name(env_vars, :init_type)
59
+ def get_init_package_name(env_vars, platform)
60
+ get_os_package_name(env_vars, :init_type, platform)
52
61
  end
53
62
 
54
- def get_web_server_package_name(env_vars)
55
- get_os_package_name(env_vars, :web_server_type)
63
+ def get_web_server_package_name(env_vars, platform)
64
+ get_os_package_name(env_vars, :web_server_type, platform)
56
65
  end
57
66
 
58
- def get_os_package_name(env_vars, attribute)
59
- platform = FPM::Cookery::Facts.platform.to_sym
60
-
67
+ def get_os_package_name(env_vars, attribute, platform)
61
68
  skeleton_type = create_skeleton_type(env_vars.send(attribute))
62
69
  os_package_name = skeleton_type.get_os_package_name(platform)
63
70
 
data/lib/gordon/recipe.rb CHANGED
@@ -4,20 +4,7 @@ module Gordon
4
4
 
5
5
  def initialize(options)
6
6
  @options = options
7
- @application = Application::Factory.create(options.app_type)
8
- end
9
-
10
- def platform
11
- map = {
12
- rpm: :centos,
13
- deb: :debian,
14
- }
15
-
16
- map[options.package_type.to_sym]
17
- end
18
-
19
- def requires_platform?
20
- !!platform
7
+ @application = Application::Factory.create(options)
21
8
  end
22
9
 
23
10
  def application_template_path
@@ -1,3 +1,3 @@
1
1
  module Gordon
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gordon::Application::Factory do
4
+ let(:options) { instance_double Gordon::Options, app_type: :web, runtime_name: :java }
5
+
6
+ it 'returns a instance of specified runtime and type' do
7
+ expect(described_class.create(options)).to be_instance_of(Gordon::Application::Types::JavaWebApp)
8
+ end
9
+ end
10
+
@@ -12,7 +12,7 @@ describe Gordon::Cookery::DependencyResolver do
12
12
  describe 'resolving dependencies' do
13
13
  context 'given a ruby app' do
14
14
  it 'returns all dependencies for web' do
15
- expect(env_vars).to receive(:app_type).and_return("ruby_web_app")
15
+ expect(env_vars).to receive(:runtime_name).and_return("ruby")
16
16
  expect(env_vars).to receive(:runtime_version).and_return("2.2.0")
17
17
  allow(env_vars).to receive(:http_server_type).and_return("apache")
18
18
  expect(env_vars).to receive(:web_server_type).and_return("")
@@ -24,11 +24,11 @@ describe Gordon::Cookery::DependencyResolver do
24
24
  "systemd",
25
25
  ]
26
26
 
27
- expect(subject.resolve_dependencies(env_vars)).to eq(expected)
27
+ expect(subject.resolve_dependencies(env_vars, :centos)).to eq(expected)
28
28
  end
29
29
 
30
30
  it 'returns all dependencies for standalone' do
31
- expect(env_vars).to receive(:app_type).and_return("ruby_standalone_app")
31
+ expect(env_vars).to receive(:runtime_name).and_return("ruby")
32
32
  expect(env_vars).to receive(:runtime_version).and_return("2.1.5")
33
33
  expect(env_vars).to receive(:http_server_type).and_return("")
34
34
  expect(env_vars).to receive(:web_server_type).and_return("")
@@ -39,14 +39,14 @@ describe Gordon::Cookery::DependencyResolver do
39
39
  "systemd",
40
40
  ]
41
41
 
42
- expect(subject.resolve_dependencies(env_vars)).to eq(expected)
42
+ expect(subject.resolve_dependencies(env_vars, :centos)).to eq(expected)
43
43
  end
44
44
  end
45
45
 
46
46
  context 'given a java standalone app' do
47
47
  it 'returns all dependencies for web' do
48
- expect(env_vars).to receive(:app_type).and_return("java_web_app")
49
48
  allow(env_vars).to receive(:http_server_type).and_return("apache")
49
+ expect(env_vars).to receive(:runtime_name).and_return("java-oracle")
50
50
  allow(env_vars).to receive(:runtime_version).and_return("1.7.0_60")
51
51
  allow(env_vars).to receive(:web_server_type).and_return("tomcat")
52
52
  expect(env_vars).to receive(:init_type).and_return("")
@@ -57,12 +57,12 @@ describe Gordon::Cookery::DependencyResolver do
57
57
  "tomcat",
58
58
  ]
59
59
 
60
- expect(subject.resolve_dependencies(env_vars)).to eq(expected)
60
+ expect(subject.resolve_dependencies(env_vars, :centos)).to eq(expected)
61
61
  end
62
62
 
63
63
  it 'handles damn Oracle JRE 8 package name' do
64
- expect(env_vars).to receive(:app_type).and_return("java_web_app")
65
64
  allow(env_vars).to receive(:http_server_type).and_return("apache")
65
+ expect(env_vars).to receive(:runtime_name).and_return("java-oracle")
66
66
  allow(env_vars).to receive(:runtime_version).and_return("1.8.0_25")
67
67
  allow(env_vars).to receive(:web_server_type).and_return("tomcat")
68
68
  expect(env_vars).to receive(:init_type).and_return("")
@@ -73,7 +73,55 @@ describe Gordon::Cookery::DependencyResolver do
73
73
  "tomcat",
74
74
  ]
75
75
 
76
- expect(subject.resolve_dependencies(env_vars)).to eq(expected)
76
+ expect(subject.resolve_dependencies(env_vars, :centos)).to eq(expected)
77
+ end
78
+
79
+ it 'handles OpenJDK package name for centos' do
80
+ allow(env_vars).to receive(:http_server_type).and_return("apache")
81
+ expect(env_vars).to receive(:runtime_name).and_return("java-openjdk")
82
+ allow(env_vars).to receive(:runtime_version).and_return("1.7.0_60")
83
+ allow(env_vars).to receive(:web_server_type).and_return("tomcat")
84
+ expect(env_vars).to receive(:init_type).and_return("")
85
+
86
+ expected = [
87
+ "java-1.7.0-openjdk",
88
+ "httpd",
89
+ "tomcat",
90
+ ]
91
+
92
+ expect(subject.resolve_dependencies(env_vars, :centos)).to eq(expected)
93
+ end
94
+
95
+ it 'assigns java-oracle to OpenJDK for debian' do
96
+ allow(env_vars).to receive(:http_server_type).and_return("apache")
97
+ expect(env_vars).to receive(:runtime_name).and_return("java-oracle")
98
+ allow(env_vars).to receive(:runtime_version).and_return("1.7.0_60")
99
+ allow(env_vars).to receive(:web_server_type).and_return("tomcat")
100
+ expect(env_vars).to receive(:init_type).and_return("")
101
+
102
+ expected = [
103
+ "openjdk-7-jre",
104
+ "apache2",
105
+ "tomcat7",
106
+ ]
107
+
108
+ expect(subject.resolve_dependencies(env_vars, :debian)).to eq(expected)
109
+ end
110
+
111
+ it 'handles OpenJDK package name for debian' do
112
+ allow(env_vars).to receive(:http_server_type).and_return("apache")
113
+ expect(env_vars).to receive(:runtime_name).and_return("java-openjdk")
114
+ allow(env_vars).to receive(:runtime_version).and_return("1.7.0_60")
115
+ allow(env_vars).to receive(:web_server_type).and_return("tomcat")
116
+ expect(env_vars).to receive(:init_type).and_return("")
117
+
118
+ expected = [
119
+ "openjdk-7-jre",
120
+ "apache2",
121
+ "tomcat7",
122
+ ]
123
+
124
+ expect(subject.resolve_dependencies(env_vars, :debian)).to eq(expected)
77
125
  end
78
126
  end
79
127
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Gordon::Recipe do
4
- let(:options) { instance_double Gordon::Options, app_type: :ruby_web_app }
4
+ let(:options) { instance_double Gordon::Options, app_type: :web, runtime_name: :ruby }
5
5
  let(:app_type) { Gordon::Application::Types::RubyWebApp.new }
6
6
 
7
7
  subject do
@@ -14,16 +14,6 @@ describe Gordon::Recipe do
14
14
  end
15
15
  end
16
16
 
17
- # TODO: check if is really needed
18
- describe 'getting a platform' do
19
- pending
20
- end
21
-
22
- # TODO: check if is really needed
23
- describe 'checking if requires platform' do
24
- pending
25
- end
26
-
27
17
  describe 'getting application template path' do
28
18
  it 'returns expected path based on app type' do
29
19
  expect(subject.application_template_path).to eq(app_type.get_template_path)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gordon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Pinheiro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-26 00:00:00.000000000 Z
11
+ date: 2015-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -110,6 +110,7 @@ files:
110
110
  - lib/gordon/skeleton/factory.rb
111
111
  - lib/gordon/skeleton/types.rb
112
112
  - lib/gordon/version.rb
113
+ - spec/gordon/application/factory_spec.rb
113
114
  - spec/gordon/application/templates/java_web_app_spec.rb
114
115
  - spec/gordon/application/templates/ruby_standalone_app_spec.rb
115
116
  - spec/gordon/application/templates/ruby_web_app_spec.rb
@@ -158,6 +159,7 @@ signing_key:
158
159
  specification_version: 4
159
160
  summary: A tool to create application OS packages
160
161
  test_files:
162
+ - spec/gordon/application/factory_spec.rb
161
163
  - spec/gordon/application/templates/java_web_app_spec.rb
162
164
  - spec/gordon/application/templates/ruby_standalone_app_spec.rb
163
165
  - spec/gordon/application/templates/ruby_web_app_spec.rb