kubes 0.4.5 → 0.4.6
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 +3 -0
- data/docs/_docs/helpers/custom.md +40 -0
- data/docs/_includes/sidebar.html +1 -0
- data/lib/kubes/autoloader.rb +9 -0
- data/lib/kubes/compiler/shared/custom_helpers.rb +17 -0
- data/lib/kubes/compiler/strategy/base.rb +1 -0
- data/lib/kubes/compiler/strategy/dsl.rb +1 -0
- data/lib/kubes/compiler/strategy/erb.rb +2 -0
- data/lib/kubes/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4943b1a730b2ab6d80a6de3128d6a55182a02f75c6ed176ab5bdc2eef9e080a
|
4
|
+
data.tar.gz: 0d30261fa44bb60fa61bc9d38ada888469caa27b42e09c19e59edbbed52ab190
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a17f532fa0b257a92b79fd1975c6d83ba0d7fc6f4d56c7e01f0937d9f64b16bae2e3637364acc258027f0c3fe434f1732221dedc8461587c45a9fcaea4c873b
|
7
|
+
data.tar.gz: 91e88038fcdfd9925567936c2a665d097ac739d2ebb17191526357bbd227336ffe57c389e946f44b6ce78ed27022901f2c78ee64f2aacdcbeda490a51d35e35a
|
data/CHANGELOG.md
CHANGED
@@ -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.4.6]
|
7
|
+
- #32 custom helpers support
|
8
|
+
|
6
9
|
## [0.4.5]
|
7
10
|
- #31 kubes AWS helpers
|
8
11
|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
title: Custom Helpers
|
3
|
+
---
|
4
|
+
|
5
|
+
Kubes ships with several built-in helpers. On top of this, you can define your own custom helpers. This allows you to define new methods and customize Kubes further.
|
6
|
+
|
7
|
+
## Example
|
8
|
+
|
9
|
+
You define custom helpers in the `.kubes/helpers` folder.
|
10
|
+
|
11
|
+
.kubes/helpers/my_helpers.rb
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
module MyHelpers
|
15
|
+
def database_endpoint
|
16
|
+
case Kubes.env
|
17
|
+
when "dev"
|
18
|
+
"dev-db.cbuqdmc3nqvb.us-west-2.rds.amazonaws.com"
|
19
|
+
when "prod"
|
20
|
+
"prod-db.cbuqdmc3nqvb.us-west-2.rds.amazonaws.com"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
```
|
25
|
+
|
26
|
+
The `database_endpoint` will be available to use in the `.kubes/resources` YAML files. IE:
|
27
|
+
|
28
|
+
.kubes/helpers/resources/shared/config_map.yaml
|
29
|
+
|
30
|
+
```yaml
|
31
|
+
apiVersion: v1
|
32
|
+
kind: ConfigMap
|
33
|
+
metadata:
|
34
|
+
name: demo
|
35
|
+
labels:
|
36
|
+
app: demo
|
37
|
+
data:
|
38
|
+
DATABASE_ENDPOINT: <%= database_endpoint %>
|
39
|
+
```
|
40
|
+
|
data/docs/_includes/sidebar.html
CHANGED
@@ -99,6 +99,7 @@
|
|
99
99
|
</li>
|
100
100
|
<li><a href="{% link _docs/helpers.md %}">Helpers</a>
|
101
101
|
<ul>
|
102
|
+
<li><a href="{% link _docs/helpers/custom.md %}">Custom</a></li>
|
102
103
|
<li><a href="{% link _docs/helpers/aws.md %}">AWS</a>
|
103
104
|
<ul>
|
104
105
|
{% assign docs = site.docs | where: "categories","helpers-aws" %}
|
data/lib/kubes/autoloader.rb
CHANGED
@@ -14,8 +14,17 @@ module Kubes
|
|
14
14
|
loader = Zeitwerk::Loader.new
|
15
15
|
loader.inflector = Inflector.new
|
16
16
|
loader.push_dir(File.dirname(__dir__)) # lib
|
17
|
+
|
18
|
+
helpers = "#{kubes_root}/.kubes/helpers"
|
19
|
+
loader.push_dir(helpers) if File.exist?(helpers) # project helpers
|
20
|
+
|
17
21
|
loader.setup
|
18
22
|
end
|
23
|
+
|
24
|
+
# Autoloader runs so early that Kubes.root is not available, so we must declare it here
|
25
|
+
def kubes_root
|
26
|
+
ENV['KUBES_ROOT'] || '.'
|
27
|
+
end
|
19
28
|
end
|
20
29
|
end
|
21
30
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Kubes::Compiler::Shared
|
2
|
+
module CustomHelpers
|
3
|
+
# Load custom helper methods from project
|
4
|
+
@@custom_helpers_loaded = false
|
5
|
+
def load_custom_helpers
|
6
|
+
return if @@custom_helpers_loaded
|
7
|
+
paths = Dir.glob("#{Kubes.root}/.kubes/helpers/**/*.rb")
|
8
|
+
paths.sort_by! { |p| p.size } # so namespaces are loaded first
|
9
|
+
paths.each do |path|
|
10
|
+
filename = path.sub(%r{.*.kubes/helpers/},'').sub('.rb','')
|
11
|
+
module_name = filename.camelize
|
12
|
+
self.class.send :include, module_name.constantize
|
13
|
+
end
|
14
|
+
@@custom_helpers_loaded = true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -4,10 +4,12 @@ class Kubes::Compiler::Strategy
|
|
4
4
|
class Erb < Base
|
5
5
|
extend Kubes::Compiler::Dsl::Core::Fields
|
6
6
|
include Kubes::Compiler::Dsl::Core::Helpers
|
7
|
+
include Kubes::Compiler::Shared::CustomHelpers
|
7
8
|
include Kubes::Compiler::Shared::Helpers
|
8
9
|
include Kubes::Compiler::Layering
|
9
10
|
|
10
11
|
def run
|
12
|
+
load_custom_helpers
|
11
13
|
@data = {}
|
12
14
|
|
13
15
|
render_files(pre_layers)
|
data/lib/kubes/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kubes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
@@ -303,6 +303,7 @@ files:
|
|
303
303
|
- docs/_docs/helpers/aws/iam-role.md
|
304
304
|
- docs/_docs/helpers/aws/secrets.md
|
305
305
|
- docs/_docs/helpers/aws/ssm.md
|
306
|
+
- docs/_docs/helpers/custom.md
|
306
307
|
- docs/_docs/helpers/google.md
|
307
308
|
- docs/_docs/helpers/google/secrets.md
|
308
309
|
- docs/_docs/helpers/google/service-account.md
|
@@ -557,6 +558,7 @@ files:
|
|
557
558
|
- lib/kubes/compiler/dsl/syntax/service.rb
|
558
559
|
- lib/kubes/compiler/dsl/syntax/service_account.rb
|
559
560
|
- lib/kubes/compiler/layering.rb
|
561
|
+
- lib/kubes/compiler/shared/custom_helpers.rb
|
560
562
|
- lib/kubes/compiler/shared/helpers.rb
|
561
563
|
- lib/kubes/compiler/strategy.rb
|
562
564
|
- lib/kubes/compiler/strategy/base.rb
|