rcloadenv 0.0.1.rc1 → 0.0.1.rc2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a87297ed8dee36a3aed034991042cd36fca122b
4
- data.tar.gz: 1714fafa57d7e35fe6f5a258a5ffd939f7253bce
3
+ metadata.gz: c68796040890128ba8d662312d27dfaabcc08c9d
4
+ data.tar.gz: e9cb3bf736137aa83203289b33c20cfcc655581f
5
5
  SHA512:
6
- metadata.gz: 3f8cc786c9a142a0d7381488b9d8282d4507bceb9e9b3c14b0b4e0597f6be5dff2ce2dd4590a4b5b2aad093a37dc34f32479dccf73d28f83ff27edb51ebda12d
7
- data.tar.gz: 977c7bb995baa901fb36934b4d5f9ec552047d2778d3e7212c207307760748eae840d77d3ea385d70944b1bce34e56b5b2b5fe7546a4f63368bd8c2d9083a128
6
+ metadata.gz: '09c2518da2e08e37fdac0ec1ceaf768461a5082ce07890a7e8db186bfa0786269096e66e1a731759388f3487b7015f0ed14ade39a8c5e189689cdabfb83bf7cb'
7
+ data.tar.gz: 21626feb54da19cc9184c72512ada5ff195b7e8b051dc39978d98bbb18f15abcad9843a58c86e945cb9c497d4bc3fa5cb40af32eb59dd4dc3e48891c07c84221
data/README.md CHANGED
@@ -34,19 +34,19 @@ When not running on GCP, credentials are obtained from
34
34
  so you can the `GOOGLE_APPLICATION_CREDENTIALS` environment variable or
35
35
  configure `gcloud auth`.
36
36
 
37
- ## Example: Loading the Rails SECRET_KEY in Google App Engine
37
+ ## Example: Loading the Rails SECRET_KEY_BASE in Google App Engine
38
38
 
39
39
  This gem is commonly used to provide sensitive information such as API keys or
40
40
  database passwords to a Ruby application deployed to Google Cloud Platform,
41
41
  without exposing them to configuration files checked into source control.
42
42
 
43
- For example, Rails applications require the environment variable `SECRET_KEY`
44
- to be set in the production environment. When deploying a Rails application to
45
- Google App Engine, you could set this environment variable in the "app.yaml"
46
- configuration file, but that is not recommended because the "app.yaml" file
47
- is commonly checked into source control. Instead, you can set the `SECRET_KEY`
48
- value securely in the Runtime Config service, and use `rcloadenv` to load it
49
- into the Rails app. Here's how.
43
+ For example, Rails applications require the environment variable
44
+ `SECRET_KEY_BASE` to be set in the production environment. When deploying a
45
+ Rails application to Google App Engine, you could set this environment
46
+ variable in the "app.yaml" configuration file, but that is not recommended
47
+ because the "app.yaml" file is commonly checked into source control. Instead,
48
+ you can set the `SECRET_KEY_BASE` value securely in the Runtime Config
49
+ service, and use `rcloadenv` to load it into the Rails app. Here's how.
50
50
 
51
51
  1. We will assume that:
52
52
 
@@ -86,10 +86,10 @@ into the Rails app. Here's how.
86
86
 
87
87
  This will generate a random key and print it to the console.
88
88
 
89
- 5. Use the gcloud command line to set the `SECRET_KEY` in your configuration.
89
+ 5. Use the gcloud command line to set `SECRET_KEY_BASE` in your configuration.
90
90
 
91
- gcloud beta runtime-config configs variables set SECRET_KEY 12345678 \
92
- --config-name=my-config
91
+ gcloud beta runtime-config configs variables set \
92
+ SECRET_KEY_BASE 12345678 --config-name=my-config
93
93
 
94
94
  Replace `my-config` with the name of your configuration, and `12345678`
95
95
  with the secret key that you generated above.
@@ -109,11 +109,11 @@ into the Rails app. Here's how.
109
109
 
110
110
  Replace `my-config` with the name of your configuration.
111
111
 
112
- (If you previously set SECRET_KEY in the env_variables section of your
112
+ (If you previously set SECRET_KEY_BASE in the env_variables section of your
113
113
  app.yaml, remove it. You no longer need it!)
114
114
 
115
115
  Now when you deploy and run your application, it should load the
116
- SECRET_KEY value from your Runtime Configuration.
116
+ SECRET_KEY_BASE value from your Runtime Configuration.
117
117
 
118
118
  8. If you have set any custom build steps for your application that require
119
119
  this configuration, make sure you update them too. For example, you might
data/lib/rcloadenv/cli.rb CHANGED
@@ -33,7 +33,8 @@ module RCLoadEnv
33
33
  @include = []
34
34
  @override = false
35
35
  @debug = false
36
- parser = OptionParser.new do |opts|
36
+
37
+ @parser = OptionParser.new do |opts|
37
38
  opts.banner = "Usage: rcloadenv [options] <config-name> -- <command>"
38
39
  opts.on "-p name", "--project=name", "--projectId=name",
39
40
  "Project to read runtime config from" do |p|
@@ -54,17 +55,35 @@ module RCLoadEnv
54
55
  opts.on "-d", "--debug", "Enable debug output" do
55
56
  @debug = true
56
57
  end
57
- opts.on "-?", "--help", "Show the help text and exit" do
58
- puts parser.help
58
+ opts.on_tail "--version", "Show the version and exit" do
59
+ puts RCLoadEnv::VERSION
60
+ exit
61
+ end
62
+ opts.on_tail "-?", "--help", "Show the help text and exit" do
63
+ puts @parser.help
59
64
  exit
60
65
  end
61
66
  end
62
- @command_list = parser.parse args
63
- @config_name = @command_list.shift
64
- unless @config_name && @command_list.size > 0
65
- STDERR.puts "rcloadenv: config name and command are both required."
66
- STDERR.puts parser.help
67
- exit 1
67
+
68
+ separator_index = args.index "--"
69
+ @command_list = separator_index ? args[(separator_index+1)..-1] : []
70
+
71
+ args = args[0..separator_index] if separator_index
72
+ begin
73
+ remaining_args = @parser.parse args
74
+ rescue OptionParser::ParseError => ex
75
+ usage_error ex.message
76
+ end
77
+ @config_name = remaining_args.shift
78
+ unless @config_name
79
+ usage_error "You must provide a config name."
80
+ end
81
+ unless remaining_args.empty?
82
+ usage_error "Extra arguments found: #{remaining_args.inspect}"
83
+ end
84
+
85
+ if @command_list.empty?
86
+ usage_error "You must provide a command delimited by `--`."
68
87
  end
69
88
  end
70
89
 
@@ -79,5 +98,12 @@ module RCLoadEnv
79
98
  loader.modify_env ENV
80
99
  exec(*@command_list)
81
100
  end
101
+
102
+ ## @private
103
+ def usage_error msg
104
+ STDERR.puts "rcloadenv: #{msg}"
105
+ STDERR.puts @parser.help
106
+ exit 1
107
+ end
82
108
  end
83
109
  end
@@ -16,6 +16,6 @@
16
16
  module RCLoadEnv
17
17
 
18
18
  ## The current version of this gem, as a string.
19
- VERSION = '0.0.1.rc1'.freeze
19
+ VERSION = '0.0.1.rc2'.freeze
20
20
 
21
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rcloadenv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.rc1
4
+ version: 0.0.1.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Azuma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-27 00:00:00.000000000 Z
11
+ date: 2017-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-api-client
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.5'
19
+ version: '0.13'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.5'
26
+ version: '0.13'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: google-cloud-core
29
29
  requirement: !ruby/object:Gem::Requirement