ey-core 3.4.2 → 3.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +5 -5
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +1 -0
  4. data/CHANGELOG.md +27 -5
  5. data/Gemfile +1 -2
  6. data/README.md +65 -8
  7. data/ey-core.gemspec +6 -5
  8. data/features/docker_registry_credentials.feature +21 -0
  9. data/features/environment_variables.feature +54 -0
  10. data/features/step_definitions/accounts_steps.rb +14 -0
  11. data/features/step_definitions/applications_steps.rb +7 -14
  12. data/features/step_definitions/docker_registry_credentials_steps.rb +3 -0
  13. data/features/step_definitions/environment_variables_steps.rb +51 -0
  14. data/features/step_definitions/environments_steps.rb +15 -0
  15. data/features/support/environment_variable_helpers.rb +20 -0
  16. data/features/support/mock_api.rb +0 -1
  17. data/features/support/resource_helpers.rb +12 -0
  18. data/lib/ey-core/cli/deploy.rb +14 -11
  19. data/lib/ey-core/cli/docker_registry_login.rb +29 -0
  20. data/lib/ey-core/cli/environment_variables.rb +71 -0
  21. data/lib/ey-core/cli/helpers/chef.rb +1 -1
  22. data/lib/ey-core/cli/helpers/core.rb +32 -3
  23. data/lib/ey-core/cli/helpers/server_sieve.rb +7 -0
  24. data/lib/ey-core/cli/main.rb +5 -4
  25. data/lib/ey-core/cli/servers.rb +35 -17
  26. data/lib/ey-core/cli/ssh.rb +7 -1
  27. data/lib/ey-core/client/mock.rb +5 -0
  28. data/lib/ey-core/client.rb +35 -0
  29. data/lib/ey-core/collections/auto_scaling_alarms.rb +8 -0
  30. data/lib/ey-core/collections/auto_scaling_groups.rb +8 -0
  31. data/lib/ey-core/collections/auto_scaling_policies.rb +33 -0
  32. data/lib/ey-core/collections/container_clusters.rb +9 -0
  33. data/lib/ey-core/collections/container_service_deployments.rb +17 -0
  34. data/lib/ey-core/collections/environment_variables.rb +8 -0
  35. data/lib/ey-core/collections/servers.rb +4 -0
  36. data/lib/ey-core/models/account.rb +10 -0
  37. data/lib/ey-core/models/address.rb +2 -0
  38. data/lib/ey-core/models/application.rb +1 -0
  39. data/lib/ey-core/models/auto_scaling_alarm.rb +54 -0
  40. data/lib/ey-core/models/auto_scaling_group.rb +75 -0
  41. data/lib/ey-core/models/base_auto_scaling_policy.rb +61 -0
  42. data/lib/ey-core/models/container_service_deployment.rb +17 -0
  43. data/lib/ey-core/models/deployment.rb +1 -0
  44. data/lib/ey-core/models/environment.rb +57 -45
  45. data/lib/ey-core/models/environment_variable.rb +29 -0
  46. data/lib/ey-core/models/request.rb +6 -0
  47. data/lib/ey-core/models/server.rb +2 -0
  48. data/lib/ey-core/models/simple_auto_scaling_policy.rb +24 -0
  49. data/lib/ey-core/models/step_auto_scaling_policy.rb +24 -0
  50. data/lib/ey-core/models/target_auto_scaling_policy.rb +24 -0
  51. data/lib/ey-core/requests/create_account.rb +5 -0
  52. data/lib/ey-core/requests/create_address.rb +1 -0
  53. data/lib/ey-core/requests/create_application.rb +8 -7
  54. data/lib/ey-core/requests/create_auto_scaling_alarm.rb +69 -0
  55. data/lib/ey-core/requests/create_auto_scaling_group.rb +62 -0
  56. data/lib/ey-core/requests/create_auto_scaling_policy.rb +68 -0
  57. data/lib/ey-core/requests/create_environment.rb +2 -0
  58. data/lib/ey-core/requests/create_environment_variable.rb +39 -0
  59. data/lib/ey-core/requests/create_user.rb +8 -6
  60. data/lib/ey-core/requests/deploy_environment_application.rb +1 -0
  61. data/lib/ey-core/requests/destroy_auto_scaling_alarm.rb +49 -0
  62. data/lib/ey-core/requests/destroy_auto_scaling_group.rb +44 -0
  63. data/lib/ey-core/requests/destroy_auto_scaling_policy.rb +49 -0
  64. data/lib/ey-core/requests/discover_container_service_deployments.rb +71 -0
  65. data/lib/ey-core/requests/discover_server.rb +60 -0
  66. data/lib/ey-core/requests/get_applications.rb +1 -1
  67. data/lib/ey-core/requests/get_auto_scaling_alarm.rb +27 -0
  68. data/lib/ey-core/requests/get_auto_scaling_alarms.rb +34 -0
  69. data/lib/ey-core/requests/get_auto_scaling_group.rb +21 -0
  70. data/lib/ey-core/requests/get_auto_scaling_groups.rb +29 -0
  71. data/lib/ey-core/requests/get_auto_scaling_policies.rb +46 -0
  72. data/lib/ey-core/requests/get_auto_scaling_policy.rb +27 -0
  73. data/lib/ey-core/requests/get_deployments.rb +1 -1
  74. data/lib/ey-core/requests/get_environment_variable.rb +19 -0
  75. data/lib/ey-core/requests/get_environment_variables.rb +29 -0
  76. data/lib/ey-core/requests/get_environments.rb +1 -1
  77. data/lib/ey-core/requests/get_ssl_certificate.rb +1 -1
  78. data/lib/ey-core/requests/retrieve_docker_registry_credentials.rb +24 -0
  79. data/lib/ey-core/requests/update_auto_scaling_alarm.rb +45 -0
  80. data/lib/ey-core/requests/update_auto_scaling_group.rb +45 -0
  81. data/lib/ey-core/requests/update_auto_scaling_policy.rb +46 -0
  82. data/lib/ey-core/requests/update_environment_variable.rb +25 -0
  83. data/lib/ey-core/test_helpers/auto_scaling_helpers.rb +35 -0
  84. data/lib/ey-core/test_helpers.rb +2 -0
  85. data/lib/ey-core/version.rb +1 -1
  86. data/spec/addresses_spec.rb +2 -1
  87. data/spec/auto_scaling_alarms_spec.rb +40 -0
  88. data/spec/auto_scaling_groups_spec.rb +28 -0
  89. data/spec/auto_scaling_policies_spec.rb +94 -0
  90. data/spec/docker_registry_credentials_spec.rb +16 -0
  91. data/spec/environments_spec.rb +18 -0
  92. data/spec/servers_spec.rb +8 -0
  93. data/spec/spec_helper.rb +7 -0
  94. data/spec/support/core.rb +0 -2
  95. metadata +88 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: eefaa4fc0fdde7b371d8ebec9b314466876b1c5d
4
- data.tar.gz: a23eff0e443e2b03b72dea834bc33c1637ab274e
2
+ SHA256:
3
+ metadata.gz: 301123fdb0da2d489face06c5ff98f5a7468c87567931d6bf3a7a9c5487d7d76
4
+ data.tar.gz: cf368989a95109d155d2e6594a52dc4e49f4c8791fbc8a1a63cd6e749cbf8c1d
5
5
  SHA512:
6
- metadata.gz: 7f67364760735bd280125001c9b011f081be7feb3e1ebf76c0b9872f8938307ba4d01c50b481d1a38f7ab017741fbbdd817c69dfc65c5e753244761bd5b4416f
7
- data.tar.gz: 8942c9a5e4edd04d67193c2ec6adc5987ebe21564bc07541632712ae3cd7a9ce0bfec4cda7fa9056df7906bead3257915ba7f9977da9195d413a0944a6f46fa0
6
+ metadata.gz: ddaf5291676659eb5f0dc2cac60ff76320c3af82eb1fd3bc40cac4ec01ceb18ba8b549da610be189ef69110d010b9c3ec5d1d3f7d4728d9f1dc20ee3eb4bc37a
7
+ data.tar.gz: 01c05f180816f015752983109e27ac01e9b9e3f9826a29524754fb728b1b85ebf2099e1cd757600b35ae22129d1b9000ebb44ca39a44275548caa317254fddc7
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 1.9.3
1
+ 2.5.8
data/.travis.yml CHANGED
@@ -15,6 +15,7 @@ cache: bundler
15
15
  rvm:
16
16
  - 2.2.2
17
17
  - 2.3.1
18
+ - 2.4.2
18
19
 
19
20
  env:
20
21
  - COVERAGE=true
data/CHANGELOG.md CHANGED
@@ -1,13 +1,35 @@
1
1
  # Change Log
2
2
 
3
- ## [Unreleased](https://github.com/engineyard/core-client-rb/tree/HEAD)
3
+ ## [Unreleased](https://github.com/engineyard/core-client-rb/tree/develop)
4
4
 
5
- [Full Changelog](https://github.com/engineyard/core-client-rb/compare/v2.8.4...HEAD)
5
+ [Full Changelog](https://github.com/engineyard/core-client-rb/compare/v3.6.1...develop)
6
6
 
7
7
  **Merged pull requests:**
8
8
 
9
- - \[ENG-193\] Create untracked addresses via smithy [\#34](https://github.com/engineyard/core-client-rb/pull/34) ([omgitsads](https://github.com/omgitsads))
10
- - remove usage of hmac client in specs [\#33](https://github.com/engineyard/core-client-rb/pull/33) ([lanej](https://github.com/lanej))
9
+ ## [v3.6.1](https://github.com/engineyard/core-client-rb/tree/v3.6.1) (2020-06-11)
10
+
11
+ [Full Changelog](https://github.com/engineyard/core-client-rb/compare/v3.5.0...v3.6.1)
12
+
13
+ **Merged pull requests:**
14
+
15
+ - Adds support for Docker credentials [\#106](https://github.com/engineyard/core-client-rb/pull/106) ([nodecarter](https://github.com/nodecarter))
16
+ - Adds support for container discovery [\#107](https://github.com/engineyard/core-client-rb/pull/107) ([thorn](https://github.com/thorn))
17
+ - Fixes `get_deployment` request parameters [\#108](https://github.com/engineyard/core-client-rb/pull/108) ([lucis-fluxum](https://github.com/lucis-fluxum))
18
+ - Adds server names to server list output [\#112](https://github.com/engineyard/core-client-rb/pull/112) ([glennr](https://github.com/glennr))
19
+ - Fixes the `--no-migrate` flag for `ey-core deploy` [\#114](https://github.com/engineyard/core-client-rb/pull/114) ([mushyy](https://github.com/mushyy))
20
+ - Upgrades dependencies and adds ruby-2.7 support for the gem [\#120](https://github.com/engineyard/core-client-rb/pull/120) ([ssuttner](https://github.com/ssuttner))
21
+ - Adds a bit of CLI documentation [\#121](https://github.com/engineyard/core-client-rb/pull/121) ([ess](https://github.com/ess))
22
+
23
+ ## [v3.5.0](https://github.com/engineyard/core-client-rb/tree/v3.5.0) (2018-04-04)
24
+ [Full Changelog](https://github.com/engineyard/core-client-rb/compare/v3.4.4...v3.5.0)
25
+
26
+ **Merged pull requests:**
27
+
28
+ - Add support for autoscaling policies [\#110](https://github.com/engineyard/core-client-rb/pull/101) ([thorn](https://github.com/thorn))
29
+ - Add support for environment variables [\#90](https://github.com/engineyard/core-client-rb/pull/90) ([rzaharenkov](https://github.com/rzaharenkov))
30
+ - Add ability to send configuration options together with blueprint [\#104](https://github.com/engineyard/core-client-rb/pull/104) ([ramonpm](https://github.com/ramonpm))
31
+ - Add support for address.scope parameter for EIP [\#102](https://github.com/engineyard/core-client-rb/pull/102) ([thorn](https://github.com/thorn))
32
+ - Various fixes for `servers` command [\#103](https://github.com/engineyard/core-client-rb/pull/103) ([binarypaladin](https://github.com/binarypaladin))
11
33
 
12
34
  ## [v2.8.4](https://github.com/engineyard/core-client-rb/tree/v2.8.4) (2015-08-12)
13
35
  [Full Changelog](https://github.com/engineyard/core-client-rb/compare/v2.8.3...v2.8.4)
@@ -164,4 +186,4 @@
164
186
 
165
187
 
166
188
 
167
- \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
189
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in ey-core.gemspec
4
4
  gemspec
5
5
 
6
- gem "rack", "<= 2.0"
6
+ gem "rack", "<= 2.1.4"
7
7
 
8
8
  group :doc do
9
9
  gem 'yard'
@@ -13,7 +13,6 @@ end
13
13
  group :test do
14
14
  gem 'codeclimate-test-reporter', '~> 0.3'
15
15
  gem 'faker'
16
- gem 'hashie'
17
16
  gem 'rack-test'
18
17
  gem 'rspec', '~> 3.1'
19
18
  gem 'simplecov'
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Ey::Core
1
+ # Ey::Core #
2
2
 
3
- Official Ruby Engine Yard Core API Client.
3
+ Official Engine Yard Core API Ruby client and CLI utility.
4
4
 
5
- ## Installation
5
+ ## Installation ##
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
@@ -12,11 +12,68 @@ And then execute:
12
12
 
13
13
  $ bundle
14
14
 
15
- Or install it yourself as:
15
+ Or install it yourself for ad-hoc or CLI usage:
16
16
 
17
17
  $ gem install ey-core
18
18
 
19
- ## Usage
19
+ ## Usage ##
20
+
21
+ There are two ways to use this gem: you can install it to use as a client library for writing your own Engine Yard Cloud integrations, or you can use the `ey-core` CLi app to use our curated integrations.
22
+
23
+ ### CLI Usage ###
24
+
25
+ The CLI app, `ey-core`, is the replacement for the `ey` command that was provided by the now mostly deprecated`engineyard` gem. The old gem is still updated as need be, but is effectively just a slightly different UI for the `ey-core` command.
26
+ Like the `git` command, `ey-core` is like a gateway to other commands.
27
+
28
+ Rather than attempting to provide an exhaustive writeup of all of the commands provided by `ey-core`, this document will instead describe what are likely the most common use cases and leave you to read up on the remainder via the `help` command.
29
+
30
+ #### Use Case: Getting Help ####
31
+
32
+ Arguably the most important command in the app is `ey-core help`. Given no arguments, it provides the list of second-level commands avaiable for use. From that point, each argument is expected to be a command from the next level of the hierarchy.
33
+
34
+ For example, if one wishes to learn about the `servers` second-level command, they would do `ey-core help servers`.
35
+
36
+ For commands in even deeper levels, one just adds each level of chain after the `help` command. Try this in your terminal: `ey-core help recipes apply`
37
+
38
+ #### Use Case: Deploying An App ####
39
+
40
+ The `ey-core deploy` command allows one to deploy a new revision of an existing application in an existing environment. The command itself has several options, some of which may or may not be required depending on several factors. To guarantee the best result and remove a good deal of uncertainty in the process, we've opted to describe a somewhat verbose invocation of the command in this document.
41
+
42
+ Let's start with some assumptions:
43
+
44
+ * The name of our Engine Yard account is `MyAwesomeCompany` (you can get a real account name with `ey-core accounts`)
45
+ * That account has an environment named `awesome_production` (you can get a real environment name with `ey-core environments`)
46
+ * That account has an application named `awesome_app` (you can get a real application name with `ey-core applications`)
47
+ * The aforementioned application is already associated with the environment
48
+
49
+ As mentioned, some of the options for the `deploy` command are optional, and all of the topics discussed in our assumptions are effectively optional. That said, we suggest specifying *all* of these options to ensure absolutely that the proper application is deployed to the proper environment in the proper account.
50
+
51
+ All that said, to deploy the application to its latest git ref and the same migration command as the last deployment, you would issue the following command:
52
+
53
+ `$ ey-core deploy --account MyAwesomeCompany --environment awesome_production --app awesome_app`
54
+
55
+ You can also specify a git ref to use if you'd like to deploy a specific version or branch of the app:
56
+
57
+ `$ ey-core deploy --account MyAwesomeCompany --environment awesome_production --app awesome_app --ref feature/new-ui`
58
+
59
+ Say that you want to change the way your migrations are run during the deploy. You can specify the migration command:
60
+
61
+ `$ ey-core deploy --account MyAwesomeCompany --environment awesome_production --app awesome_app --migrate 'bundle exec rake db:migrate:new_hotness'`
62
+
63
+ Additionally, if you wish to skip migrations for the deployment, you can do that, too:
64
+
65
+ `$ ey-core deploy --account MyAwesomeCompany --environment awesome_production --app awesome_app --no-migrate`
66
+
67
+ Any of the invocations that we've talked about so far will stream the deployment log as it runs. If you'd rather do a fire-and-forget style deployment and check in on it later, you can add the `--no-wait` flag. If, however, you'd like to see even more information spit out during the deploy, you can add the `--verbose` flag.
68
+
69
+ That's about all there is to deployment so long as you consider the application, environment, and account to be required options. You can read more about any of the commands that we've mentioned in this use case by running the following in your terminal:
70
+
71
+ * `ey-core help accounts`
72
+ * `ey-core help applications`
73
+ * `ey-core help deploy`
74
+ * `ey-core help environments`
75
+
76
+ ### Client Library Usage ###
20
77
 
21
78
  Uses [cistern](https://github.com/lanej/cistern) to wrap RESTful resources nicely.
22
79
 
@@ -30,7 +87,7 @@ client.users.current # =>
30
87
  >
31
88
  ```
32
89
 
33
- ### Authentication
90
+ #### Authentication ####
34
91
 
35
92
  * Via Token
36
93
 
@@ -48,7 +105,7 @@ Ey::Core::Client.new(
48
105
  )
49
106
  ```
50
107
 
51
- ### Mock
108
+ #### Mock ####
52
109
 
53
110
  Mock is disabled by default.
54
111
 
@@ -64,7 +121,7 @@ Reset the mock
64
121
  Ey::Core::Client.reset!
65
122
  ```
66
123
 
67
- ### Testing
124
+ #### Testing ####
68
125
 
69
126
  By default, specs are run against the core mock. In order to run them against awsm mocked mode instead, run `MOCK_CORE=false bundle exec rspec`
70
127
 
data/ey-core.gemspec CHANGED
@@ -18,22 +18,23 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
  gem.licenses = ["MIT"]
20
20
 
21
- gem.required_ruby_version = ">= 2.2.2"
21
+ gem.required_ruby_version = ">= 2.5"
22
22
 
23
23
  gem.add_dependency "addressable"
24
24
 
25
- gem.add_dependency "awesome_print"
25
+ gem.add_dependency "amazing_print", "~> 1.1.0"
26
26
  gem.add_dependency "belafonte"
27
27
  gem.add_dependency "cistern", "~> 0.12.3"
28
28
  gem.add_dependency "colorize"
29
29
  gem.add_dependency "ey-hmac", "~> 2.0"
30
30
  gem.add_dependency "escape"
31
- gem.add_dependency "faraday", "~> 0.9"
32
- gem.add_dependency "faraday_middleware", "~> 0.9"
31
+ gem.add_dependency "hashie", "~> 4.1.0"
32
+ gem.add_dependency "faraday", "~> 1.0.1"
33
+ gem.add_dependency "faraday_middleware", "~> 1.0.0"
33
34
  gem.add_dependency "rack"
34
35
  gem.add_dependency "faye"
35
36
  gem.add_dependency "highline"
36
- gem.add_dependency "json", "< 2.0"
37
+ gem.add_dependency "json", "~> 2.3.0"
37
38
  gem.add_dependency "mime-types"
38
39
  gem.add_dependency "oj"
39
40
  gem.add_dependency "oj_mimic_json"
@@ -0,0 +1,21 @@
1
+ Feature: Docker Registry Credentials
2
+ In order to authorize the Docker Engine with the AWS ECR registry
3
+ As a User
4
+ I want to be able to retrieve the Docker authorization credentials
5
+
6
+ Background:
7
+ Given I'm an Engine Yard user
8
+ And ey-core is configured with my cloud token
9
+ And I have the following accounts:
10
+ | Account Name |
11
+ | one |
12
+ | two |
13
+
14
+ Scenario Outline: Retrieving Docker authorization credentials
15
+ When I run `ey-core get-docker-registry-login <Account Flag> one <Location Flag> us-east-1`
16
+ Then I see the docker login command
17
+
18
+ Examples:
19
+ | Account Flag | Location Flag |
20
+ | -c | -l |
21
+ | --account | --location |
@@ -0,0 +1,54 @@
1
+ Feature: Environment Variables
2
+ In order to know current values of environment variables assigned to my Engine Yard environments
3
+ As a User
4
+ I want to be able to list the environment variables for environments which I'm associated
5
+
6
+ Background:
7
+ Given I'm an Engine Yard user
8
+ And ey-core is configured with my cloud token
9
+ And I have the following accounts:
10
+ | Account Name |
11
+ | one |
12
+ | two |
13
+ | three |
14
+ And I have the following applications:
15
+ | Account Name | Application Name |
16
+ | one | blog_app |
17
+ | two | todo_app |
18
+ And I have the following environments:
19
+ | Application Name | Environment Name |
20
+ | blog_app | staging |
21
+ | blog_app | production |
22
+ | todo_app | staging |
23
+ And I have the following environment variables:
24
+ | Name | Value | Application Name | Environment Name | Sensitive |
25
+ | SECRET_BASE | abc= | blog_app | staging | false |
26
+ | DB_PASSWORD | 123qweasd!! | blog_app | staging | true |
27
+ | SECRET_BASE | qwe= | blog_app | production | false |
28
+ | DB_PASSWORD | 987qweasd!! | blog_app | production | true |
29
+ | DB_PASSWORD | my_secure_password | todo_app | staging | true |
30
+
31
+ Scenario: Listing all of my environment variables
32
+ When I run `ey-core environment_variables`
33
+ Then I see the name and value for all of my environments as well as name of associated environment and application
34
+
35
+ Scenario Outline: Listing environment variables for a specific environment
36
+ When I run `ey-core environment_variables <Environment Flag> staging`
37
+ Then I see the environment variables associated with `staging` environment
38
+ But I do not see environment variables associated with any other environments different from `staging`
39
+
40
+ Examples:
41
+ | Environment Flag |
42
+ | -e |
43
+ | --environment |
44
+
45
+ Scenario Outline: Listing environment variables for a specific application
46
+ When I run `ey-core environment_variables <Application Flag> blog_app`
47
+ Then I see the environment variables associated with `blog_app` application
48
+ But I do not see environment variables associated with any other applications different from `blog_app`
49
+
50
+ Examples:
51
+ | Application Flag |
52
+ | -a |
53
+ | --application |
54
+
@@ -15,6 +15,20 @@ Given %(I'm associated with several accounts) do
15
15
  memorize_fact(:accounts, [account1, account2])
16
16
  end
17
17
 
18
+ Given %r(^I have the following accounts:$) do |account_names|
19
+ account_names.hashes.each do |account_hash|
20
+ known_accounts.push(
21
+ create_account(
22
+ client: client,
23
+ owner: current_user,
24
+ account: {
25
+ name: account_hash['Account Name']
26
+ }
27
+ )
28
+ )
29
+ end
30
+ end
31
+
18
32
  Then %(I see the name and ID of each of my accounts) do
19
33
  recall_fact(:accounts).each do |account|
20
34
  expect(output_text).to include(account.id)
@@ -1,17 +1,3 @@
1
- Given %r(^I have the following accounts:$) do |account_names|
2
- account_names.hashes.each do |account_hash|
3
- known_accounts.push(
4
- create_account(
5
- client: client,
6
- owner: current_user,
7
- account: {
8
- name: account_hash['Account Name']
9
- }
10
- )
11
- )
12
- end
13
- end
14
-
15
1
  Given %(each of my accounts has several applications) do
16
2
  known_accounts.each do |account|
17
3
  known_apps.push(
@@ -24,6 +10,13 @@ Given %(each of my accounts has several applications) do
24
10
  end
25
11
  end
26
12
 
13
+ Given(/^I have the following applications:$/) do |applications|
14
+ applications.hashes.each do |application_hash|
15
+ account = known_accounts.find { |acc| acc.name == application_hash['Account Name'] }
16
+ known_apps.push(create_application(account: account, name: application_hash['Application Name']))
17
+ end
18
+ end
19
+
27
20
  Then %(I see the name and ID for all of my applications) do
28
21
  known_apps.each do |app|
29
22
  expect(output_text).to match(/#{Regexp.escape(app.id.to_s)}\s+\|\s+#{Regexp.escape(app.name)}/)
@@ -0,0 +1,3 @@
1
+ Then %(I see the docker login command) do
2
+ expect(output_text).to match("docker login -u foo -p bar https://012345678901.dkr.ecr.us-east-1.amazonaws.com")
3
+ end
@@ -0,0 +1,51 @@
1
+ Given(/^I have the following environment variables:$/) do |variables|
2
+ variables.hashes.each do |variable_hash|
3
+ application = known_apps.find { |app| app.name == variable_hash['Application Name'] }
4
+ environment = known_environments.find { |env| env.name == variable_hash['Environment Name'] }
5
+ known_environment_variables.push(
6
+ create_environment_variable(
7
+ application: application,
8
+ environment: environment,
9
+ environment_variable: {
10
+ name: variable_hash['Name'],
11
+ value: variable_hash['Value'],
12
+ sensitive: variable_hash['Sensitive']
13
+ }
14
+ )
15
+ )
16
+ end
17
+ end
18
+
19
+ Then(/^I see the name and value for all of my environments as well as name of associated environment and application$/) do
20
+ known_environment_variables.each do |environment_variable|
21
+ expect(output_text).to match(match_environment_variable_regexp(environment_variable))
22
+ end
23
+ end
24
+
25
+ Then(/^I see the environment variables associated with `(\w+)` environment$/) do |environment_name|
26
+ known_environment_variables.each do |environment_variable|
27
+ next unless environment_variable.environment_name == environment_name
28
+ expect(output_text).to match(match_environment_variable_regexp(environment_variable))
29
+ end
30
+ end
31
+
32
+ Then(/^I do not see environment variables associated with any other environments different from `(\w+)`$/) do |environment_name|
33
+ known_environment_variables.each do |environment_variable|
34
+ next if environment_variable.environment_name == environment_name
35
+ expect(output_text).not_to match(match_environment_variable_regexp(environment_variable))
36
+ end
37
+ end
38
+
39
+ Then(/^I see the environment variables associated with `(\w+)` application$/) do |application_name|
40
+ known_environment_variables.each do |environment_variable|
41
+ next unless environment_variable.application_name == application_name
42
+ expect(output_text).to match(match_environment_variable_regexp(environment_variable))
43
+ end
44
+ end
45
+
46
+ Then(/^I do not see environment variables associated with any other applications different from `(\w+)`$/) do |application_name|
47
+ known_environment_variables.each do |environment_variable|
48
+ next if environment_variable.application_name == application_name
49
+ expect(output_text).not_to match(match_environment_variable_regexp(environment_variable))
50
+ end
51
+ end
@@ -14,6 +14,21 @@ Given %(each of my applications has an environment) do
14
14
  end
15
15
  end
16
16
 
17
+ Given(/^I have the following environments:$/) do |environments|
18
+ environments.hashes.each do |environment_hash|
19
+ application = known_apps.find { |app| app.name == environment_hash['Application Name'] }
20
+ known_environments.push(
21
+ create_environment(
22
+ account: application.account,
23
+ application: application,
24
+ environment: {
25
+ name: environment_hash['Environment Name']
26
+ }
27
+ )
28
+ )
29
+ end
30
+ end
31
+
17
32
  Then %(I see the name and ID for all of my environments) do
18
33
  known_environments.each do |environment|
19
34
  expect(output_text).to match(/#{Regexp.escape(environment.id.to_s)}\s+\|\s+#{Regexp.escape(environment.name)}/)
@@ -0,0 +1,20 @@
1
+ module EnvironmentVariableHelpers
2
+ ENVIRONMENT_VARIABLE_DISPLAY_FIELDS = %i[id name value environment_name application_name]
3
+
4
+ def known_environment_variables
5
+ begin
6
+ recall_fact(:environment_variables)
7
+ rescue
8
+ memorize_fact(:environment_variables, [])
9
+ end
10
+ end
11
+
12
+ def match_environment_variable_regexp(environment_variable)
13
+ regexp_parts = ENVIRONMENT_VARIABLE_DISPLAY_FIELDS.map do |field|
14
+ Regexp.escape(environment_variable.send(field).to_s)
15
+ end
16
+ Regexp.new(regexp_parts.join("(\s+)\\|(\s+)"))
17
+ end
18
+ end
19
+
20
+ World(EnvironmentVariableHelpers)
@@ -1,7 +1,6 @@
1
1
  require 'cucumber/rspec/doubles'
2
2
 
3
3
  # Set up the mocks. Ookla would approve.
4
- Cistern.formatter = Cistern::Formatter::AwesomePrint
5
4
  Ey::Core::Client.mock!
6
5
  Ey::Core::Client::Mock.timeout = 0.1
7
6
  Ey::Core::Client::Mock.poll_interval = 0
@@ -127,6 +127,18 @@ module ResourceHelpers
127
127
  environment
128
128
  end
129
129
 
130
+ def create_environment_variable(options={})
131
+ application = options[:application] || create_application
132
+ environment = options[:environment] || create_environment
133
+
134
+ environment_variable = options[:environment_variable] || {}
135
+ environment_variable.merge!(application_id: application.id, environment: environment.id)
136
+ environment_variable[:name] ||= SecureRandom.hex(8)
137
+ environment_variable[:value] ||= SecureRandom.hex(32)
138
+
139
+ client.environment_variables.create!(environment_variable)
140
+ end
141
+
130
142
  def create_provider_location(client, attributes={})
131
143
  attributes = Cistern::Hash.stringify_keys(attributes)
132
144
 
@@ -32,6 +32,11 @@ module Ey
32
32
  long: "migrate",
33
33
  description: "The migration command to run. This option has a 50 character limit.",
34
34
  argument: "migrate"
35
+ option :serverside_version,
36
+ short: "S",
37
+ long: "serverside_version",
38
+ description: "Override the default version of engineyard-serverside. The version must match a released version. Use with care.",
39
+ argument: "serverside_version"
35
40
 
36
41
  option :app,
37
42
  short: "a",
@@ -43,11 +48,6 @@ module Ey
43
48
  long: "no-wait",
44
49
  description: "Don't wait for deploy to finish, exit after deploy is started"
45
50
 
46
- switch :verbose,
47
- short: "v",
48
- long: "verbose",
49
- description: "Deploy with verbose output"
50
-
51
51
  switch :verbose,
52
52
  short: "v",
53
53
  long: "verbose",
@@ -63,7 +63,7 @@ module Ey
63
63
  abort <<-EOF
64
64
  Found account #{operator.name} but requested account #{option(:account)}.
65
65
  Use the ID of the account instead of the name.
66
- This can be retrieved by running "ey accounts".
66
+ This can be retrieved by running "ey-core accounts".
67
67
  EOF
68
68
  .red unless operator.name == option(:account) || operator.id == option(:account)
69
69
  end
@@ -78,8 +78,11 @@ EOF
78
78
 
79
79
  app = core_application_for(environment, self.options)
80
80
 
81
- deploy_options = {verbose: options[:verbose], cli_args: ARGV}
81
+ deploy_options = {verbose: switch_active?(:verbose), cli_args: ARGV}
82
82
  latest_deploy = nil
83
+ if options[:serverside_version]
84
+ deploy_options.merge!(serverside_version: option(:serverside_version))
85
+ end
83
86
  if options[:ref]
84
87
  deploy_options.merge!(ref: option(:ref))
85
88
  else
@@ -91,14 +94,14 @@ EOF
91
94
  raise "--ref is required (HEAD is the typical choice)"
92
95
  end
93
96
  end
94
- if (switch_active?(:migrate) || switch_active?(:no_migrate))
95
- deploy_options.merge!(migrate_command: option(:migrate)) if switch_active?(:migrate)
96
- deploy_options.merge!(migrate_command: '') if switch_active?(:no_migrate)
97
+ if (option(:migrate) || switch_active?(:no_migrate))
98
+ deploy_options.merge!(migrate_command: option(:migrate)) if option(:migrate)
99
+ deploy_options.merge!(migrate_command: nil) if switch_active?(:no_migrate)
97
100
  else
98
101
  puts "missing migrate option (--migrate or --no-migrate), checking latest deploy...".yellow
99
102
  latest_deploy ||= environment.latest_deploy(app)
100
103
  if latest_deploy
101
- deploy_options.merge!(migrate_command: (latest_deploy.migrate && latest_deploy.migrate_command) || '')
104
+ deploy_options.merge!(migrate_command: (latest_deploy.migrate && latest_deploy.migrate_command) || nil)
102
105
  else
103
106
  raise "either --migrate or --no-migrate needs to be specified"
104
107
  end
@@ -0,0 +1,29 @@
1
+ require 'ey-core/cli/subcommand'
2
+
3
+ module Ey
4
+ module Core
5
+ module Cli
6
+ class DockerRegistryLogin < Subcommand
7
+ title "get-docker-registry-login"
8
+ summary "Prints the docker login command to authorize the Docker Engine with the AWS ECR registry"
9
+
10
+ option :account,
11
+ short: 'c',
12
+ long: 'account',
13
+ description: 'Name or ID of the account that the environment resides in.',
14
+ argument: 'Account name or id'
15
+
16
+ option :location,
17
+ short: 'l',
18
+ long: 'location',
19
+ description: 'ECR availability regions',
20
+ argument: 'Location name'
21
+
22
+ def handle
23
+ credentials = core_account.retrieve_docker_registry_credentials(option(:location))
24
+ stdout.puts "docker login -u #{credentials.username} -p #{credentials.password} #{credentials.registry_endpoint}"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,71 @@
1
+ require 'ey-core/cli/subcommand'
2
+ require 'ey-core/cli/helpers/stream_printer'
3
+
4
+ module Ey
5
+ module Core
6
+ module Cli
7
+ class EnvironmentVariables < Subcommand
8
+ MASK = '****'.freeze
9
+ SYMBOLS_TO_DISPLAY = 4
10
+ MAX_LENGTH_TO_DISPLAY = 30
11
+
12
+ include Ey::Core::Cli::Helpers::StreamPrinter
13
+
14
+ title "environment_variables"
15
+ summary "Retrieve a list of Engine Yard environment variables for environments that you have access to."
16
+
17
+ option :environment,
18
+ short: 'e',
19
+ long: 'environment',
20
+ description: 'Filter by environmeent name or id',
21
+ argument: 'Environment'
22
+
23
+ option :application,
24
+ short: 'a',
25
+ long: 'application',
26
+ description: 'Filter by application name or id',
27
+ argument: 'Application'
28
+
29
+ switch :display_sensitive,
30
+ short: 's',
31
+ long: 'display_sensitive',
32
+ description: 'Determines whether values of sensitive variables should be printed',
33
+ argument: 'Display Sensitive'
34
+
35
+ def handle
36
+ environment_variables = if option(:application)
37
+ core_applications(option(:application)).flat_map(&:environment_variables)
38
+ elsif option(:environment)
39
+ core_environments(option(:environment)).flat_map(&:environment_variables)
40
+ else
41
+ core_environment_variables
42
+ end
43
+
44
+ stream_print("ID" => 10, "Name" => 30, "Value" => 50, "Environment" => 30, "Application" => 30) do |printer|
45
+ environment_variables.each_entry do |ev|
46
+ printer.print(ev.id, ev.name, print_variable_value(ev), ev.environment_name, ev.application_name)
47
+ end
48
+ end
49
+ end
50
+
51
+ private
52
+
53
+ def print_variable_value(environment_variable)
54
+ if environment_variable.sensitive && !switch_active?(:display_sensitive)
55
+ hide_sensitive_data(environment_variable.value)
56
+ else
57
+ environment_variable.value
58
+ end
59
+ end
60
+
61
+ def hide_sensitive_data(value)
62
+ if value.length > SYMBOLS_TO_DISPLAY
63
+ MASK + value[-SYMBOLS_TO_DISPLAY, SYMBOLS_TO_DISPLAY]
64
+ else
65
+ MASK
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end