Skip to content

Commit

Permalink
rename mconcat to merge
Browse files Browse the repository at this point in the history
  • Loading branch information
wr0ngway committed Dec 22, 2021
1 parent d58d6a1 commit b66107a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
1.1.0 (12/22/2021)
------------------

* rename mconcat to merge [be0b068](../../commit/be0b068)
* add active_templates in crd to make it easier to selectively enable of templates [3399bce](../../commit/3399bce)
* make typify handle collections, add mconcat and re_replace filters [ffc8563](../../commit/ffc8563)
* fix multi env/ns docs [0f3c4ee](../../commit/0f3c4ee)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ ones:
| `inflate` | Converts a map of key/values into a nested data structure based on a delimiter in the key name, e.g. `{foo.baz.bum: 2}` => `{foo: {bar: {baz: 2}}}` Inverse of deflate|
| `deflate` | Converts a nested data structure into a single level map using a delimiter to indicate level in the key name, e.g. `{foo: {bar: {baz: 2}}}` => `{foo.baz.bum: 2}` Inverse of inflate |
| `typify` | Converts string values into primitive types (int, float, bool) where applicable for a nested data structure |
| `mconcat` | Combines two hashes into one, a.l.a ruby merge |
| `merge` | Combines two hashes into one, a.l.a ruby merge |
| `re_replace` | Regexp search and replace, a.l.a ruby gsub, e.g. `"foo" | re_replace: "o+", "X"` |

The default `resource_templates` make use of the `context` attribute to allow
Expand Down
2 changes: 1 addition & 1 deletion lib/kubetruth/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def typify(data, parser="json")
end
end

def mconcat(lhs_map, rhs_map)
def merge(lhs_map, rhs_map)
lhs_map.merge(rhs_map)
end

Expand Down
6 changes: 3 additions & 3 deletions spec/kubetruth/template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,13 @@ module Kubetruth

end

describe "#mconcat" do
describe "#merge" do

it "merges two maps" do
m1 = {"x" => "y", "a" => "z"}
m2 = {"a" => "b", "y" => "z"}
expect(mconcat(m1, m2)).to eq(m1.merge(m2))
expect(described_class.new("{{ m1 | mconcat: m2 | to_json }}").render(m1: m1, m2: m2)).to eq(m1.merge(m2).to_json)
expect(merge(m1, m2)).to eq(m1.merge(m2))
expect(described_class.new("{{ m1 | merge: m2 | to_json }}").render(m1: m1, m2: m2)).to eq(m1.merge(m2).to_json)
end

end
Expand Down

0 comments on commit b66107a

Please sign in to comment.