Skip to content

Commit

Permalink
Simplify checking when to define the repository
Browse files Browse the repository at this point in the history
Don't try to detect if a MirrorCache repository is defined.
Instead, enable only if needed in pillar data.
  • Loading branch information
eliroca authored and andrii-suse committed May 17, 2024
1 parent 59a932e commit 661e08c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 17 deletions.
18 changes: 1 addition & 17 deletions mirrorcache/repo.sls
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
{%- set repositories = salt['pillar.get']('zypper:repositories', {}) -%}
{%- set already = { 'defined': False } -%}

{# repository might be already defined in zypper pillar, so need to detect it #}
{%- if not repositories -%}
{%- set repositories = salt['pillar.get']('zypp:repositories', {}) -%}
{%- endif -%}

{%- if repositories -%}
{%- for repo, data in repositories.items() -%}
{%- if ('baseurl' in data and data['baseurl'] and 'MirrorCache' in data['baseurl']) or ('ibs' in data and 'NPMC' in data['ibs']) -%}
{%- do already.update({ 'defined': True }) -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}

{%- if already.defined != True -%}
{%- if 'mirrorcache_formula_enable_repository' in pillar and pillar.mirrorcache_formula_enable_repository -%}
{% set repourl = salt['pillar.get']('mirrorcache:repourl', 'http://download.opensuse.org/repositories/openSUSE:/infrastructure:/MirrorCache/$releasever/') %}
mc:
pkgrepo.managed:
Expand Down
1 change: 1 addition & 0 deletions t/lib/repo.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mirrorcache_formula_enable_repository: True
1 change: 1 addition & 0 deletions t/lib/top.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

{{ saltenv }}:
"*":
- repo
- testpreset
{% if (salt['grains.has_value']('roles')) %}
{% for role in roles %}
Expand Down

0 comments on commit 661e08c

Please sign in to comment.