Formula reset to specific refs (example: Gerrit review)
diff --git a/README.rst b/README.rst
index f63aa65..dd87f53 100644
--- a/README.rst
+++ b/README.rst
@@ -57,6 +57,53 @@
engine: pip
version: 2016.3.0rc2
+Salt master with specified formula to install through apt-get
+
+.. code-block:: yaml
+
+ salt:
+ master:
+ enabled: true
+ ...
+ environment:
+ prd:
+ keysone:
+ source: pkg
+ name: salt-formula-keystone
+
+Clone master branch of keystone formula as local feature branch
+
+.. code-block:: yaml
+
+ salt:
+ master:
+ enabled: true
+ ...
+ environment:
+ dev:
+ formula:
+ keystone:
+ source: git
+ address: git@github.com:openstack/salt-formula-keystone.git
+ revision: master
+ branch: feature
+
+Salt master with specified formula refs (for example for Gerrit review)
+
+.. code-block:: yaml
+
+ salt:
+ master:
+ enabled: true
+ ...
+ environment:
+ dev:
+ formula:
+ keystone:
+ source: git
+ address: https://git.openstack.org/openstack/salt-formula-keystone
+ revision: refs/changes/56/123456/1
+
Salt master syndicate master of masters
.. code-block:: yaml
diff --git a/salt/master/env.sls b/salt/master/env.sls
index 77f5d42..3822667 100644
--- a/salt/master/env.sls
+++ b/salt/master/env.sls
@@ -151,11 +151,50 @@
git.latest:
- name: {{ formula.address }}
- target: /usr/share/salt-formulas/env/_formulas/{{ formula_name }}
- - rev: {{ formula.revision }}
+ {% if formula.get("revision", "").split("/")[0] == "refs" %}
+ - rev: {{ formula.branch|default("master") }}
+ {%- if grains['saltversion'] < "2015.8.0" %}
+ - branch: {{ formula.branch|default("master") }}
+ {%- endif %}
+ {% else %}
+ - rev: {{ formula.revision|default(formula.branch) }}
+ {%- if grains['saltversion'] < "2015.8.0" %}
+ - branch: {{ formula.branch|default(formula.revision) }}
+ {%- endif %}
+ {% endif %}
+ - force_reset: {{ formula.force_reset|default(False) }}
- require:
- file: salt_env_{{ environment_name }}_dirs
- pkg: git_packages
+{%- if formula.get("revision", "").split("/")[0] == "refs" %}
+
+salt_master_{{ environment_name }}_{{ formula_name }}_formula_refs_workaround_fetch:
+ module.run:
+ - name: git.fetch
+ - cwd: /usr/share/salt-formulas/env/_formulas/{{ formula_name }}
+ - opts: {{ formula.address }} {{ formula.revision }}
+ - require:
+ - git: salt_master_{{ environment_name }}_{{ formula_name }}_formula
+
+salt_master_{{ environment_name }}_{{ formula_name }}_formula_refs_workaround_reset:
+ module.run:
+ - name: git.reset
+ - cwd: /usr/share/salt-formulas/env/_formulas/{{ formula_name }}
+ - opts: --hard FETCH_HEAD
+ - require:
+ - module: salt_master_{{ environment_name }}_{{ formula_name }}_formula_refs_workaround_fetch
+
+salt_master_{{ environment_name }}_{{ formula_name }}_formula_refs_workaround_rebase:
+ module.run:
+ - name: git.rebase
+ - cwd: /usr/share/salt-formulas/env/_formulas/{{ formula_name }}
+ - rev: origin/{{ formula.branch|default("master") }}
+ - require:
+ - module: salt_master_{{ environment_name }}_{{ formula_name }}_formula_refs_workaround_reset
+
+{%- endif %}
+
salt_env_{{ environment_name }}_{{ formula_name }}_link:
file.symlink:
- name: /usr/share/salt-formulas/env/{{ formula_name }}
@@ -245,4 +284,5 @@
{# end new #}
-{%- endif %}
\ No newline at end of file
+{%- endif %}
+