gordon 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +91 -0
- data/Rakefile +1 -0
- data/bin/gordon +8 -0
- data/gordon.gemspec +26 -0
- data/lib/gordon/application/templates/ruby_web_app.rb +41 -0
- data/lib/gordon/application/types.rb +41 -0
- data/lib/gordon/cli.rb +88 -0
- data/lib/gordon/cooker.rb +56 -0
- data/lib/gordon/cookery/common.rb +18 -0
- data/lib/gordon/cookery/init.rb +27 -0
- data/lib/gordon/cookery/webserver.rb +14 -0
- data/lib/gordon/factory.rb +19 -0
- data/lib/gordon/options.rb +12 -0
- data/lib/gordon/process.rb +9 -0
- data/lib/gordon/recipe.rb +32 -0
- data/lib/gordon/skeleton/info.rb +28 -0
- data/lib/gordon/skeleton/types.rb +56 -0
- data/lib/gordon/version.rb +3 -0
- data/lib/gordon.rb +17 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c54664a1e5359e5fd1fcbba7441631a573126523
|
4
|
+
data.tar.gz: f7891f315e9960dc15cec108bea040aa6158327f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 99b6cff85548e38b072b5d28750bb8da757117fdbb0c1ab03d60ae07fd12c89399f51d38c99f42b1a91f45469b4750b4de39acc23bbfa82d22ffa602fb9cee12
|
7
|
+
data.tar.gz: f97b983cf4239584ed6e007cba368f865792b18da71f944c7bc8f4f38650c43633c85134c2da5f8a149c28e92f199345e57ff974322f8b7d33d38573b4fef5b6
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rpm
|
3
|
+
*.deb
|
4
|
+
*.tar
|
5
|
+
*.gz
|
6
|
+
*.rbc
|
7
|
+
.bash_history
|
8
|
+
.bundle
|
9
|
+
.config
|
10
|
+
.yardoc
|
11
|
+
Gemfile.lock
|
12
|
+
InstalledFiles
|
13
|
+
_yardoc
|
14
|
+
coverage
|
15
|
+
doc/
|
16
|
+
lib/bundler/man
|
17
|
+
pkg
|
18
|
+
rdoc
|
19
|
+
spec/reports
|
20
|
+
test/tmp
|
21
|
+
test/version_tmp
|
22
|
+
tmp
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Marcelo Pinheiro
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# Gordon
|
2
|
+
|
3
|
+
We all know that build application packages is a pain. A lot of pain.
|
4
|
+
|
5
|
+
Of course, [fpm](https://github.com/jordansissel/fpm) is a awesome tool to abstract package building for a lot of Operational Systems. Period.
|
6
|
+
|
7
|
+
Of course, [fpm-cookery](https://github.com/bernd/fpm-cookery) is another great tool to approach building as a simple recipe.
|
8
|
+
|
9
|
+
But, unfortunately, create recipes for each application can be boring and repetitive. You need to create init files (inittab, systemd, etc) for each project
|
10
|
+
and, if a webserver changes (example: from Thin to Unicorn) you need to change script again, again and again.
|
11
|
+
|
12
|
+
And when you are in front with a web application that breaks Nginx or Apache conventions? Do you remember that feel, bro?
|
13
|
+
|
14
|
+
Gordon is a try to automagically create init files using Foreman and build artifacts using FPM. Make developers free to develop, while you take apps under a minimal control.
|
15
|
+
|
16
|
+
## How it works?
|
17
|
+
|
18
|
+
Gordon have a lot of restrictions:
|
19
|
+
|
20
|
+
* Web Servers: Nginx or Apache (Tomcat soon);
|
21
|
+
* Init scripts: all generated by Foreman;
|
22
|
+
* Apps supported: at this time, Ruby. Java soon and others too.
|
23
|
+
|
24
|
+
## Installation
|
25
|
+
|
26
|
+
Add this line to your application's Gemfile:
|
27
|
+
|
28
|
+
gem 'gordon'
|
29
|
+
|
30
|
+
And then execute:
|
31
|
+
|
32
|
+
$ bundle
|
33
|
+
|
34
|
+
Or install it yourself as:
|
35
|
+
|
36
|
+
$ gem install gordon
|
37
|
+
|
38
|
+
## Usage
|
39
|
+
|
40
|
+
A simple example to build a Ruby Web App that runs Nginx and uses Systemd as init process:
|
41
|
+
|
42
|
+
$ ruby -S gordon \
|
43
|
+
--app-type ruby_web_app \
|
44
|
+
--app-name $APP_NAME \
|
45
|
+
--app-desc $APP_DESC \
|
46
|
+
--app-repo $APP_REPO \
|
47
|
+
--app-version $APP_VERSION \
|
48
|
+
--package-type rpm \
|
49
|
+
--package-dir . \
|
50
|
+
--source-dir . \
|
51
|
+
--build-dir /tmp \
|
52
|
+
--skeleton-type nginx \
|
53
|
+
--init-type systemd \
|
54
|
+
--init-build-dir /tmp/systemd
|
55
|
+
|
56
|
+
It will generate a RPM package with the following structure:
|
57
|
+
|
58
|
+
* /usr/share/nginx/html/*all-app-stuff*
|
59
|
+
* /usr/lib/systemd/system/*app-name*/*all-systemd-stuff*
|
60
|
+
|
61
|
+
Sounds good?
|
62
|
+
|
63
|
+
## Why you not use Omnibus or Heroku buildpacks?
|
64
|
+
|
65
|
+
Because I want to create a tool that can be used as a transition step.
|
66
|
+
|
67
|
+
## Why you use fpm-cookery templates instead of fpm?
|
68
|
+
|
69
|
+
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.
|
70
|
+
|
71
|
+
## Why Gordon?
|
72
|
+
|
73
|
+
Because I like Gordon Ramsay.
|
74
|
+
|
75
|
+
## TODO
|
76
|
+
|
77
|
+
* Very unstable, need to fix it
|
78
|
+
* Validate outputs
|
79
|
+
* Fix annoying --package-dir OptionParser::InvalidOption error
|
80
|
+
* Add a way to map package dependencies
|
81
|
+
* Adapt to use Debian and other OS conventions for Nginx and Apache
|
82
|
+
* Create a better way to handle env vars than injecting a lot of global variables in fpm-cookery ruby-web-app template
|
83
|
+
* Tests
|
84
|
+
|
85
|
+
## Contributing
|
86
|
+
|
87
|
+
1. Fork it
|
88
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
89
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
90
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
91
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/gordon
ADDED
data/gordon.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'gordon/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "gordon"
|
8
|
+
spec.version = Gordon::VERSION
|
9
|
+
spec.authors = ["Marcelo Pinheiro"]
|
10
|
+
spec.email = ["salizzar@gmail.com"]
|
11
|
+
spec.description = %q{Gordon is a tool to create artifacts using fpm-cookery and foreman.}
|
12
|
+
spec.summary = %q{A tool to create application artifacts}
|
13
|
+
spec.homepage = "https://github.com/salizzar/gordon"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_dependency "fpm-cookery"
|
25
|
+
spec.add_dependency "foreman"
|
26
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
$app_name = ENV['GORDON_APP_NAME']
|
2
|
+
$app_desc = ENV['GORDON_APP_DESC']
|
3
|
+
$app_repo = ENV['GORDON_APP_REPO']
|
4
|
+
$app_version = ENV['GORDON_APP_VERSION']
|
5
|
+
#app_depends = ENV['GORDON_APP_DEPENDS']
|
6
|
+
$app_source_dir = ENV['GORDON_APP_SOURCE_DIR']
|
7
|
+
|
8
|
+
$skeleton_type = ENV['GORDON_SKELETON_TYPE']
|
9
|
+
$skeleton_files = ENV['GORDON_SKELETON_FILES']
|
10
|
+
|
11
|
+
$init_type = ENV['GORDON_INIT_TYPE']
|
12
|
+
$init_build_dir = ENV['GORDON_INIT_BUILD_DIR']
|
13
|
+
|
14
|
+
path = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib'))
|
15
|
+
$LOAD_PATH.unshift path
|
16
|
+
|
17
|
+
require 'gordon'
|
18
|
+
|
19
|
+
class RubyWebApp < FPM::Cookery::Recipe
|
20
|
+
include Gordon::Cookery::Common,
|
21
|
+
Gordon::Cookery::Init,
|
22
|
+
Gordon::Cookery::Webserver
|
23
|
+
|
24
|
+
name $app_name
|
25
|
+
description $app_desc
|
26
|
+
version $app_version
|
27
|
+
homepage $app_repo
|
28
|
+
|
29
|
+
source $app_source_dir, with: :local_path
|
30
|
+
# depends $app_depends
|
31
|
+
|
32
|
+
def build
|
33
|
+
vendor_gems
|
34
|
+
end
|
35
|
+
|
36
|
+
def install
|
37
|
+
setup_init_files
|
38
|
+
setup_webserver_files
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Gordon
|
2
|
+
module Application
|
3
|
+
module Types
|
4
|
+
module Base
|
5
|
+
def template_path
|
6
|
+
curdir = File.dirname(__FILE__)
|
7
|
+
template_path = File.join(curdir, 'templates', "#{get_template}.rb")
|
8
|
+
|
9
|
+
File.expand_path(template_path)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class RubyWebApp
|
14
|
+
include Base
|
15
|
+
|
16
|
+
def get_template ; 'ruby_web_app' ; end
|
17
|
+
end
|
18
|
+
|
19
|
+
class JavaWebApp
|
20
|
+
include Base
|
21
|
+
|
22
|
+
def get_template ; 'java_web_app' ; end
|
23
|
+
end
|
24
|
+
|
25
|
+
class JavaStandaloneApp
|
26
|
+
include Base
|
27
|
+
|
28
|
+
def get_template ; 'java_standalone_app' ; end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class Factory
|
33
|
+
def self.create(application_type)
|
34
|
+
namespace = "Application::Types"
|
35
|
+
|
36
|
+
::Gordon::Factory.create_instance(namespace, application_type)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
data/lib/gordon/cli.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module Gordon
|
4
|
+
class CLI
|
5
|
+
def self.run
|
6
|
+
options = Options.new
|
7
|
+
options.source_dir = Dir.pwd
|
8
|
+
options.build_dir = '/tmp'
|
9
|
+
options.package_dir = Dir.pwd
|
10
|
+
options.init_build_dir = '/tmp'
|
11
|
+
|
12
|
+
parser = create_option_parser(options)
|
13
|
+
parser.parse!
|
14
|
+
|
15
|
+
file_path = File.join(Dir.pwd, 'gordon.yml')
|
16
|
+
|
17
|
+
recipe = Recipe.new(options)
|
18
|
+
cooker = Cooker.new(recipe, options)
|
19
|
+
cooker.cook
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.create_option_parser(options)
|
23
|
+
parser = OptionParser.new do |opts|
|
24
|
+
opts.banner = 'Usage: gordon [options]'
|
25
|
+
|
26
|
+
opts.on('-t', '--app-type APP_TYPE', 'Application Type') do |type|
|
27
|
+
options.app_type = type
|
28
|
+
end
|
29
|
+
|
30
|
+
opts.on('-n', '--app-name APP_NAME', 'Application Name') do |name|
|
31
|
+
options.app_name = name
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.on('-d', '--app-desc APP_DESC', 'Application Description') do |desc|
|
35
|
+
options.app_desc = desc
|
36
|
+
end
|
37
|
+
|
38
|
+
opts.on('-r', '--app-repo APP_REPO', 'Application Repository URL') do |repo|
|
39
|
+
options.app_repo = repo
|
40
|
+
end
|
41
|
+
|
42
|
+
opts.on('-V', '--app-version APP_VERSION', 'Application Version') do |version|
|
43
|
+
options.app_version = version
|
44
|
+
end
|
45
|
+
|
46
|
+
opts.on('-p', '--package-type PACKAGE', 'Package type') do |package_type|
|
47
|
+
options.package_type = package_type
|
48
|
+
end
|
49
|
+
|
50
|
+
opts.on('-P' '--package-dir PACKAGE_DIR', 'Package Directory') do |package_dir|
|
51
|
+
options.package_dir = package_dir
|
52
|
+
end
|
53
|
+
|
54
|
+
opts.on('-s', '--source-dir SOURCE_DIR', 'Source Directory') do |source_dir|
|
55
|
+
options.source_dir = source_dir
|
56
|
+
end
|
57
|
+
|
58
|
+
opts.on('-b', '--build-dir BUILD_DIR', 'Build Directory') do |build_dir|
|
59
|
+
options.build_dir = build_dir
|
60
|
+
end
|
61
|
+
|
62
|
+
opts.on('-S', '--skeleton-type SKELETON_TYPE', 'Skeleton Type') do |skeleton_type|
|
63
|
+
options.skeleton_type = skeleton_type
|
64
|
+
end
|
65
|
+
|
66
|
+
opts.on('-i', '--init-type INIT_TYPE', 'Init Type') do |init_type|
|
67
|
+
options.init_type = init_type
|
68
|
+
end
|
69
|
+
|
70
|
+
opts.on('-I', '--init-build-dir INIT_BUILD_DIR', 'Init Build Directory') do |init_build_dir|
|
71
|
+
options.init_build_dir = init_build_dir
|
72
|
+
end
|
73
|
+
|
74
|
+
opts.on('-D', '--debug DEBUG', 'Debug Mode') do |debug|
|
75
|
+
options.debug = debug
|
76
|
+
end
|
77
|
+
|
78
|
+
opts.on('-h', '--help', 'Displays Help') do
|
79
|
+
puts opts
|
80
|
+
exit
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
parser
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Gordon
|
2
|
+
class Cooker
|
3
|
+
attr_reader :options, :recipe
|
4
|
+
|
5
|
+
def initialize(recipe, options)
|
6
|
+
@recipe = recipe
|
7
|
+
@options = options
|
8
|
+
end
|
9
|
+
|
10
|
+
def cook
|
11
|
+
cook_args = []
|
12
|
+
|
13
|
+
cook_args << "--debug" if options.debug?
|
14
|
+
|
15
|
+
cook_args << "--target #{options.package_type}"
|
16
|
+
cook_args << "--platform #{recipe.platform}" if recipe.requires_platform?
|
17
|
+
cook_args << "--cache-dir #{File.expand_path(options.build_dir)}"
|
18
|
+
cook_args << "--tmp-root #{File.expand_path(options.build_dir)}"
|
19
|
+
cook_args << "--pkg-dir #{File.expand_path(options.package_dir)}"
|
20
|
+
cook_args << "package"
|
21
|
+
cook_args << recipe.application_template_path
|
22
|
+
|
23
|
+
env_vars = get_env_vars
|
24
|
+
command = "#{env_vars.join " "} ruby -S fpm-cook #{cook_args.join " "}"
|
25
|
+
|
26
|
+
if options.debug?
|
27
|
+
STDOUT.puts ''
|
28
|
+
STDOUT.puts command
|
29
|
+
STDOUT.puts ''
|
30
|
+
end
|
31
|
+
|
32
|
+
Process.run(command)
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def get_env_vars
|
38
|
+
env_vars = []
|
39
|
+
|
40
|
+
env_vars << "GORDON_APP_NAME=#{options.app_name}"
|
41
|
+
env_vars << "GORDON_APP_DESC=#{options.app_desc}"
|
42
|
+
env_vars << "GORDON_APP_REPO=#{options.app_repo}"
|
43
|
+
env_vars << "GORDON_APP_VERSION=#{options.app_version}"
|
44
|
+
env_vars << "GORDON_APP_SOURCE_DIR=#{File.expand_path(options.source_dir)}"
|
45
|
+
|
46
|
+
env_vars << "GORDON_SKELETON_TYPE=#{recipe.skeleton.type}"
|
47
|
+
env_vars << "GORDON_SKELETON_FILES=#{recipe.skeleton.artifacts.join(',')}"
|
48
|
+
|
49
|
+
env_vars << "GORDON_INIT_TYPE=#{options.init_type}"
|
50
|
+
env_vars << "GORDON_INIT_BUILD_DIR=#{File.expand_path(options.init_build_dir)}"
|
51
|
+
|
52
|
+
env_vars
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Gordon
|
2
|
+
module Cookery
|
3
|
+
module Common
|
4
|
+
def vendor_gems
|
5
|
+
safesystem('ruby -S bundle install --deployment --without development test')
|
6
|
+
end
|
7
|
+
|
8
|
+
def common_ruby_files
|
9
|
+
%w(.bundle Gemfile Gemfile.lock Procfile config.ru vendor)
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_skeleton_path(skeleton_type)
|
13
|
+
skeleton_type.path(skeleton_type.requires_app_name? ? $app_name : '')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Gordon
|
2
|
+
module Cookery
|
3
|
+
module Init
|
4
|
+
def setup_init_files
|
5
|
+
create_init_files
|
6
|
+
install_init_files
|
7
|
+
end
|
8
|
+
|
9
|
+
def create_init_files
|
10
|
+
init_build_dir_path = File.join($init_build_dir, $init_type)
|
11
|
+
|
12
|
+
command = "ruby -S foreman export --app #{$app_name} #{$init_type} #{init_build_dir_path}"
|
13
|
+
::Gordon::Process.run(command)
|
14
|
+
end
|
15
|
+
|
16
|
+
def install_init_files
|
17
|
+
init_build_dir_path = File.join($init_build_dir, $init_type)
|
18
|
+
|
19
|
+
skeleton_type = ::Gordon::Skeleton::Types::Factory.create($init_type)
|
20
|
+
path = get_skeleton_path(skeleton_type)
|
21
|
+
|
22
|
+
root(path).install Dir["#{init_build_dir_path}/*"]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Gordon
|
2
|
+
module Cookery
|
3
|
+
module Webserver
|
4
|
+
def setup_webserver_files
|
5
|
+
skeleton_type = ::Gordon::Skeleton::Types::Factory.create($skeleton_type)
|
6
|
+
skeleton_path = get_skeleton_path(skeleton_type)
|
7
|
+
|
8
|
+
root(skeleton_path).install common_ruby_files
|
9
|
+
root(skeleton_path).install $skeleton_files.split(',')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Gordon
|
2
|
+
class Factory
|
3
|
+
def self.create_instance(namespace, object_type)
|
4
|
+
fragments = object_type.split('_')
|
5
|
+
|
6
|
+
type = fragments.map do |fragment|
|
7
|
+
fragment[0].upcase + fragment[1..-1]
|
8
|
+
end.join('')
|
9
|
+
|
10
|
+
ns = "Gordon::#{namespace}::#{type}"
|
11
|
+
|
12
|
+
klass = ns.split('::').inject(Object) do |obj, ns|
|
13
|
+
obj.const_get(ns)
|
14
|
+
end
|
15
|
+
|
16
|
+
klass.new
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Gordon
|
2
|
+
class Options
|
3
|
+
attr_accessor :app_type, :app_name, :app_desc, :app_repo, :app_version
|
4
|
+
attr_accessor :package_type, :package_dir
|
5
|
+
attr_accessor :source_dir, :build_dir
|
6
|
+
attr_accessor :skeleton_type
|
7
|
+
attr_accessor :init_type, :init_build_dir
|
8
|
+
attr_accessor :debug
|
9
|
+
|
10
|
+
def debug? ; !!debug ; end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
3
|
+
module Gordon
|
4
|
+
class Recipe
|
5
|
+
attr_reader :options, :skeleton
|
6
|
+
|
7
|
+
def initialize(options)
|
8
|
+
@options = options
|
9
|
+
@skeleton = Skeleton::Info.new(options.skeleton_type, options.source_dir)
|
10
|
+
end
|
11
|
+
|
12
|
+
def platform
|
13
|
+
map = {
|
14
|
+
'rpm' => 'centos',
|
15
|
+
'deb' => 'debian',
|
16
|
+
}
|
17
|
+
|
18
|
+
map[options.package_type]
|
19
|
+
end
|
20
|
+
|
21
|
+
def requires_platform?
|
22
|
+
!!platform
|
23
|
+
end
|
24
|
+
|
25
|
+
def application_template_path
|
26
|
+
application = Application::Factory.create(options.app_type)
|
27
|
+
|
28
|
+
application.template_path
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Gordon
|
2
|
+
module Skeleton
|
3
|
+
class Info
|
4
|
+
attr_reader :type, :artifacts
|
5
|
+
|
6
|
+
BLACKLIST = %w(.git log spec Vagrantfile coverage tmp/cache)
|
7
|
+
|
8
|
+
def initialize(type, source_dir)
|
9
|
+
@type, @artifacts = type, clean_source_files(source_dir)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def clean_source_files(source_dir)
|
15
|
+
source_path = File.join(source_dir, '*')
|
16
|
+
|
17
|
+
all_files = Dir[source_path]
|
18
|
+
|
19
|
+
blacklist = BLACKLIST.map do |file|
|
20
|
+
File.join(source_dir, file)
|
21
|
+
end
|
22
|
+
|
23
|
+
all_files - blacklist
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Gordon
|
2
|
+
module Skeleton
|
3
|
+
module Types
|
4
|
+
module Base
|
5
|
+
def path(app = '')
|
6
|
+
File.join(get_default_path, app)
|
7
|
+
end
|
8
|
+
|
9
|
+
def requires_app_name?
|
10
|
+
false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Nginx
|
15
|
+
include Base
|
16
|
+
|
17
|
+
def get_default_path ; '/usr/share/nginx/html' ; end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Httpd
|
21
|
+
include Base
|
22
|
+
|
23
|
+
def get_default_path ; '/var/www/html' ; end
|
24
|
+
end
|
25
|
+
|
26
|
+
class Misc
|
27
|
+
include Base
|
28
|
+
|
29
|
+
def get_default_path ; '/opt' ; end
|
30
|
+
|
31
|
+
def requires_app_name?
|
32
|
+
true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class Systemd
|
37
|
+
include Base
|
38
|
+
|
39
|
+
def get_default_path ; '/usr/lib/systemd/system' ; end
|
40
|
+
|
41
|
+
def requires_app_name?
|
42
|
+
true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class Factory
|
47
|
+
def self.create(skeleton_type)
|
48
|
+
namespace = "Skeleton::Types"
|
49
|
+
|
50
|
+
::Gordon::Factory.create_instance(namespace, skeleton_type)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
data/lib/gordon.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "gordon/version"
|
2
|
+
|
3
|
+
module Gordon
|
4
|
+
require 'gordon/cli'
|
5
|
+
require 'gordon/cooker'
|
6
|
+
require 'gordon/recipe'
|
7
|
+
require 'gordon/factory'
|
8
|
+
require 'gordon/options'
|
9
|
+
require 'gordon/process'
|
10
|
+
require 'gordon/application/types'
|
11
|
+
require 'gordon/cookery/common'
|
12
|
+
require 'gordon/cookery/init'
|
13
|
+
require 'gordon/cookery/webserver'
|
14
|
+
require 'gordon/skeleton/info'
|
15
|
+
require 'gordon/skeleton/types'
|
16
|
+
end
|
17
|
+
|
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gordon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marcelo Pinheiro
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: fpm-cookery
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: foreman
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Gordon is a tool to create artifacts using fpm-cookery and foreman.
|
70
|
+
email:
|
71
|
+
- salizzar@gmail.com
|
72
|
+
executables:
|
73
|
+
- gordon
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/gordon
|
83
|
+
- gordon.gemspec
|
84
|
+
- lib/gordon.rb
|
85
|
+
- lib/gordon/application/templates/ruby_web_app.rb
|
86
|
+
- lib/gordon/application/types.rb
|
87
|
+
- lib/gordon/cli.rb
|
88
|
+
- lib/gordon/cooker.rb
|
89
|
+
- lib/gordon/cookery/common.rb
|
90
|
+
- lib/gordon/cookery/init.rb
|
91
|
+
- lib/gordon/cookery/webserver.rb
|
92
|
+
- lib/gordon/factory.rb
|
93
|
+
- lib/gordon/options.rb
|
94
|
+
- lib/gordon/process.rb
|
95
|
+
- lib/gordon/recipe.rb
|
96
|
+
- lib/gordon/skeleton/info.rb
|
97
|
+
- lib/gordon/skeleton/types.rb
|
98
|
+
- lib/gordon/version.rb
|
99
|
+
homepage: https://github.com/salizzar/gordon
|
100
|
+
licenses:
|
101
|
+
- MIT
|
102
|
+
metadata: {}
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 2.0.14
|
120
|
+
signing_key:
|
121
|
+
specification_version: 4
|
122
|
+
summary: A tool to create application artifacts
|
123
|
+
test_files: []
|