jack-eb 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 +1 -3
- data/CHANGELOG.md +8 -0
- data/README.md +62 -71
- data/lib/jack/cli.rb +8 -3
- data/lib/jack/cli/help.rb +17 -17
- data/lib/jack/config.rb +3 -2
- data/lib/jack/config/diff.rb +1 -1
- data/lib/jack/config/download.rb +2 -2
- data/lib/jack/config/sort.rb +2 -2
- data/lib/jack/config/transmit.rb +2 -2
- data/lib/jack/config/upload.rb +5 -5
- data/lib/jack/config/yaml_formatter.rb +5 -3
- data/lib/jack/default/settings.yml +2 -2
- data/lib/jack/eb_config/create.rb +1 -1
- data/lib/jack/settings.rb +1 -1
- data/lib/jack/version.rb +1 -1
- data/spec/fixtures/project/jack/cfg/{stag-rails-app-s9.cfg.yml → hi-web-stag-1.cfg.yml} +0 -0
- data/spec/lib/cli_spec.rb +4 -5
- data/spec/lib/create_spec.rb +3 -3
- data/spec/lib/eb_config/create_spec.rb +7 -7
- data/spec/lib/settings_spec.rb +1 -1
- data/spec/lib/util_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/support/fake_project.rb +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e095571181846a04003b3a1d75d240db355159c5
|
4
|
+
data.tar.gz: c7512eca5ecc54afcf6d60ee49ab31fc6904a906
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7294c1c20b0e20bbb57f5f5c7e541aca79e8616004db23551e8b3ffc7b1023bef5351dd1a29600948f5e038dfe2994a05893f840bb5f4511462e948aacae53e7
|
7
|
+
data.tar.gz: 5c546e4064b4f95993d87220ecf9095ac26b1adf4706105ca3d06e6f096a461fb18da610ee45ede3e75b773e40949b7600f3afee89b3b8586655f3f382be8b1a
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
|
+
|
6
|
+
## [0.3.0]
|
7
|
+
|
8
|
+
- Change the default app name convention to: [app]-[role]-[env]. This is a breaking change with version 0.2.0, if you need to use old app name convention override the conventions.app_name_pattern with `jack/settings.yml`.
|
data/README.md
CHANGED
@@ -5,17 +5,17 @@
|
|
5
5
|
[![Code Climate](https://codeclimate.com/github/tongueroo/jack/badges/gpa.svg)](https://codeclimate.com/github/tongueroo/jack)
|
6
6
|
[![Test Coverage](https://codeclimate.com/github/tongueroo/jack/badges/coverage.svg)](https://codeclimate.com/github/tongueroo/jack)
|
7
7
|
|
8
|
-
Jack is a wrapper tool around the [aws eb cli3](http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3.html) tool use
|
8
|
+
Jack is a wrapper tool around the [aws eb cli3](http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3.html) tool use for managing AWS Elastic Beanstalk, EB, environments. It allows you to create environments using the saved template configuration file generated by `eb config save`. Jack moves the config file to the jack/cfg folder of your project and manages the the config files from there.
|
9
9
|
|
10
|
-
Jack
|
10
|
+
Jack provides a `jack config upload` command to update the EB environment. Before uploading the new configuration to EB jack first downloads the current configuration and then does a diff on the changes that are about to be applied. This gives a very helpful preview of exactly what you are intending to change. This particularly helpful when changes are made through the EB GUI and are out of sync with what is stored in the `jack/cfg` files. The demo video is available [here](https://www.youtube.com/watch?v=t7EcAOf8h1o).
|
11
11
|
|
12
|
-
For things that this tool does not
|
12
|
+
For things that this tool does not cover like deploying code, it is recommended that you use use the underlying aws `eb` tool directly. `eb deploy` provides a good deploy command already. This tool has been tested with `EB CLI 3.8.3 (Python 2.7.1)`.
|
13
13
|
|
14
14
|
## Use Cases
|
15
15
|
|
16
16
|
* Downloading EB config to codified the EB infrastructure that has been built.
|
17
|
-
* Allowing safe uploading of new configs.
|
18
|
-
* Moving EB enviroments from one EB application to another EB application. EB provides a way to clone environments within an application but not to another application.
|
17
|
+
* Allowing safe uploading of new configs since the preview feature allows you to inspect the changes before actually uploading the configuration.
|
18
|
+
* Moving EB enviroments from one EB application to another EB application. EB provides a way to clone environments within an application but not to another entire application. This is useful if you want to "rename" the EB application.
|
19
19
|
|
20
20
|
## Installation
|
21
21
|
|
@@ -23,16 +23,16 @@ For things that this tool does not do, it is recommended that you use use the un
|
|
23
23
|
$ gem install jack-eb
|
24
24
|
```
|
25
25
|
|
26
|
-
Note that the gem is called jack-eb but the command that is installed is called jack
|
26
|
+
Note that the gem is called jack-eb but the actual command that is installed is called `jack`.
|
27
27
|
|
28
28
|
### Setup
|
29
29
|
|
30
30
|
If the version of `eb` that you are using is not working with jack, here is a way to install the specific version jack has been tested with.
|
31
31
|
|
32
32
|
<pre>
|
33
|
-
cd ~/ && wget https://pypi.python.org/packages/source/a/awsebcli/awsebcli-3.
|
34
|
-
tar -zxvf awsebcli-3.
|
35
|
-
cd awsebcli-3.
|
33
|
+
cd ~/ && wget https://pypi.python.org/packages/source/a/awsebcli/awsebcli-3.8.3.tar.gz
|
34
|
+
tar -zxvf awsebcli-3.8.3.tar.gz
|
35
|
+
cd awsebcli-3.8.3
|
36
36
|
sudo python setup.py install
|
37
37
|
</pre>
|
38
38
|
|
@@ -41,6 +41,7 @@ More detail instructions are on [AWS EB Documentation](http://docs.aws.amazon.co
|
|
41
41
|
I typically install the `eb` cli tool with homebrew.
|
42
42
|
|
43
43
|
<pre>
|
44
|
+
brew update
|
44
45
|
brew install awsebcli
|
45
46
|
</pre>
|
46
47
|
|
@@ -51,10 +52,6 @@ export AWS_ACCESS_KEY_ID=xxx
|
|
51
52
|
export AWS_SECRET_ACCESS_KEY=xxx
|
52
53
|
</pre>
|
53
54
|
|
54
|
-
The jack tool does not yet support the `.aws/credentials` method of setting the aws keys.
|
55
|
-
|
56
|
-
You're ready to go.
|
57
|
-
|
58
55
|
## Usage
|
59
56
|
|
60
57
|
### Conventions
|
@@ -62,130 +59,124 @@ You're ready to go.
|
|
62
59
|
Before using the tool, it is good to know that jack follows a convention for the environment and application name. This is done in order to keep the jack commands simple and short. The convention is:
|
63
60
|
|
64
61
|
<pre>
|
65
|
-
environment_name: [
|
62
|
+
environment_name: [app]-[role]-[env]
|
66
63
|
application_name: [app]
|
67
64
|
</pre>
|
68
65
|
|
69
66
|
A concrete example is helpful:
|
70
67
|
|
71
68
|
<pre>
|
72
|
-
environment_name:
|
73
|
-
application_name:
|
69
|
+
environment_name: hi-web-prod
|
70
|
+
application_name: hi
|
74
71
|
</pre>
|
75
72
|
|
76
|
-
The example above means the EB application name will be `
|
73
|
+
The example above means the EB application name will be `hi` and the environment name will be `hi-web-prod`. By convention, the first word, separated by a '-', of the environment name is the application name.
|
77
74
|
|
78
|
-
This convention can be
|
75
|
+
This convention can be overridden easily via by creating a `~/.jack/settings.yml` or `jack/settings.yml` within the project and defining your own regular expression with the `conventions.app_name_pattern` key. The regexp is a ruby regexp and must have 1 capture group. The capture group is used to determine the application name. Here is an example:
|
79
76
|
|
80
77
|
```yaml
|
81
78
|
create:
|
82
79
|
keyname: default
|
83
|
-
platform: "64bit Amazon Linux
|
80
|
+
platform: "64bit Amazon Linux 2016.09 v2.2.0 running Docker 1.11.2"
|
84
81
|
conventions:
|
85
|
-
app_name_pattern: (\w+)-\w
|
82
|
+
app_name_pattern: !ruby/regexp /\w+-(\w+)-\w+/
|
86
83
|
```
|
87
84
|
|
88
|
-
In the example above, the capture group is the
|
85
|
+
In the example above, the capture group is the second word and this will result in:
|
89
86
|
|
90
87
|
<pre>
|
91
|
-
environment_name:
|
92
|
-
application_name:
|
88
|
+
environment_name: prod-hi-web
|
89
|
+
application_name: hi
|
93
90
|
</pre>
|
94
91
|
|
95
92
|
|
96
|
-
The default
|
93
|
+
The default setting is located at [lib/jack/default/settings.yml](https://github.com/tongueroo/jack/blob/master/lib/jack/default/settings.yml).
|
97
94
|
|
98
95
|
You can also override the application name convention from the cli with the `--app` flag. Examples are provided below.
|
99
96
|
|
100
|
-
###
|
97
|
+
### Creating Environments
|
101
98
|
|
102
|
-
|
99
|
+
If you do not yet have EB environment simply create an EB environment with jack and then you can download the initial EB config file it afterwards. To create a EB environment using jack without an initial config file.
|
103
100
|
|
104
|
-
|
105
|
-
$
|
106
|
-
|
101
|
+
```bash
|
102
|
+
$ git clone https://github.com/tongueroo/sinatra
|
103
|
+
$ cd sinatra
|
104
|
+
$ jack create hi-web-stag-1
|
105
|
+
```
|
107
106
|
|
108
|
-
The
|
107
|
+
The big benefit of using jack though is the ability to create EB environments based on previously saved configuration files. So now you can download the configuration file from the newly created hi-web-stag-1 environment and version control them.
|
109
108
|
|
110
|
-
|
111
|
-
$ jack config download
|
112
|
-
|
113
|
-
Running: eb config save --cfg current-2015-03-03_18-40-34 stag-rails-app-s1
|
114
|
-
|
115
|
-
Configuration saved at: /Users/tung/src/rails/.elasticbeanstalk/saved_configs/current-2015-03-03_18-40-34.cfg.yml
|
116
|
-
Writing to local config file: jack/cfg/stag-rails-app-s1.cfg.yml
|
117
|
-
Cleaning up eb remote config and local files
|
118
|
-
Config downloaded to jack/cfg/stag-rails-app.cfg.yml
|
119
|
-
$
|
120
|
-
</pre>
|
109
|
+
```bash
|
110
|
+
$ jack config download hi-web-stag-1
|
111
|
+
```
|
121
112
|
|
122
|
-
|
113
|
+
This above saves the configuration file at `jack/cfg/hi-web-stag-1.cfg.yml`. Here is an [example](https://gist.github.com/tongueroo/5791a4575a71cb664d48e4e8b29791b3) of what the config file.
|
123
114
|
|
124
|
-
|
125
|
-
$ jack config download -c myconfig stag-rails-app-s1
|
126
|
-
</pre>
|
115
|
+
If you would like to save the config file under a different path, you can use the `-c` option.
|
127
116
|
|
128
|
-
|
129
|
-
|
130
|
-
|
117
|
+
```bash
|
118
|
+
$ jack config download hi-web-stag-1 -c my-config
|
119
|
+
```
|
131
120
|
|
132
|
-
|
121
|
+
This saves the config file to `jack/cfg/my-config.cfg.yml` looks like.
|
133
122
|
|
134
|
-
|
135
|
-
* [Here](https://gist.github.com/tongueroo/f22bbae7864ecec41ff3) is an example of what you would tyically see when you download the initial saved configuration.
|
123
|
+
You can then create different environments using any of the saved config files.
|
136
124
|
|
137
|
-
|
125
|
+
```bash
|
126
|
+
$ jack create -c my-config hi-web-stag-2 # creates environment using jack/cfg/myconfig.cfg.yml
|
127
|
+
```
|
138
128
|
|
139
|
-
|
129
|
+
If the project is brand new and has never had `eb init` ran on it before like a project that has been newly git cloned. Then calling any of the jack commands will automatically call `eb init` in the project. `eb init` requires the platform flag in order to avoid prompting. The default platform is "64bit Amazon Linux 2016.09 v2.2.0 running Docker 1.11.2". But you can override that by creating an `~/.jack/settings.yml` or `jack/settings.yml` within the project folder and setting the `create.platform` key.
|
140
130
|
|
141
|
-
|
142
|
-
$ jack create stag-rails-app-s1 # uses the jack/cfg/stag-rails-app-s1.cfg.yml config
|
143
|
-
$ jack create stag-rails-app-s2 # uses the jack/cfg/stag-rails-app-s2.cfg.yml config
|
144
|
-
$ jack create -c myconfig stag-rails-app-s3 # creates environment using jack/cfg/myconfig.cfg.yml
|
145
|
-
</pre>
|
131
|
+
Here's an [example](https://gist.github.com/tongueroo/086e3c11c4d00d5c39b6). The options from each file is merged and combined together in following order: project folder, user home, [default](lib/jack/default/settings.yml) that is packaged with this gem. So the project `jack/settings.yml` options have higher precedence than `~/.jack/settings.yml`.
|
146
132
|
|
147
|
-
If the project is brand new and has never had `eb init` ran on it before. For example, a project that has just been git cloned. Then calling any of the jack commands will automatically call `eb init` in the project. `eb init` requires the platform flag in order to avoid prompting. The default platform is "64bit Amazon Linux 2015.03 v1.4.0 running Docker 1.6.0". But you can override that by creating an `~/.jack/settings.yml` or `jack/settings.yml` within the project folder and setting the `create.platform` key.
|
148
133
|
|
149
|
-
|
134
|
+
### More Configuration Examples
|
150
135
|
|
151
|
-
|
136
|
+
Configuration templates hold all the options and settings that we can set for an EB environment. Elastic Beanstalk surfaces a portion of settings available from the underlying AWS Resources. These settings include ELB behavior, VPC, LaunchConfiguration, Autoscaling settings, hard drive size, environment variables, etc. Here is an [example](https://gist.github.com/tongueroo/5791a4575a71cb664d48e4e8b29791b3).
|
152
137
|
|
153
|
-
#### Download
|
138
|
+
#### Download Config
|
154
139
|
|
155
140
|
To download a template configuration.
|
156
141
|
|
157
142
|
```
|
158
|
-
$ jack config download
|
143
|
+
$ jack config download hi-web-prod-1
|
159
144
|
|
160
|
-
$ jack config download
|
145
|
+
$ jack config download hi-web-prod-1 --app customappname
|
161
146
|
```
|
162
147
|
|
163
|
-
This will save the config to jack/cfg/
|
148
|
+
This will save the config to jack/cfg/hi-web-prod-1.cfg.yml.
|
164
149
|
|
165
|
-
#### Upload
|
150
|
+
#### Upload Config
|
166
151
|
|
167
152
|
To upload a template configuration.
|
168
153
|
|
169
154
|
```
|
170
|
-
$ jack config upload
|
155
|
+
$ jack config upload hi-web-prod-1
|
171
156
|
|
172
|
-
$ jack config upload
|
157
|
+
$ jack config upload hi-web-prod-1 --app customappname
|
173
158
|
```
|
174
159
|
|
175
|
-
This will save the config to `jack/cfg/
|
160
|
+
This will save the config to `jack/cfg/hi-web-prod-1.cfg.yml`.
|
176
161
|
|
177
162
|
You will notice that the `eb config upload` command prompts you with the diff and asks for confirmation before uploading. You can bypass the prompt with the force option.
|
178
163
|
|
179
|
-
#### Diff - Comparing your local config to the live environment config
|
164
|
+
#### Diff Config - Comparing your local config to the live environment config
|
180
165
|
|
181
166
|
You can use the diff command directly to compare your local config to what configs the environment is actually using is useful. To see the diff.
|
182
167
|
|
183
168
|
```
|
184
|
-
$ jack config diff
|
169
|
+
$ jack config diff hi-web-prod-1
|
185
170
|
```
|
186
171
|
|
187
172
|
A note about the configs. They are formatted so that the keys are sorted. This has been done so the diffs are actually useful. It is also recommended you install colordiff so you can see the diff output colorized. You can also specify your own diff viewer via the JACK_DIFF environment variable.
|
188
173
|
|
174
|
+
To use a your own diff viewer, add this to your `~/.profile`:
|
175
|
+
|
176
|
+
```
|
177
|
+
$ export JACK_DIFF=colordiff
|
178
|
+
```
|
179
|
+
|
189
180
|
### More Help
|
190
181
|
|
191
182
|
You can get help information from the CLI. Examples:
|
data/lib/jack/cli.rb
CHANGED
@@ -4,7 +4,7 @@ require 'jack/version_checker'
|
|
4
4
|
Jack::VersionChecker.new.run unless ENV['TEST']
|
5
5
|
|
6
6
|
module Jack
|
7
|
-
class
|
7
|
+
class Config < Thor
|
8
8
|
desc "upload ENV_NAME", "upload and apply jack config changes to EB environment"
|
9
9
|
long_desc Jack::CLI::Help.upload
|
10
10
|
option :force, aliases: :f, type: :boolean, desc: "skip prompt"
|
@@ -48,8 +48,13 @@ module Jack
|
|
48
48
|
Jack::Create.new(options.merge(env_name: env_name)).run
|
49
49
|
end
|
50
50
|
|
51
|
+
desc "version", "display jack version number"
|
52
|
+
def version
|
53
|
+
puts Jack::VERSION
|
54
|
+
end
|
55
|
+
|
51
56
|
desc "config ACTION ENV_NAME", "manage environment config"
|
52
57
|
long_desc Help.config
|
53
|
-
subcommand "config",
|
58
|
+
subcommand "config", Config
|
54
59
|
end
|
55
|
-
end
|
60
|
+
end
|
data/lib/jack/cli/help.rb
CHANGED
@@ -4,37 +4,37 @@ module Jack
|
|
4
4
|
class << self
|
5
5
|
def convention
|
6
6
|
<<-EOL
|
7
|
-
The configuration name is based on convention. An environment with the name of
|
7
|
+
The configuration name is based on convention. An environment with the name of hi-web-stag-1 results in the jack/cfg/stag-rails-app.cfg.yml being used. The convention can be overriden with the --cfg option.
|
8
8
|
EOL
|
9
9
|
end
|
10
10
|
|
11
11
|
def create
|
12
12
|
<<-EOL
|
13
|
-
Creates a new environment using the configuration in jack/cfg folder.
|
13
|
+
Creates a new environment using the configuration in jack/cfg folder. The AWS sample app is initially used for the newly created environment. The sample app is used as a starting point to make sure that the environment is working before you introduce your own app code.
|
14
14
|
|
15
15
|
#{convention}
|
16
16
|
|
17
17
|
Example:
|
18
18
|
|
19
|
-
$ jack create
|
19
|
+
$ jack create hi-web-stag-1
|
20
20
|
|
21
|
-
$ jack create -c myconfig
|
21
|
+
$ jack create -c myconfig hi-web-stag-1
|
22
22
|
|
23
|
-
$ jack create -a myapp -c myconfig
|
23
|
+
$ jack create -a myapp -c myconfig hi-web-stag-1
|
24
24
|
EOL
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def upload
|
28
28
|
<<-EOL
|
29
|
-
Uploads the specified template configuration in jack/cfg and applies it to the environment immediately.
|
29
|
+
Uploads the specified template configuration in jack/cfg and applies it to the environment immediately.
|
30
30
|
|
31
31
|
#{convention}
|
32
32
|
|
33
33
|
Example:
|
34
34
|
|
35
|
-
$ jack config upload
|
35
|
+
$ jack config upload hi-web-stag-1
|
36
36
|
|
37
|
-
$ jack config upload myapp -c myconfig
|
37
|
+
$ jack config upload myapp -c myconfig hi-web-stag-1
|
38
38
|
EOL
|
39
39
|
end
|
40
40
|
|
@@ -46,9 +46,9 @@ Downloads the environment's config to jack/cfg/[CONFIG_NAME].cfg.yml
|
|
46
46
|
|
47
47
|
Example:
|
48
48
|
|
49
|
-
$ jack config download
|
49
|
+
$ jack config download hi-web-stag-1
|
50
50
|
|
51
|
-
$ jack config download myapp -c myconfig
|
51
|
+
$ jack config download myapp -c myconfig hi-web-stag-1
|
52
52
|
EOL
|
53
53
|
end
|
54
54
|
|
@@ -63,9 +63,9 @@ If you have colordiff installed the diff command will use make use of it. If yo
|
|
63
63
|
|
64
64
|
Example:
|
65
65
|
|
66
|
-
$ jack config diff
|
66
|
+
$ jack config diff hi-web-stag-1
|
67
67
|
|
68
|
-
$ jack config diff myapp -c myconfig
|
68
|
+
$ jack config diff myapp -c myconfig hi-web-stag-1
|
69
69
|
EOL
|
70
70
|
end
|
71
71
|
|
@@ -77,9 +77,9 @@ Reformats local jack config file to a sorted yaml format.
|
|
77
77
|
|
78
78
|
Example:
|
79
79
|
|
80
|
-
$ jack config sort
|
80
|
+
$ jack config sort hi-web-stag-1
|
81
81
|
|
82
|
-
$ jack config sort -c myconfig
|
82
|
+
$ jack config sort -c myconfig hi-web-stag-1 # env name doesnt matter here
|
83
83
|
EOL
|
84
84
|
end
|
85
85
|
|
@@ -90,7 +90,7 @@ Manage the environment's config. Can use this to download the environment's con
|
|
90
90
|
|
91
91
|
Example:
|
92
92
|
|
93
|
-
$ jack config download
|
93
|
+
$ jack config download hi-web-stag-1
|
94
94
|
|
95
95
|
For more info:
|
96
96
|
|
@@ -104,4 +104,4 @@ EOL
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
107
|
-
end
|
107
|
+
end
|
data/lib/jack/config.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'fileutils'
|
2
|
+
require 'thor'
|
2
3
|
|
3
4
|
module Jack
|
4
|
-
|
5
|
+
class Config < Thor
|
5
6
|
autoload :Base, 'jack/config/base'
|
6
7
|
autoload :Diff, 'jack/config/diff'
|
7
8
|
autoload :Download, 'jack/config/download'
|
@@ -10,4 +11,4 @@ module Jack
|
|
10
11
|
autoload :Upload, 'jack/config/upload'
|
11
12
|
autoload :YamlFormatter, 'jack/config/yaml_formatter'
|
12
13
|
end
|
13
|
-
end
|
14
|
+
end
|
data/lib/jack/config/diff.rb
CHANGED
data/lib/jack/config/download.rb
CHANGED
@@ -2,7 +2,7 @@ require 'fileutils'
|
|
2
2
|
require 'yaml'
|
3
3
|
|
4
4
|
module Jack
|
5
|
-
|
5
|
+
class Config < Thor
|
6
6
|
class Download < Transmit
|
7
7
|
include Util
|
8
8
|
|
@@ -58,7 +58,7 @@ module Jack
|
|
58
58
|
def do_copy_to_local_cfg
|
59
59
|
return if @options[:noop]
|
60
60
|
local_path = "#{@root}/#{@local_config_path}"
|
61
|
-
FileUtils.cp(@current_path, local_path)
|
61
|
+
FileUtils.cp(@current_path, local_path)
|
62
62
|
YamlFormatter.new.process(local_path)
|
63
63
|
end
|
64
64
|
|
data/lib/jack/config/sort.rb
CHANGED
data/lib/jack/config/transmit.rb
CHANGED
data/lib/jack/config/upload.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
|
3
3
|
module Jack
|
4
|
-
|
4
|
+
class Config < Thor
|
5
5
|
class Upload < Transmit
|
6
6
|
include Util
|
7
7
|
|
@@ -21,7 +21,7 @@ module Jack
|
|
21
21
|
compare
|
22
22
|
if confirm
|
23
23
|
upload
|
24
|
-
update_env
|
24
|
+
update_env
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -40,9 +40,9 @@ module Jack
|
|
40
40
|
def confirm
|
41
41
|
UI.say("Are you sure you want to update the environment with your the new config #{@config_path}?".colorize(:yellow))
|
42
42
|
UI.say(<<-EOL)
|
43
|
-
If the difference is not what you expected, you should say no.
|
44
|
-
A blank newline indicates that there was no difference.
|
45
|
-
If you want to download the config from the environment and
|
43
|
+
If the difference is not what you expected, you should say no.
|
44
|
+
A blank newline indicates that there was no difference.
|
45
|
+
If you want to download the config from the environment and
|
46
46
|
overwrite your #{@local_config_path} instead, you can use this command:
|
47
47
|
$ jack config download #{@env_name}
|
48
48
|
$ jack config help download # for more info
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "yaml"
|
2
2
|
|
3
3
|
module Jack
|
4
|
-
|
4
|
+
class Config < Thor
|
5
5
|
# Class does very specific formatting for the eb config files:
|
6
6
|
#
|
7
7
|
# * Makes sure that the keys are sorted so we can compare them
|
@@ -11,7 +11,9 @@ module Jack
|
|
11
11
|
data = YAML.load_file(file)
|
12
12
|
data = strip_metadata_dates(data)
|
13
13
|
dump = YAML.dump(data).gsub("!ruby/object:Hash", '')
|
14
|
-
|
14
|
+
lines = dump.split("\n")
|
15
|
+
lines = lines.map { |l| l.rstrip } # strip trailing whitespace
|
16
|
+
dump = lines[1..-1].join("\n") + "\n" # strip first line
|
15
17
|
outfile = "#{file}.sorted"
|
16
18
|
File.open(outfile, 'w') { |f| f.write(dump) }
|
17
19
|
FileUtils.mv(outfile, file)
|
@@ -27,4 +29,4 @@ module Jack
|
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
30
|
-
end
|
32
|
+
end
|
data/lib/jack/settings.rb
CHANGED
data/lib/jack/version.rb
CHANGED
File without changes
|
data/spec/lib/cli_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Jack::CLI do
|
4
4
|
before(:all) do
|
5
|
-
@args = "
|
5
|
+
@args = "hi-web-stag-1 --root spec/fixtures/project --noop --force"
|
6
6
|
FileUtils.rm_rf("spec/fixtures/project/.elasticbeanstalk")
|
7
7
|
end
|
8
8
|
|
@@ -11,10 +11,9 @@ describe Jack::CLI do
|
|
11
11
|
out = execute("bin/jack create #{@args}")
|
12
12
|
# puts out
|
13
13
|
expect(out).to include('eb create')
|
14
|
-
expect(out).to include('--cname
|
14
|
+
expect(out).to include('--cname hi-web-stag-1')
|
15
15
|
expect(out).to include('--keyname "default"')
|
16
|
-
expect(out).to include('
|
17
|
-
expect(out).to include('stag-rails-app-s9')
|
16
|
+
expect(out).to include('hi-web-stag-1')
|
18
17
|
end
|
19
18
|
|
20
19
|
it "should upload and apply config to environment" do
|
@@ -41,4 +40,4 @@ describe Jack::CLI do
|
|
41
40
|
expect(out).to include("Reformatted the local config")
|
42
41
|
end
|
43
42
|
end
|
44
|
-
end
|
43
|
+
end
|
data/spec/lib/create_spec.rb
CHANGED
@@ -11,10 +11,10 @@ describe Jack::Create do
|
|
11
11
|
command = @create.build_command
|
12
12
|
# puts "command = #{command }"
|
13
13
|
expect(command).to include('eb create')
|
14
|
-
expect(command).to include('--cname
|
14
|
+
expect(command).to include('--cname hi-web-stag-1')
|
15
15
|
expect(command).to include('--keyname "default"')
|
16
|
-
expect(command).to include('--cfg stag-
|
17
|
-
expect(command).to include('
|
16
|
+
expect(command).to include('--cfg hi-web-stag-1')
|
17
|
+
expect(command).to include('hi-web-stag-1')
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -7,9 +7,9 @@ describe Jack::EbConfig do
|
|
7
7
|
|
8
8
|
def solution_stacks
|
9
9
|
[
|
10
|
-
"64bit Amazon Linux 2015.03 v1.4.6 running Docker 1.6.2",
|
11
10
|
"64bit Amazon Linux 2015.09 v2.0.6 running Docker 1.7.1",
|
12
11
|
"64bit Amazon Linux 2016.03 v2.1.0 running Docker 1.9.1",
|
12
|
+
"64bit Amazon Linux 2016.09 v2.2.0 running Docker 1.11.2",
|
13
13
|
"64bit Debian jessie v2.1.0 running GlassFish 4.1 Java 8 (Preconfigured - Docker)",
|
14
14
|
"64bit Amazon Linux 2015.03 v1.4.6 running Multi-container Docker 1.6.2 (Generic)"
|
15
15
|
]
|
@@ -18,7 +18,7 @@ describe Jack::EbConfig do
|
|
18
18
|
let(:create) do
|
19
19
|
Jack::EbConfig::Create.new(test_options(env_name))
|
20
20
|
end
|
21
|
-
let(:env_name) { "
|
21
|
+
let(:env_name) { "hi-web-stag-1" }
|
22
22
|
|
23
23
|
describe "Create#sync" do
|
24
24
|
context "default platform from default settings" do
|
@@ -27,13 +27,13 @@ describe Jack::EbConfig do
|
|
27
27
|
|
28
28
|
data = YAML.load_file(create.eb_config_path)
|
29
29
|
global = data['global']
|
30
|
-
expect(global['application_name']).to eq "
|
31
|
-
expect(global['default_platform']).to eq "64bit Amazon Linux
|
30
|
+
expect(global['application_name']).to eq "hi"
|
31
|
+
expect(global['default_platform']).to eq "64bit Amazon Linux 2016.09 v2.2.0 running Docker 1.11.2"
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
context "different platform from project settings" do
|
36
|
-
let(:env_name) { "
|
36
|
+
let(:env_name) { "hi-web-stag-1" }
|
37
37
|
|
38
38
|
before(:each) { fake_project.create_settings }
|
39
39
|
after(:each) { fake_project.remove_settings }
|
@@ -42,7 +42,7 @@ describe Jack::EbConfig do
|
|
42
42
|
|
43
43
|
data = YAML.load_file(create.eb_config_path)
|
44
44
|
global = data['global']
|
45
|
-
expect(global['application_name']).to eq "
|
45
|
+
expect(global['application_name']).to eq "hi"
|
46
46
|
expect(global['default_platform']).to eq "Fake Platform From Project Settings"
|
47
47
|
end
|
48
48
|
end
|
@@ -51,7 +51,7 @@ describe Jack::EbConfig do
|
|
51
51
|
# aws elasticbeanstalk list-available-solution-stacks | jq '.SolutionStacks' | grep Docker
|
52
52
|
it "list solution stacks" do
|
53
53
|
expect(create).to receive(:solution_stacks).and_return(solution_stacks)
|
54
|
-
expect(create.latest_docker_platform).to eq "64bit Amazon Linux 2016.
|
54
|
+
expect(create.latest_docker_platform).to eq "64bit Amazon Linux 2016.09 v2.2.0 running Docker 1.11.2"
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
data/spec/lib/settings_spec.rb
CHANGED
@@ -20,7 +20,7 @@ describe Jack::Settings do
|
|
20
20
|
|
21
21
|
context "no custom project settings" do
|
22
22
|
it "flags uses defaults provided gem" do
|
23
|
-
project_flags = '--keyname "default" --platform "64bit Amazon Linux
|
23
|
+
project_flags = '--keyname "default" --platform "64bit Amazon Linux 2016.09 v2.2.0 running Docker 1.11.2"'
|
24
24
|
expect(settings.create_flags).to eq(project_flags)
|
25
25
|
end
|
26
26
|
end
|
data/spec/lib/util_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -6,7 +6,7 @@ CodeClimate::TestReporter.start
|
|
6
6
|
require "pp"
|
7
7
|
require 'ostruct'
|
8
8
|
require 'pry'
|
9
|
-
|
9
|
+
|
10
10
|
root = File.expand_path('../../', __FILE__)
|
11
11
|
require "#{root}/lib/jack"
|
12
12
|
|
@@ -20,7 +20,7 @@ module Helpers
|
|
20
20
|
out
|
21
21
|
end
|
22
22
|
|
23
|
-
def test_options(env_name="
|
23
|
+
def test_options(env_name="hi-web-stag-1")
|
24
24
|
{
|
25
25
|
noop: true,
|
26
26
|
mute: true,
|
@@ -5,7 +5,7 @@ class FakeProject
|
|
5
5
|
|
6
6
|
def create_eb_config
|
7
7
|
data = <<-EOL
|
8
|
-
---
|
8
|
+
---
|
9
9
|
global:
|
10
10
|
application_name: blah
|
11
11
|
default_platform: 64bit Amazon Linux 2014.09 v1.2.0 running Docker 1.3.3
|
@@ -20,7 +20,7 @@ create:
|
|
20
20
|
keyname: default
|
21
21
|
platform: "Fake Platform From Project Settings"
|
22
22
|
conventions:
|
23
|
-
app_name_pattern: (\\w+)-\\w+-\\w
|
23
|
+
app_name_pattern: !ruby/regexp /(\\w+)-\\w+-\\w+/
|
24
24
|
EOL
|
25
25
|
# really tricky but when writting yaml file like this the \ needs to be escaped
|
26
26
|
# when writing the yaml file normal, they do not need to be escaped
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jack-eb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- ".gitignore"
|
148
148
|
- ".rspec"
|
149
149
|
- ".travis.yml"
|
150
|
+
- CHANGELOG.md
|
150
151
|
- Gemfile
|
151
152
|
- Guardfile
|
152
153
|
- LICENSE.txt
|
@@ -176,7 +177,7 @@ files:
|
|
176
177
|
- lib/jack/util.rb
|
177
178
|
- lib/jack/version.rb
|
178
179
|
- lib/jack/version_checker.rb
|
179
|
-
- spec/fixtures/project/jack/cfg/
|
180
|
+
- spec/fixtures/project/jack/cfg/hi-web-stag-1.cfg.yml
|
180
181
|
- spec/lib/cli_spec.rb
|
181
182
|
- spec/lib/config/diff_spec.rb
|
182
183
|
- spec/lib/config/download_spec.rb
|
@@ -213,12 +214,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
214
|
version: '0'
|
214
215
|
requirements: []
|
215
216
|
rubyforge_project:
|
216
|
-
rubygems_version: 2.
|
217
|
+
rubygems_version: 2.5.2
|
217
218
|
signing_key:
|
218
219
|
specification_version: 4
|
219
220
|
summary: Wrapper tool to manage AWS Elastic Beanstalk environments
|
220
221
|
test_files:
|
221
|
-
- spec/fixtures/project/jack/cfg/
|
222
|
+
- spec/fixtures/project/jack/cfg/hi-web-stag-1.cfg.yml
|
222
223
|
- spec/lib/cli_spec.rb
|
223
224
|
- spec/lib/config/diff_spec.rb
|
224
225
|
- spec/lib/config/download_spec.rb
|
@@ -235,4 +236,3 @@ test_files:
|
|
235
236
|
- spec/lib/verison_checker_spec.rb
|
236
237
|
- spec/spec_helper.rb
|
237
238
|
- spec/support/fake_project.rb
|
238
|
-
has_rdoc:
|