kubes_google 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b3c67a729485761593635bc0393fbe23f1edc9b68210d843fdf2d01bf64c34c
4
- data.tar.gz: 7790b2ba42f85e001874dddb8aa2e250c3c1a3f4e6a402f1b7ae2529b5579588
3
+ metadata.gz: 64cbb6d5f91c9d194e47f9695b79802c5615367afe6464933b83bb59d9dfc418
4
+ data.tar.gz: 6d3d98f419a73dd8117dc87cfd0adf43e40e2e9feef447c8bbcfe5867b1410c9
5
5
  SHA512:
6
- metadata.gz: c230c68192f0605e1a7285c0842757b3ac1a54a4b33c782a208436ffa6e12fa838c3b9258081a07b25a4108b3266de30b8c1fda066d5805c935b7c0b52e7183d
7
- data.tar.gz: '09bf54cf2eaaa4b99ec4f28c8095d924ab70a0025d37e53b8fc6d413f93a7e295de172c0ee43609488383ce65be9f2e8f1dcbacb12b4bb0716489065cd072140'
6
+ metadata.gz: 500425e494045b16a68672ad80c6d2157fc3a0dcd501c627850c6b3432dd95bec3dba727d31a7bed59d17be128366c4056bccb788d398659032b57afeb6b13e1
7
+ data.tar.gz: 679203c3c148448bfab87162c5267d1403e4f37c5f3dfd6e01bcf042dc7d4453e1919199037092651c807bb774b7a4afb6348f63603146463f552983c5e2c29e
@@ -3,6 +3,9 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [0.1.2]
7
+ - #1 base64 option
8
+
6
9
  ## [0.1.1]
7
10
  - dont base64 secret values in data by default
8
11
 
data/README.md CHANGED
@@ -29,7 +29,7 @@ Then set the secrets in the YAML:
29
29
 
30
30
  .kubes/resources/shared/secret.yaml
31
31
 
32
- ```
32
+ ```yaml
33
33
  apiVersion: v1
34
34
  kind: Secret
35
35
  metadata:
@@ -38,7 +38,7 @@ metadata:
38
38
  app: demo
39
39
  data:
40
40
  <% KubesGoogle::Secrets.data.each do |k,v| -%>
41
- <%= k %>: <%= Base64.encode64(v).strip %>
41
+ <%= k %>: <%= base64(v) %>
42
42
  <% end -%>
43
43
  ```
44
44
 
@@ -78,6 +78,7 @@ Secrets#initialize options:
78
78
 
79
79
  Variable | Description | Default
80
80
  ---|---|---
81
+ base64 | Automatically base64 encode the values. | false
81
82
  upcase | Automatically upcase the Kubernetes secret data keys. | false
82
83
  prefix | Prefixed used to list and filter Google secrets. IE: `projects/686010496118/secrets/demo-dev-`. Can also be set with the `GCP_SECRET_PREFIX` env variable. The env variable takes the highest precedence. | nil
83
84
 
@@ -2,8 +2,8 @@ require "google-cloud-secret_manager"
2
2
 
3
3
  module KubesGoogle
4
4
  class Secrets
5
- def initialize(upcase: false, prefix: nil)
6
- @upcase = upcase
5
+ def initialize(upcase: false, base64: false, prefix: nil)
6
+ @upcase, @base64 = upcase, base64
7
7
  @prefix = ENV['GCP_SECRET_PREFIX'] || prefix || raise("GOOGLE_PROJECT env variable is not set. It's required.")
8
8
  @project_id = ENV['GOOGLE_PROJECT']
9
9
  # IE: prefix: projects/686010496118/secrets/demo-dev-
@@ -22,10 +22,16 @@ module KubesGoogle
22
22
  key = secret.name.sub(@prefix,'')
23
23
  key = key.upcase if @upcase
24
24
  value = version.payload.data
25
+ # strict_encode64 to avoid newlines https://stackoverflow.com/questions/2620975/strange-n-in-base64-encoded-string-in-ruby
26
+ value = Base64.strict_encode64(value).strip if @base64
25
27
  self.class.data[key] = value
26
28
  end
27
29
  end
28
30
 
31
+ def data
32
+ self.class.data
33
+ end
34
+
29
35
  class_attribute :data
30
36
  self.data = {}
31
37
  end
@@ -1,3 +1,3 @@
1
1
  module KubesGoogle
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kubes_google
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-13 00:00:00.000000000 Z
11
+ date: 2020-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport