Skip to content

Commit 9fb1e0b

Browse files
author
nicolas.delossantos
committed
fix: python3 missing iteritems() for OrderedDict
Changing it to using items() instead fixes it.
1 parent fe611c7 commit 9fb1e0b

2 files changed

Lines changed: 23 additions & 23 deletions

File tree

_modules/helm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def manage_repos(present={}, absent=[], exclusive=False, **kwargs):
201201
"failed": []
202202
}
203203

204-
for name, url in present.iteritems():
204+
for name, url in present.items():
205205
if not name or not url:
206206
raise CommandExecutionError(('Supplied repo to add must have a name (%s) '
207207
'and url (%s)' % (name, url)))
@@ -217,7 +217,7 @@ def manage_repos(present={}, absent=[], exclusive=False, **kwargs):
217217
'stdout': add_repo(name, url, **kwargs)['stdout']
218218
})
219219
existing_repos = {
220-
n: u for (n, u) in existing_repos.iteritems() if name != n
220+
n: u for (n, u) in existing_repos.items() if name != n
221221
}
222222
except CommandExecutionError as e:
223223
result['failed'].append({
@@ -231,7 +231,7 @@ def manage_repos(present={}, absent=[], exclusive=False, **kwargs):
231231
# Handle removal of repositories configured to be absent (or not configured
232232
# to be present if the `exclusive` flag is set)
233233
#
234-
existing_names = [name for (name, url) in existing_repos.iteritems()]
234+
existing_names = [name for (name, url) in existing_repos.items()]
235235
if exclusive:
236236
present['stable'] = "exclude"
237237
absent = [name for name in existing_names if not name in present]

_states/helm_repos.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,35 @@
55
def managed(name, present={}, absent=[], exclusive=False, helm_home=None):
66
'''
77
Ensure the supplied repositories are available to the helm client. If the
8-
`exclusive` flag is set to a truthy value, any extra repositories in the
8+
`exclusive` flag is set to a truthy value, any extra repositories in the
99
helm client will be removed.
1010
1111
name
1212
The name of the state
1313
1414
present
15-
A dict of repository names to urls to ensure are registered with the
15+
A dict of repository names to urls to ensure are registered with the
1616
Helm client
17-
17+
1818
absent
1919
A list of repository names to ensure are unregistered from the Helm client
20-
20+
2121
exclusive
22-
A boolean flag indicating whether the state should ensure only the
22+
A boolean flag indicating whether the state should ensure only the
2323
supplied repositories are availabe to the target minion.
2424
2525
helm_home
26-
An optional path to the Helm home directory
26+
An optional path to the Helm home directory
2727
'''
2828
ret = {'name': name,
2929
'changes': {},
3030
'result': True,
3131
'comment': ''}
32-
32+
3333
try:
3434
result = __salt__['helm.manage_repos'](
35-
present=present,
36-
absent=absent,
35+
present=present,
36+
absent=absent,
3737
exclusive=exclusive,
3838
helm_home=helm_home
3939
)
@@ -50,7 +50,7 @@ def managed(name, present={}, absent=[], exclusive=False, helm_home=None):
5050
return ret
5151

5252
ret['comment'] = ("Repositories were in the desired state: "
53-
"%s" % [name for (name, url) in present.iteritems()])
53+
"%s" % [name for (name, url) in present.items()])
5454
return ret
5555
except CommandExecutionError as e:
5656
ret['result'] = False
@@ -59,24 +59,24 @@ def managed(name, present={}, absent=[], exclusive=False, helm_home=None):
5959

6060
def updated(name, helm_home=None):
6161
'''
62-
Ensure the local Helm repository cache is up to date with each of the
63-
helm client's configured remote chart repositories. Because the `helm repo
64-
update` command doesn't indicate whether any changes were made to the local
62+
Ensure the local Helm repository cache is up to date with each of the
63+
helm client's configured remote chart repositories. Because the `helm repo
64+
update` command doesn't indicate whether any changes were made to the local
6565
cache, this will only indicate change if the Helm client failed to retrieve
66-
an update from one or more of the repositories, regardless of whether an
66+
an update from one or more of the repositories, regardless of whether an
6767
update was made to the local Helm chart repository cache.
6868
6969
name
7070
The name of the state
7171
7272
helm_home
73-
An optional path to the Helm home directory
73+
An optional path to the Helm home directory
7474
'''
7575
ret = {'name': name,
7676
'changes': {},
7777
'result': True,
7878
'comment': 'Successfully synced repositories: ' }
79-
79+
8080

8181
try:
8282
result = __salt__['helm.update_repos'](helm_home=helm_home)
@@ -86,20 +86,20 @@ def updated(name, helm_home=None):
8686
r'Successfully got an update from the \"([^\"]+)\"', result['stdout'])
8787
failed_repos = re.findall(
8888
r'Unable to get an update from the \"([^\"]+)\"', result['stdout'])
89-
89+
9090
if failed_repos and len(failed_repos) > 0:
9191
ret['result'] = False
9292
ret['changes']['succeeded'] = success_repos
9393
ret['changes']['failed'] = failed_repos
9494
ret['comment'] = 'Failed to sync against some repositories' + cmd_str
9595
else:
9696
ret['comment'] += "%s" % success_repos + cmd_str
97-
97+
9898
except CommandExecutionError as e:
9999
ret['name'] = e.cmd
100100
ret['result'] = False
101-
ret['comment'] = ("Failed to update repos: %s" % e.error +
101+
ret['comment'] = ("Failed to update repos: %s" % e.error +
102102
"\nExecuted command: %s" % e.cmd)
103103
return ret
104104

105-
return ret
105+
return ret

0 commit comments

Comments
 (0)