gce-host 0.3.0 → 0.3.1

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: 19193e270212331af7d6ed88a67a2477cc918ffd
4
- data.tar.gz: 6938284bed1b7ae803773b673ee47b2507e4993a
3
+ metadata.gz: 9dcb22f8502017ffafae992fec07a972eff348b8
4
+ data.tar.gz: 1167b8fa23f4d18d24cda1473799a60cf9964ead
5
5
  SHA512:
6
- metadata.gz: 2489ae5fd002f8e517592d9ca0c88b932d08c49aab5193bacfc8dfa2164b7fff3889541178b69c63f238a1c338075ea0c1d3c82e0c1869ff010f326d7b29941d
7
- data.tar.gz: 852d0b3b2c8dbba2229ccfbf4e69821da5ac7484b94388ab12df563c60ec77d950ef2ea7121391b652e87d152cc59d85f838ef522c9bbb8b918b773eb9e4f602
6
+ metadata.gz: 4c3be2a15187ff646baa87b93377cbcfd86de9b9d7816ebc0f585d6b18bf0a87b4a54572a2aaf128fdca064313d84af8b410a9738809d50c403a09ebed5c0c01
7
+ data.tar.gz: af63c8a6aabbfa595de78f233814f9502047a269252f17c93b7e394c494ba441b2734bd671a0810b20a188afe5f91eefd1656deaab103e6110057f4203a23bb3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.3.1 (2016/11/25)
2
+
3
+ Enhancements
4
+
5
+ * Get project_id from credentials['client_email'] for a service account json
6
+
1
7
  # 0.3.0 (2016/11/25)
2
8
 
3
9
  Changes
data/README.md CHANGED
@@ -21,8 +21,9 @@ You can write a configuration file located at `/etc/sysconfig/gce-host` (You can
21
21
 
22
22
  GOOGLE API parameters:
23
23
 
24
- * **AUTH_METHOD (optional)**: Authentication method. Currently, `compute_engine`, `service_account`, `authorized_user`, and `application_default` is available. The default reads from `GOOGLE_APPLICATION_CREDENTIALS`.
24
+ * **AUTH_METHOD (optional)**: Authentication method. Currently, `compute_engine`, `service_account`, `authorized_user`, and `application_default` is available. The default is `application_default`
25
25
  * **GOOGLE_APPLICATION_CREDENTIALS (optional)**: Specify path of json credential file. The default is `~/.config/gcloud/application_default_credentials.json`.
26
+ * **GOOGLE_PROJECT (optional)**: Specify project name of your GCP account. It tries to retrieve project_id if service account json is given in `GOOGLE_APPLICATION_CREDENTIALS`.
26
27
 
27
28
  gce-host parameters:
28
29
 
@@ -169,7 +170,7 @@ NOTE: Currently, mock is not supported yet. So, you have to create your own gclo
169
170
  Configure .env file as
170
171
 
171
172
  ```
172
- AUTH_METHOD=json_key
173
+ AUTH_METHOD=service_account
173
174
  GOOGLE_APPLICATION_CREDENTIALS=service_acount.json
174
175
  GOOGLE_PROJECT=XXXXXXXXXXXXX
175
176
  OPTIONAL_STRING_KEYS=service,status
data/example/example.conf CHANGED
@@ -1,4 +1,4 @@
1
- AUTH_METHOD=json_key
1
+ AUTH_METHOD=service_account
2
2
  GOOGLE_APPLICATION_CREDENTIALS=~/.config/gcloud/your-project-000.json
3
3
  ROLES_KEY=roles
4
4
  ROLE_VALUE_DELIMITER=:
@@ -6,3 +6,4 @@ OPTIONAL_STRING_KEYS=service,status
6
6
  OPTIONAL_ARRAY_KEYS=tags
7
7
  ARRAY_VALUE_DELIMITER=,
8
8
  LOG_LEVEL=info
9
+ STATUS=state
@@ -16,12 +16,12 @@ class GCE
16
16
  end
17
17
 
18
18
  def self.auth_method
19
- @auth_method ||= ENV['AUTH_METHOD'] || config.fetch('AUTH_METHOD', nil) || credentials['type'] || 'application_default'
19
+ @auth_method ||= ENV['AUTH_METHOD'] || config.fetch('AUTH_METHOD', nil) || 'application_default'
20
20
  end
21
21
 
22
22
  def self.credentials_file
23
23
  # ref. https://developers.google.com/identity/protocols/application-default-credentials
24
- @credential_file ||= File.expand_path(ENV['GOOGLE_APPLICATION_CREDENTIALS'] || config.fetch('GOOGLE_APPLICATION_CREDENTIALS', nil) || credentials_file_default)
24
+ @credentials_file ||= File.expand_path(ENV['GOOGLE_APPLICATION_CREDENTIALS'] || config.fetch('GOOGLE_APPLICATION_CREDENTIALS', nil) || credentials_file_default)
25
25
  end
26
26
 
27
27
  def self.credentials_file_default
@@ -57,7 +57,9 @@ class GCE
57
57
  end
58
58
 
59
59
  def self.project
60
- @project ||= ENV['GOOGLE_PROJECT'] || config.fetch('GOOGLE_PROJECT', nil) || credentials['project_id'] || project_default
60
+ @project ||= ENV['GOOGLE_PROJECT'] || config.fetch('GOOGLE_PROJECT', nil) || credentials['project_id']
61
+ @project ||= credentials['client_email'].chomp('.iam.gserviceaccount.com').split('@').last if credentials['client_email']
62
+ @project ||= project_default
61
63
  end
62
64
 
63
65
  def self.log_level
@@ -1,5 +1,5 @@
1
1
  class GCE
2
2
  class Host
3
- VERSION = '0.3.0'
3
+ VERSION = '0.3.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gce-host
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo