Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add defaults.update function. #45051

Merged
merged 2 commits into from Dec 22, 2017

Conversation

Projects
None yet
2 participants
@AAbouZaid
Copy link
Contributor

commented Dec 16, 2017

What does this PR do?

Add defaults.update function.

What issues does this PR fix or reference?

After enhancing defaults module with PR no. #44851 and #44850

I found that we have a lot of redundant in jinja, so this function is a combination of defaults.merge and defaults.deepcopy to avoid redundancy.

Here is an arbitrary example:

Yaml

group01:
  defaults:
    enabled: True
    extra:
      - test
      - stage
  nodes:
    host01:
      index: foo
      upstream: bar
    host02:
      index: foo2
      upstream: bar2

Expected output of group01.nodes.host01:

host01:
  index: foo
  upstream: bar
  enabled: True
  aggregate: source
  extra:
    - test
    - stage

Old style that done with Jinja:

{% for host, vars in group01.nodes.items() %}
  {% set defaults = salt['defaults.deepcopy'](group01.defaults) %}
  {% set host_vars = salt['defaults.merge'](defaults, vars) %}
  ....
{% endfor %}

The same thing with the new function defaults.update:

{% do salt['defaults.update'](group01.nodes, group01.defaults) %}

New Behavior

Better merge of defaults for groups.

Tests written?

Yes

Commits signed with GPG?

Yes

AAbouZaid added some commits Dec 16, 2017

@rallytime rallytime merged commit dafb42f into saltstack:develop Dec 22, 2017

6 of 9 checks passed

default Build finished.
Details
jenkins/PR/salt-pr-linode-ubuntu16-py3 Pull Requests » Salt PR - Linode Ubuntu16.04 - PY3 #4894 — FAILURE
Details
jenkins/PR/salt-pr-rs-cent7-n Pull Requests » Salt PR - RS CentOS 7 #14444 — FAILURE
Details
WIP ready for review
Details
codeclimate All good!
Details
jenkins/PR/salt-pr-clone Pull Requests » Salt PR - Clone #20340 — SUCCESS
Details
jenkins/PR/salt-pr-docs-n Pull Requests » Salt PR - Docs #12860 — SUCCESS
Details
jenkins/PR/salt-pr-linode-ubuntu14-n Pull Requests » Salt PR - Linode Ubuntu14.04 #17875 — SUCCESS
Details
jenkins/PR/salt-pr-lint-n Pull Requests » Salt PR - Code Lint #17445 — SUCCESS
Details
@AAbouZaid

This comment has been minimized.

Copy link
Contributor Author

commented Nov 26, 2018

@rallytime It's almost a year, when this function will be available please? 🤔

@rallytime

This comment has been minimized.

Copy link
Contributor

commented Nov 28, 2018

It will be available in Fluorine.

@AAbouZaid

This comment has been minimized.

Copy link
Contributor Author

commented Nov 29, 2018

Ah, ok 👍
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.