orchparty 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -0
- data/Gemfile +9 -1
- data/README.md +47 -47
- data/lib/deep_merge.rb +41 -0
- data/lib/orchparty/ast.rb +0 -4
- data/lib/orchparty/dsl_parser.rb +60 -49
- data/lib/orchparty/generators/docker_compose_v2.rb +10 -3
- data/lib/orchparty/transformations.rb +2 -0
- data/lib/orchparty/transformations/all.rb +1 -1
- data/lib/orchparty/transformations/mixin.rb +3 -3
- data/lib/orchparty/transformations/sort.rb +10 -0
- data/lib/orchparty/version.rb +1 -1
- data/orchparty.gemspec +0 -1
- metadata +3 -20
- data/lib/orchparty/ast/application.rb +0 -7
- data/lib/orchparty/ast/mixin.rb +0 -6
- data/lib/orchparty/ast/root.rb +0 -6
- data/lib/orchparty/ast/service.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55f8691c994adb91f7014c7eacf51502935fdfb5
|
4
|
+
data.tar.gz: 896bb151bae3cf8e00dc4d142115f897619404a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6744b33e3722b7b0e068639231b7d482d310f33cd1959771695c6d583a13e910da4b9ad42a4057e87cda51a1c4bc58925901c944861a824b39d51a40d6aafcae
|
7
|
+
data.tar.gz: 45afc985d279854bb41c9ec9b9a17492d86f68107333bc7020c458ace9db85d71213b18cde7b056bbf65148ac89a9cfc2baf6312070245bf45d6eb73d199052c
|
data/.travis.yml
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
sudo: false
|
2
2
|
language: ruby
|
3
|
+
addons:
|
4
|
+
code_climate:
|
5
|
+
repo_token:
|
6
|
+
secure: "HTTk2xYKjsWmnOkQd0CX/ltH5E87vRmqm5z+010D4wc4P8gxrbdwgZB9J/KgKp0u55WP1Ox64VQiMqBQxAOAlMyWd+Wnys6u/ooZx8Wk8msEBio7Pf75VYTLrAfOiRNcE7iYqcv/SBrdj6jkA0+defKtZT65RavVef6B9dyPxXW8lTijW6BAM15Qe+Gh/o+hfLGAeNPMCvNmkXQL/aucGaihqJHU7AJ+udtiCBRJPuXKRSKp92rpj6ar9QyrRNH71V0sJLzpG4CS7xvSwMsKcN1VSzI8TtIYaw602EDesM/82igqgajYCJLYuvUefwexdL+eA8S+P4YHi+QkD4bCFxU1YzWQbFty2B5HBF5RJl3TVeGKu3v3NLQE7MzMfr2g6Cxq4BAY4DdRygVkeviJZJnO8D4iLfZTsawqoga6z+loj89bDxBmHHJxWPYWefOeUJDu2oC9OsxVqAIw/fZ2aorjslRMYieej8GqmZw8USbyGl+t5I4AyaUu8bAcR2pnUaZr+d9/4mA+qFow8XJNuMN2ldfKbGPYXsEiJm57aBNLaOtT5WYQ1m8TRJnaBI+26G2vNXol/OBB5Lh2ThhHDmCyGIEK91uBGGuqw1sDyIriY2DbbuHQFkprEUDLcSnDr7OxvmIaJivdcayYUaM0/znO35owdxH1Y2RCiL50WQc="
|
3
7
|
rvm:
|
4
8
|
- 2.2
|
5
9
|
- 2.3
|
@@ -7,6 +11,8 @@ rvm:
|
|
7
11
|
before_install: gem install bundler -v 1.13.6
|
8
12
|
install: bundle install
|
9
13
|
script: bundle exec rspec
|
14
|
+
after_success:
|
15
|
+
- bundle exec codeclimate-test-reporter
|
10
16
|
deploy:
|
11
17
|
provider: rubygems
|
12
18
|
api_key:
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,8 +2,10 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/jannishuebl/orchparty.svg?branch=master)](https://travis-ci.org/jannishuebl/orchparty)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/orchparty.svg)](https://badge.fury.io/rb/orchparty)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/jannishuebl/orchparty/badges/gpa.svg)](https://codeclimate.com/github/jannishuebl/orchparty)
|
6
|
+
[![Test Coverage](https://codeclimate.com/github/jannishuebl/orchparty/badges/coverage.svg)](https://codeclimate.com/github/jannishuebl/orchparty/coverage)
|
5
7
|
|
6
|
-
Write your orchestration
|
8
|
+
Write your own orchestration config with a Ruby DSL that allows you to have mixins, imports and variables.
|
7
9
|
|
8
10
|
```ruby
|
9
11
|
import "../logging.rb"
|
@@ -22,64 +24,62 @@ application 'my-cool-app' do
|
|
22
24
|
end
|
23
25
|
```
|
24
26
|
|
25
|
-
## Why the
|
27
|
+
## Why the hell?
|
26
28
|
|
27
29
|
### 1. Powerfull Ruby DSL as a YAML replacement
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
-
configurations
|
31
|
+
YAML is great for configuration, it has a clean syntax that is
|
32
|
+
readable for humans as well as machines. In addition it suites for the most of the
|
33
|
+
configurations. Furthermore YAML supports features like referencing,
|
32
34
|
inheritence and multiline Strings.
|
33
35
|
|
34
|
-
In our company we
|
35
|
-
|
36
|
-
|
37
|
-
hell complex, which
|
38
|
-
infrastucture quite painfull, because we need to touch every single service.
|
36
|
+
In our company we have a microservice architecture with multiple applications,
|
37
|
+
which is consisting of multiple services (container types).
|
38
|
+
After a while we have realized that our orchestration configuration were growing continuously and got
|
39
|
+
hell complex, which determine global changes like replacing our logging
|
40
|
+
infrastucture. This changes were quite painfull, because we need to touch every single service.
|
39
41
|
|
40
|
-
Some features
|
42
|
+
Some main features for us:
|
41
43
|
|
42
44
|
1. Mixin support
|
43
|
-
1. Import from
|
44
|
-
1. Using
|
45
|
+
1. Import from different files
|
46
|
+
1. Using variables in imported configs e.g. Stack/Service names
|
45
47
|
|
46
48
|
|
47
|
-
Some of the features are
|
49
|
+
Some of the features are already included in YAML, unfortunately we are not able to use it, because of there complexity.
|
48
50
|
|
49
51
|
|
50
52
|
### 2. Use Ruby instead of Templating engines
|
51
53
|
|
52
|
-
Most of the
|
53
|
-
But
|
54
|
+
Most of the orchestration frameworks are using a derivative of docker-compose.yml.
|
55
|
+
But most of the users realized that yml is not enough for complex
|
54
56
|
orchestration.
|
55
57
|
|
56
|
-
So most of the framework teams
|
58
|
+
So most of the framework teams started to allow templating engines in the
|
57
59
|
docker-compose configuration.
|
58
60
|
|
59
61
|
But why keep going with a data serialization language when we want to program
|
60
|
-
our configuration
|
62
|
+
our own configuration?
|
61
63
|
|
62
|
-
### 3. Have one config for multiple
|
64
|
+
### 3. Have one config for multiple orchestration frameworks
|
63
65
|
|
64
66
|
How much effort is it to get a application running on an
|
65
|
-
|
66
|
-
|
67
|
+
orchestration frameworks? Actually we are glad about finding a prebuild docker-compose file
|
68
|
+
which can be modified by us e.g. for kontena.io, but after modifying for kontena.io we
|
67
69
|
have to redo nearly all the work for rancher, kubernets etc.
|
68
70
|
|
69
|
-
It would be nice if people
|
70
|
-
orchparty and we
|
71
|
+
It would be really nice, if people starting to write an opensource application config using
|
72
|
+
orchparty and we just simply compile the config for all popular orchestration frameworks.
|
71
73
|
|
72
74
|
## Installation
|
73
75
|
|
74
|
-
|
75
|
-
2.2 is needed.
|
76
|
+
Setup a Ruby Enviroment with Ruby 2.2 or higher is necessary for the intallation.
|
76
77
|
|
77
78
|
Install from rubygems.org
|
78
79
|
|
79
80
|
$ gem install orchparty
|
80
81
|
|
81
|
-
Maybe
|
82
|
-
ruby environment is needed.
|
82
|
+
Maybe for the future it is possible to run the gem in a docker container, so no local Ruby Environment is needed.
|
83
83
|
|
84
84
|
## Usage
|
85
85
|
|
@@ -89,14 +89,15 @@ See the commandline usage instrucution by running:
|
|
89
89
|
|
90
90
|
## DSL spec
|
91
91
|
|
92
|
-
So
|
93
|
-
open source replacement of new relic !
|
92
|
+
So let us start an example! Let us implement a configuration for a beautiful app called [app_perf](https://github.com/randy-girard/app_perf) with orchparty. This App is an opensource replacement for [New Relic](https://newrelic.com/)!
|
94
93
|
|
95
94
|
### Applications
|
96
95
|
|
97
|
-
app_perf
|
98
|
-
|
99
|
-
|
96
|
+
app_perf needs the following components:
|
97
|
+
- postgres for data storage
|
98
|
+
- redis as queuing system
|
99
|
+
- web handler as receiver for all metrics
|
100
|
+
- worker for processing the metrics and inserting them to the postgres db.
|
100
101
|
|
101
102
|
```ruby
|
102
103
|
application "app_perf" do
|
@@ -134,8 +135,7 @@ end
|
|
134
135
|
|
135
136
|
### Applevel Mixins
|
136
137
|
|
137
|
-
|
138
|
-
because we want to use an exteral services like RDS from AWS.
|
138
|
+
For using external services like RDS from AWS we do not want to ship postgres in a production setup.
|
139
139
|
|
140
140
|
```ruby
|
141
141
|
mixin "app_perf" do
|
@@ -243,8 +243,7 @@ end
|
|
243
243
|
|
244
244
|
### Commonblock
|
245
245
|
|
246
|
-
|
247
|
-
this also adds the mix "logging.syslog" and environment variables to the redis and postgres service.
|
246
|
+
Using the all-block for adding configs to all services in one application. Of course the mix "logging.syslog" and environment variables will also added to the redis and postgres service.
|
248
247
|
|
249
248
|
```ruby
|
250
249
|
application 'app_perf-prod' do
|
@@ -268,7 +267,7 @@ end
|
|
268
267
|
|
269
268
|
### Variables
|
270
269
|
|
271
|
-
You want to use variables right?
|
270
|
+
You want to use variables right? Because "DRY" ;) well you can:
|
272
271
|
|
273
272
|
```ruby
|
274
273
|
application "app_perf" do
|
@@ -318,8 +317,7 @@ special variables:
|
|
318
317
|
|
319
318
|
### Import
|
320
319
|
|
321
|
-
Above we
|
322
|
-
to that use the import feature.
|
320
|
+
Above we assumed that everything is written in one file. If you do not want to, just use the import feature.
|
323
321
|
|
324
322
|
```ruby
|
325
323
|
import "../logging.rb"
|
@@ -341,15 +339,17 @@ end
|
|
341
339
|
|
342
340
|
## Development
|
343
341
|
|
344
|
-
After checking out the repo
|
345
|
-
|
346
|
-
|
342
|
+
After checking out the repo:
|
343
|
+
1. run `bin/setup` to install dependencies
|
344
|
+
2. run `rake spec` to run the tests
|
345
|
+
You can also run `bin/console` for an interactive prompt that will allow you to make some experiments.
|
347
346
|
|
348
347
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
348
|
+
|
349
|
+
To release a new version:
|
350
|
+
1. update the version number in `version.rb`
|
351
|
+
2. run `bundle exec rake release` which will create a git tag for the version
|
352
|
+
3. push git commits and tags and additionally push the `.gem` file to [rubygems.org](https://rubygems.org).
|
353
353
|
|
354
354
|
## Contributing
|
355
355
|
|
@@ -361,4 +361,4 @@ and contributors are expected to adhere to the
|
|
361
361
|
|
362
362
|
## License
|
363
363
|
|
364
|
-
The gem is available as
|
364
|
+
The gem is available as opensource project under the terms of the [GNU Lesser General Public License v3.0](http://www.gnu.de/documents/lgpl-3.0.en.html).
|
data/lib/deep_merge.rb
CHANGED
@@ -31,6 +31,32 @@ module Hashie
|
|
31
31
|
self
|
32
32
|
end
|
33
33
|
|
34
|
+
def deep_sort_by_key_and_sort_array(&block)
|
35
|
+
self.keys.sort(&block).reduce({}) do |seed, key|
|
36
|
+
seed[key] = self[key]
|
37
|
+
if seed[key].is_a?(Hash)
|
38
|
+
seed[key] = seed[key].deep_sort_by_key_and_sort_array(&block)
|
39
|
+
elsif seed[key].is_a?(Hashie::Array)
|
40
|
+
seed[key] = seed[key].sort(&block)
|
41
|
+
end
|
42
|
+
seed
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Returns a new hash with +self+ and +other_hash+ merged recursively.
|
47
|
+
def deep_sort(&block)
|
48
|
+
copy = dup
|
49
|
+
copy.extend(Hashie::Extensions::DeepMergeConcat) unless copy.respond_to?(:deep_sort!)
|
50
|
+
copy.deep_sort!(&block)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Returns a new hash with +self+ and +other_hash+ merged recursively.
|
54
|
+
# Modifies the receiver in place.
|
55
|
+
def deep_sort!(&block)
|
56
|
+
_recursive_sort(self, &block)
|
57
|
+
self
|
58
|
+
end
|
59
|
+
|
34
60
|
# Returns a new hash with +self+ and +other_hash+ merged recursively.
|
35
61
|
def deep_merge_concat(other_hash, &block)
|
36
62
|
copy = dup
|
@@ -84,6 +110,21 @@ module Hashie
|
|
84
110
|
end
|
85
111
|
end
|
86
112
|
|
113
|
+
def _recursive_sort(object, &block)
|
114
|
+
case object
|
115
|
+
when Hash
|
116
|
+
object = Orchparty::AST::Node.new(object.sort {|a, b| block.call(a[0], b[0]) }.to_h)
|
117
|
+
object.each do |key, value|
|
118
|
+
object[key] = _recursive_sort(value, &block)
|
119
|
+
end
|
120
|
+
object
|
121
|
+
when Array
|
122
|
+
object.map! {|e| _recursive_sort(e, &block) }.sort(&block)
|
123
|
+
else
|
124
|
+
yield(object)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
87
128
|
|
88
129
|
def _recursive_merge_concat(hash, other_hash, &block)
|
89
130
|
other_hash.each do |k, v|
|
data/lib/orchparty/ast.rb
CHANGED
data/lib/orchparty/dsl_parser.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'pathname'
|
2
|
-
require 'docile'
|
3
2
|
module Orchparty
|
4
3
|
class DSLParser
|
5
4
|
attr_reader :filename
|
@@ -12,14 +11,22 @@ module Orchparty
|
|
12
11
|
file_content = File.read(filename)
|
13
12
|
builder = RootBuilder.new
|
14
13
|
builder.instance_eval(file_content, filename)
|
15
|
-
builder.
|
14
|
+
builder._build
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
19
|
-
class
|
18
|
+
class Builder
|
19
|
+
def self.build(*args, block)
|
20
|
+
builder = self.new(*args)
|
21
|
+
builder.instance_eval(&block)
|
22
|
+
builder._build
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class RootBuilder < Builder
|
20
27
|
|
21
28
|
def initialize
|
22
|
-
@root = AST::
|
29
|
+
@root = AST::Node.new(applications: {}, mixins: {})
|
23
30
|
end
|
24
31
|
|
25
32
|
def import(rel_file)
|
@@ -31,50 +38,62 @@ module Orchparty
|
|
31
38
|
end
|
32
39
|
|
33
40
|
def application(name, &block)
|
34
|
-
@root.applications[name] =
|
41
|
+
@root.applications[name] = ApplicationBuilder.build(name, block)
|
35
42
|
self
|
36
43
|
end
|
37
44
|
|
38
45
|
def mixin(name, &block)
|
39
|
-
@root.mixins[name] =
|
46
|
+
@root.mixins[name] = MixinBuilder.build(name, block)
|
40
47
|
self
|
41
48
|
end
|
42
49
|
|
43
|
-
def
|
50
|
+
def _build
|
44
51
|
@root
|
45
52
|
end
|
46
53
|
end
|
47
54
|
|
48
|
-
class MixinBuilder
|
55
|
+
class MixinBuilder < Builder
|
49
56
|
|
50
57
|
def initialize(name)
|
51
|
-
@mixin = AST::
|
58
|
+
@mixin = AST::Node.new(name: name,
|
59
|
+
services: {},
|
60
|
+
mixins: {},
|
61
|
+
volumes: {},
|
62
|
+
networks: {})
|
52
63
|
end
|
53
64
|
|
54
65
|
def service(name, &block)
|
55
|
-
|
56
|
-
|
57
|
-
@mixin.
|
58
|
-
@mixin.mixins[name] = builder._build
|
66
|
+
result = ServiceBuilder.build(name, block)
|
67
|
+
@mixin.services[name] = result
|
68
|
+
@mixin.mixins[name] = result
|
59
69
|
self
|
60
70
|
end
|
61
71
|
|
62
72
|
def mixin(name, &block)
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
73
|
+
@mixin.mixins[name] = ServiceBuilder.build(name, block)
|
74
|
+
end
|
75
|
+
|
76
|
+
def volumes(&block)
|
77
|
+
@mixin.volumes = HashBuilder.build(block)
|
67
78
|
end
|
68
79
|
|
69
|
-
def
|
80
|
+
def networks(&block)
|
81
|
+
@mixin.networks = HashBuilder.build(block)
|
82
|
+
end
|
83
|
+
|
84
|
+
def _build
|
70
85
|
@mixin
|
71
86
|
end
|
72
87
|
end
|
73
88
|
|
74
|
-
class ApplicationBuilder
|
89
|
+
class ApplicationBuilder < Builder
|
75
90
|
|
76
91
|
def initialize(name)
|
77
|
-
@application = AST::
|
92
|
+
@application = AST::Node.new(name: name,
|
93
|
+
services: {},
|
94
|
+
mix: [],
|
95
|
+
mixins: {},
|
96
|
+
volumes: {})
|
78
97
|
end
|
79
98
|
|
80
99
|
def mix(name)
|
@@ -82,48 +101,44 @@ module Orchparty
|
|
82
101
|
end
|
83
102
|
|
84
103
|
def mixin(name, &block)
|
85
|
-
|
86
|
-
builder.instance_eval(&block)
|
87
|
-
@application.mixins[name] = builder._build
|
104
|
+
@application.mixins[name] = CommonBuilder.build(block)
|
88
105
|
self
|
89
106
|
end
|
90
107
|
|
91
108
|
def all(&block)
|
92
|
-
|
93
|
-
builder.instance_eval(&block)
|
94
|
-
@application.all = builder._build
|
109
|
+
@application.all = AllBuilder.build(block)
|
95
110
|
self
|
96
111
|
end
|
97
112
|
|
98
113
|
def variables(&block)
|
99
|
-
|
100
|
-
builder.instance_eval(&block)
|
101
|
-
@application._variables = builder._build
|
114
|
+
@application._variables = HashBuilder.build(block)
|
102
115
|
self
|
103
116
|
end
|
104
117
|
|
118
|
+
def volumes(&block)
|
119
|
+
@application.volumes = HashBuilder.build(block)
|
120
|
+
self
|
121
|
+
end
|
122
|
+
|
123
|
+
def networks(&block)
|
124
|
+
@application.networks = HashBuilder.build(block)
|
125
|
+
end
|
126
|
+
|
105
127
|
def service(name, &block)
|
106
|
-
|
107
|
-
builder.instance_eval(&block)
|
108
|
-
@application.services[name] = builder._build
|
128
|
+
@application.services[name] = ServiceBuilder.build(name, block)
|
109
129
|
self
|
110
130
|
end
|
111
131
|
|
112
|
-
def
|
132
|
+
def _build
|
113
133
|
@application
|
114
134
|
end
|
115
135
|
end
|
116
136
|
|
117
|
-
class HashBuilder
|
118
|
-
|
119
|
-
def initialize
|
120
|
-
end
|
137
|
+
class HashBuilder < Builder
|
121
138
|
|
122
139
|
def method_missing(_, *values, &block)
|
123
140
|
if block_given?
|
124
|
-
|
125
|
-
builder.instance_eval(&block)
|
126
|
-
value = builder._build
|
141
|
+
value = HashBuilder.build(block)
|
127
142
|
if values.count == 1
|
128
143
|
@hash ||= {}
|
129
144
|
@hash[values.first.to_sym] = value
|
@@ -150,10 +165,10 @@ module Orchparty
|
|
150
165
|
end
|
151
166
|
end
|
152
167
|
|
153
|
-
class CommonBuilder
|
168
|
+
class CommonBuilder < Builder
|
154
169
|
|
155
170
|
def initialize
|
156
|
-
@service = AST::
|
171
|
+
@service = AST::Node.new(_mix: [])
|
157
172
|
end
|
158
173
|
|
159
174
|
def mix(name)
|
@@ -162,9 +177,7 @@ module Orchparty
|
|
162
177
|
|
163
178
|
def method_missing(name, *values, &block)
|
164
179
|
if block_given?
|
165
|
-
|
166
|
-
builder.instance_eval(&block)
|
167
|
-
@service[name] = builder._build
|
180
|
+
@service[name] = HashBuilder.build(block)
|
168
181
|
else
|
169
182
|
@service[name] = values.first
|
170
183
|
end
|
@@ -175,9 +188,7 @@ module Orchparty
|
|
175
188
|
end
|
176
189
|
|
177
190
|
def variables(&block)
|
178
|
-
|
179
|
-
builder.instance_eval(&block)
|
180
|
-
@service._variables = builder._build
|
191
|
+
@service._variables = HashBuilder.build(block)
|
181
192
|
self
|
182
193
|
end
|
183
194
|
end
|
@@ -188,7 +199,7 @@ module Orchparty
|
|
188
199
|
class ServiceBuilder < CommonBuilder
|
189
200
|
|
190
201
|
def initialize(name)
|
191
|
-
@service = AST::
|
202
|
+
@service = AST::Node.new(name: name, _mix: [])
|
192
203
|
end
|
193
204
|
end
|
194
205
|
end
|
@@ -7,14 +7,21 @@ module Orchparty
|
|
7
7
|
@ast = ast
|
8
8
|
end
|
9
9
|
|
10
|
+
def transform_to_yaml(hash)
|
11
|
+
hash = hash.deep_transform_values{|v| v.is_a?(Hash) ? v.to_h : v }
|
12
|
+
HashUtils.deep_stringify_keys(hash)
|
13
|
+
end
|
14
|
+
|
10
15
|
def output(application_name)
|
16
|
+
application = ast.applications[application_name]
|
11
17
|
{"version" => "2",
|
12
18
|
"services" =>
|
13
|
-
|
19
|
+
application.services.map do |name,service|
|
14
20
|
service = service.to_h
|
15
|
-
service.delete(:mix)
|
16
21
|
[service.delete(:name), HashUtils.deep_stringify_keys(service.to_h)]
|
17
|
-
end.to_h
|
22
|
+
end.to_h,
|
23
|
+
"volumes" => transform_to_yaml(application.volumes),
|
24
|
+
"networks" => transform_to_yaml(application.networks),
|
18
25
|
}.to_yaml
|
19
26
|
end
|
20
27
|
|
@@ -3,6 +3,7 @@ require 'orchparty/transformations/all'
|
|
3
3
|
require 'orchparty/transformations/variable'
|
4
4
|
require 'orchparty/transformations/mixin'
|
5
5
|
require 'orchparty/transformations/remove_internal'
|
6
|
+
require 'orchparty/transformations/sort'
|
6
7
|
|
7
8
|
module Orchparty
|
8
9
|
module Transformations
|
@@ -11,6 +12,7 @@ module Orchparty
|
|
11
12
|
ast = Mixin.new.transform(ast)
|
12
13
|
ast = Variable.new.transform(ast)
|
13
14
|
ast = RemoveInternal.new.transform(ast)
|
15
|
+
ast = Sort.new.transform(ast)
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
@@ -6,7 +6,7 @@ module Orchparty
|
|
6
6
|
ast.applications.each do |_, application|
|
7
7
|
application.services.transform_values! do |service|
|
8
8
|
if application.all.is_a?(Hash)
|
9
|
-
AST::
|
9
|
+
AST::Node.new(application.all.deep_merge_concat(service))
|
10
10
|
else
|
11
11
|
service
|
12
12
|
end
|
@@ -5,7 +5,7 @@ module Orchparty
|
|
5
5
|
class Mixin
|
6
6
|
def transform(ast)
|
7
7
|
ast.applications.transform_values! do |application|
|
8
|
-
current = AST::
|
8
|
+
current = AST::Node.new
|
9
9
|
application.mix.each do |mixin_name|
|
10
10
|
mixin = application.mixins[mixin_name] || ast.mixins[mixin_name]
|
11
11
|
current = current.deep_merge_concat(mixin)
|
@@ -17,7 +17,7 @@ module Orchparty
|
|
17
17
|
|
18
18
|
def transform_application(application, ast)
|
19
19
|
application.services = application.services.transform_values! do |service|
|
20
|
-
current = AST::
|
20
|
+
current = AST::Node.new
|
21
21
|
service.delete(:_mix).each do |mix|
|
22
22
|
mixin = transform_mixin(resolve_mixin(mix, application, ast), application, ast)
|
23
23
|
current = current.deep_merge_concat(mixin)
|
@@ -37,7 +37,7 @@ module Orchparty
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def transform_mixin(mixin, application, ast)
|
40
|
-
current = AST::
|
40
|
+
current = AST::Node.new
|
41
41
|
mixin[:_mix].each do |mix|
|
42
42
|
current = current.deep_merge_concat(resolve_mixin(mix, application, ast))
|
43
43
|
end
|
data/lib/orchparty/version.rb
CHANGED
data/orchparty.gemspec
CHANGED
@@ -25,7 +25,6 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.require_paths = ["lib"]
|
26
26
|
|
27
27
|
spec.add_dependency "hashie", "~> 3.5.6"
|
28
|
-
spec.add_dependency "docile", "~> 1.1.5"
|
29
28
|
spec.add_dependency "thor", "~> 0.19.4"
|
30
29
|
spec.add_dependency 'psych', '~> 2.2', '>= 2.2.4'
|
31
30
|
spec.add_development_dependency "bundler", "~> 1.13"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orchparty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jannis Huebl
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.5.6
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: docile
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.1.5
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 1.1.5
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: thor
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -141,10 +127,6 @@ files:
|
|
141
127
|
- lib/hash.rb
|
142
128
|
- lib/orchparty.rb
|
143
129
|
- lib/orchparty/ast.rb
|
144
|
-
- lib/orchparty/ast/application.rb
|
145
|
-
- lib/orchparty/ast/mixin.rb
|
146
|
-
- lib/orchparty/ast/root.rb
|
147
|
-
- lib/orchparty/ast/service.rb
|
148
130
|
- lib/orchparty/context.rb
|
149
131
|
- lib/orchparty/dsl_parser.rb
|
150
132
|
- lib/orchparty/generators.rb
|
@@ -154,6 +136,7 @@ files:
|
|
154
136
|
- lib/orchparty/transformations/all.rb
|
155
137
|
- lib/orchparty/transformations/mixin.rb
|
156
138
|
- lib/orchparty/transformations/remove_internal.rb
|
139
|
+
- lib/orchparty/transformations/sort.rb
|
157
140
|
- lib/orchparty/transformations/variable.rb
|
158
141
|
- lib/orchparty/version.rb
|
159
142
|
- orchparty.gemspec
|
data/lib/orchparty/ast/mixin.rb
DELETED
data/lib/orchparty/ast/root.rb
DELETED