Skip to content

Commit

Permalink
feat(libsaltcli.jinja): manage file for libvirt & template formulas
Browse files Browse the repository at this point in the history
  • Loading branch information
myii committed Mar 29, 2020
1 parent a0609bf commit 2da697e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ssf/config/formulas.sls
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
{%- set context = semrel_formula_specs.context %}
{%- set inspec_suites_kitchen = context.inspec_suites_kitchen %}
{%- set use_cirrus_ci = context.use_cirrus_ci %}
{%- set use_libsaltcli = context.use_libsaltcli %}
{%- set use_tofs = context.use_tofs %}
{%- set formula = context.git.github.repo %}
{#- Determine the TOFS override directory for the current formula #}
Expand Down Expand Up @@ -87,9 +88,11 @@ prepare-git-branch-for-{{ formula }}:
{#- Add files by default #}
{%- set add_or_rm = ['add', 'add', 'managed'] %}
{#- Remove files if the file is `.cirrus.yml` and `use_cirrus_ci` is `False` #}
{#- Or if the file is `libsaltcli.jinja` and `use_libsaltcli` is `False` #}
{#- Likewise, if running the state for TOFS files when `use_tofs` is `False` #}
{#- Also remove the local `CONTRIBUTING` file to use the org-level file instead #}
{%- if (semrel_file == '.cirrus.yml' and not use_cirrus_ci) or
(semrel_file == 'libsaltcli.jinja' and not use_libsaltcli) or
(semrel_file in ['docs/TOFS_pattern.rst', 'formula/libtofs.jinja'] and not use_tofs) or
(semrel_file in ['docs/CONTRIBUTING.rst'])
%}
Expand Down
5 changes: 3 additions & 2 deletions ssf/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ ssf_node_anchors:
# An alternative method could be to use:
# `git describe --abbrev=0 --tags`
# yamllint disable rule:line-length rule:quoted-strings
title: 'feat(semantic-release): implement for this formula'
body: '* Checked using https://github.com/myii/ssf-formula/pull/137'
title: "refactor(libsaltcli): use the '`'opts'`' dict throughout [skip ci]"
body: '* Automated using https://github.com/myii/ssf-formula/pull/139'
# yamllint enable rule:line-length rule:quoted-strings
github:
owner: 'saltstack-formulas'
Expand Down Expand Up @@ -167,6 +167,7 @@ ssf_node_anchors:
dist: 'bionic'
use_single_job_for_linters: true
use_cirrus_ci: false
use_libsaltcli: false
use_tofs: false
yamllint:
extends: 'default'
Expand Down
16 changes: 16 additions & 0 deletions ssf/files/default/formula/libsaltcli.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# vim: ft=jinja

{#- Get the relevant values from the `opts` dict #}
{%- set opts_cli = opts.get('__cli', '') %}
{%- set opts_masteropts_cli = opts | traverse('__master_opts__:__cli', '') %}

{#- Determine the type of salt command being run #}
{%- if opts_cli == 'salt-minion' %}
{%- set cli = 'minion' %}
{%- elif opts_cli == 'salt-call' %}
{%- set cli = 'ssh' if opts_masteropts_cli == 'salt-ssh' else 'local' %}
{%- else %}
{%- set cli = 'unknown' %}
{%- endif %}
{%- do salt['log.debug']('[libsaltcli] the salt command type has been identified to be: ' ~ cli) %}
7 changes: 7 additions & 0 deletions ssf/formulas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ ssf_node_anchors:
<<: *file_default
docs/TOFS_pattern.rst: &file__docs__TOFS_pattern--rst
<<: *file_default
formula/libsaltcli.jinja: &file__formula__libsaltcli--jinja
<<: *file_default
formula/libtofs.jinja: &file__formula__libtofs--jinja
<<: *file_default
inspec/inspec.yml: &file__inspec__inspec--yml
Expand Down Expand Up @@ -1143,6 +1145,7 @@ ssf:
- [fedora , 31 , 2019.2, 3, default]
- [opensuse/leap, 15.1 , 2018.3, 2, default]
- [ubuntu , 16.04, 2018.3, 2, default]
use_libsaltcli: true
use_tofs: true
semrel_files: *semrel_files_default
locale:
Expand Down Expand Up @@ -2321,9 +2324,13 @@ ssf:
Cops:
Metrics/BlockLength:
Max: 36
use_libsaltcli: true
use_tofs: true
semrel_files:
<<: *semrel_files_default
formula/libsaltcli.jinja:
<<: *file__formula__libsaltcli--jinja
alt_semrel_formula: 'TEMPLATE'
formula/libtofs.jinja:
<<: *file__formula__libtofs--jinja
alt_semrel_formula: 'TEMPLATE'
Expand Down

0 comments on commit 2da697e

Please sign in to comment.