Sha256: 5ddf61ede4340e6aeefce664c3456d1b73640ef26b48835874791bd55bb73e18

Contents?: true

Size: 1.33 KB

Versions: 32

Compression:

Stored size: 1.33 KB

Contents

---
title: DSL Merge Behavior
---

Generally, the merge should behave as expected. For example, map or Hash fields are merged together from multiple layers. Strings are simply replaced.

## Hash Example

.kubes/resources/base/all.rb

```ruby
labels(app: "demo")
# ...
```

.kubes/resources/base/all/env.rb

```ruby
labels(env: Kubes.env)
# ...
```

.kubes/resources/web/deployment.rb

```ruby
labels(role: "web")
# ...
```

Layering results in:

.kubes/output/web/deployment.yaml

```yaml
metadata:
  labels:
    app: demo
    env: dev
    role: web
# ...
```

## Hash Merge Behavior Override

You can override the merge behavior with the `_mode` key.

.kubes/resources/web/deployment.rb

```ruby
labels(role: "web", _mode: "reset")
# ...
```

This will completely reset the labels and result in:

```yaml
metadata:
  labels:
    role: web
# ...
```

## String Example

The merging of simple String is a straightforward replacement.

.kubes/resources/web/deployment.rb

```ruby
image docker_image # IE: user/demo:kubes-2020-06-13T19-55-16-43afc6e
# ...
```

.kubes/resources/web/deployment/prod.rb

```ruby
image "nginx:prod-v1"
# ...
```

Results in:

.kubes/output/web/deployment.yaml

```yaml
spec:
  # ...
  template:
    spec:
      containers:
      - image: nginx:prod-v1
        name: demo-web
  # ...
```

{% include dsl/methods.md name="backend_config" %}

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
kubes-0.8.9 docs/_docs/layering/merge-dsl.md
kubes-0.8.8 docs/_docs/layering/merge-dsl.md
kubes-0.8.7 docs/_docs/layering/merge-dsl.md
kubes-0.8.6 docs/_docs/layering/merge-dsl.md
kubes-0.8.5 docs/_docs/layering/merge-dsl.md
kubes-0.8.4 docs/_docs/layering/merge-dsl.md
kubes-0.8.3 docs/_docs/layering/merge-dsl.md
kubes-0.8.2 docs/_docs/layering/merge-dsl.md
kubes-0.8.1 docs/_docs/layering/merge-dsl.md
kubes-0.8.0 docs/_docs/layering/merge-dsl.md
kubes-0.7.10 docs/_docs/layering/merge-dsl.md
kubes-0.7.9 docs/_docs/layering/merge-dsl.md
kubes-0.7.8 docs/_docs/layering/merge-dsl.md
kubes-0.7.7 docs/_docs/layering/merge-dsl.md
kubes-0.7.6 docs/_docs/layering/merge.md
kubes-0.7.5 docs/_docs/layering/merge.md
kubes-0.7.4 docs/_docs/layering/merge.md
kubes-0.7.3 docs/_docs/layering/merge.md
kubes-0.7.2 docs/_docs/layering/merge.md
kubes-0.7.1 docs/_docs/layering/merge.md