gce-host 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/{bin → exe}/gce-host +0 -0
- data/gce-host.gemspec +3 -1
- data/lib/gce/host/config.rb +35 -8
- data/lib/gce/host/version.rb +1 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1698b100ec090d7a8739d551cfa6a55c69fb8cea
|
4
|
+
data.tar.gz: b7fc92d6cdaaa77cd251d9876989ac4e342e9c87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70e4f1ac7d6aa55a7b9e5b773f9e0465df4d145f4b00bd595084072055f07ddbc8791f7335c080c6be2a3fe2fefa36945ac5e585852a92a0b2fce3bdaa215269
|
7
|
+
data.tar.gz: 71376e10c41acb323debb24aff97eec453b36e0a7c2d148ed990f53ed880444b59777bfaae22a23470ed934793c547336746d1cb92973188f8d8c235c5b83317
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -22,7 +22,7 @@ You can write a configuration file located at `/etc/sysconfig/gce-host` (You can
|
|
22
22
|
GOOGLE API parameters:
|
23
23
|
|
24
24
|
* **AUTH_METHOD**: Authentication method. Currently, `compute_engine`, `json_key` and `application_default` is available. The default is `applilcation_default`.
|
25
|
-
* **GOOGLE_CREDENTIAL_FILE**: Path of credential file. Specify your service account json file for `json_key` authentication method.
|
25
|
+
* **GOOGLE_CREDENTIAL_FILE (optional)**: Path of credential file. Specify your service account json file for `json_key` authentication method. Try reading from `~/.config/gcloud/legacy_credentials/#{service_account}/adc.json` as default, where the `service_account` is being read from `~/.config/gcloud/configurations/config_default`.
|
26
26
|
|
27
27
|
gce-host parameters:
|
28
28
|
|
data/{bin → exe}/gce-host
RENAMED
File without changes
|
data/gce-host.gemspec
CHANGED
@@ -12,11 +12,13 @@ Gem::Specification.new do |gem|
|
|
12
12
|
|
13
13
|
gem.files = `git ls-files`.split("\n")
|
14
14
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
-
gem.
|
15
|
+
gem.bindir = "exe"
|
16
|
+
gem.executables = `git ls-files -- exe/*`.split("\n").map{ |f| File.basename(f) }
|
16
17
|
gem.require_paths = ["lib"]
|
17
18
|
|
18
19
|
gem.add_runtime_dependency 'google-api-client'
|
19
20
|
gem.add_runtime_dependency 'dotenv'
|
21
|
+
gem.add_runtime_dependency 'inifile'
|
20
22
|
|
21
23
|
gem.add_development_dependency 'yard'
|
22
24
|
gem.add_development_dependency 'rspec'
|
data/lib/gce/host/config.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'dotenv'
|
2
2
|
Dotenv.load
|
3
|
+
require 'inifile'
|
3
4
|
|
4
5
|
class GCE
|
5
6
|
class Host
|
@@ -19,17 +20,43 @@ class GCE
|
|
19
20
|
end
|
20
21
|
|
21
22
|
def self.credential_file
|
22
|
-
@credential_file ||= File.expand_path(
|
23
|
+
@credential_file ||= File.expand_path(
|
24
|
+
ENV['GOOGLE_CREDENTIAL_FILE'] ||
|
25
|
+
config.fetch('GOOGLE_CREDENTIAL_FILE', nil) ||
|
26
|
+
"~/.config/gcloud/legacy_credentials/#{service_account}/adc.json"
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.credential
|
31
|
+
File.readable?(credential_file) ? JSON.parse(File.read(credential_file)) : {}
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.config_default_file
|
35
|
+
File.expand_path('~/.config/gcloud/configurations/config_default')
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.config_default
|
39
|
+
@config_default ||= File.readable?(config_default_file) ? IniFile.load(config_default_file).to_h : {}
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.service_account_default
|
43
|
+
(config_default['core'] || {})['account']
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.project_default
|
47
|
+
(config_default['core'] || {})['project']
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.zone_default
|
51
|
+
(config_default['compute'] || {})['zone']
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.service_account
|
55
|
+
@service_account ||= ENV['GOOGLE_SERVICE_ACCOUNT'] || config.fetch('GOOGLE_SERVICE_ACCOUNT', nil) || service_account_default
|
23
56
|
end
|
24
57
|
|
25
58
|
def self.project
|
26
|
-
|
27
|
-
# ref. terraform https://www.terraform.io/docs/providers/google/
|
28
|
-
@project ||= ENV['GOOGLE_PROJECT'] || config.fetch('GOOGLE_PROJECT', nil)
|
29
|
-
if @project.nil? and credential_file and File.readable?(credential_file)
|
30
|
-
@project ||= (JSON.parse(File.read(credential_file)) || {})['project_id']
|
31
|
-
end
|
32
|
-
@project
|
59
|
+
@project ||= ENV['GOOGLE_PROJECT'] || config.fetch('GOOGLE_PROJECT', nil) || credential['project_id'] || project_default
|
33
60
|
end
|
34
61
|
|
35
62
|
def self.log_level
|
data/lib/gce/host/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gce-host
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-api-client
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: inifile
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: yard
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,7 +165,6 @@ files:
|
|
151
165
|
- LICENSE
|
152
166
|
- README.md
|
153
167
|
- Rakefile
|
154
|
-
- bin/gce-host
|
155
168
|
- docs/GCE.html
|
156
169
|
- docs/GCE/Host.html
|
157
170
|
- docs/GCE/Host/CLI.html
|
@@ -180,6 +193,7 @@ files:
|
|
180
193
|
- docs/top-level-namespace.html
|
181
194
|
- example/example.conf
|
182
195
|
- example/example.rb
|
196
|
+
- exe/gce-host
|
183
197
|
- gce-host.gemspec
|
184
198
|
- lib/gce-host.rb
|
185
199
|
- lib/gce/host.rb
|