Skip to content

Commit edea9e4

Browse files
committed
fix: add deprecation notice for elasticsearch module/states
1 parent d7338a0 commit edea9e4

File tree

4 files changed

+72
-40
lines changed

4 files changed

+72
-40
lines changed

salt/modules/elasticsearch.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@
5555

5656
log = logging.getLogger(__name__)
5757

58+
__deprecated__ = (
59+
3009,
60+
"elasticsearch",
61+
"https://github.com/cesan3/salt-ext-elasticsearch", # This is the repo with the issues tracker for this module
62+
# and the one that will be used to submit PRs, for now, until
63+
# PR actions are enabled in
64+
# http://salt-extensions/saltext-elasticsearch repo
65+
)
66+
5867
try:
5968
import elasticsearch
6069

salt/states/elasticsearch.py

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@
1111

1212
log = logging.getLogger(__name__)
1313

14+
__deprecated__ = (
15+
3009,
16+
"elasticsearch",
17+
"https://github.com/cesan3/salt-ext-elasticsearch", # This is the repo with the issues tracker for this module
18+
# and the one that will be used to submit PRs, for now, until
19+
# PR actions are enabled in
20+
# http://salt-extensions/saltext-elasticsearch repo
21+
)
22+
1423

1524
def index_absent(name):
1625
"""
@@ -26,20 +35,20 @@ def index_absent(name):
2635
index = __salt__["elasticsearch.index_get"](index=name)
2736
if index and name in index:
2837
if __opts__["test"]:
29-
ret["comment"] = "Index {} will be removed".format(name)
38+
ret["comment"] = f"Index {name} will be removed"
3039
ret["changes"]["old"] = index[name]
3140
ret["result"] = None
3241
else:
3342
ret["result"] = __salt__["elasticsearch.index_delete"](index=name)
3443
if ret["result"]:
35-
ret["comment"] = "Successfully removed index {}".format(name)
44+
ret["comment"] = f"Successfully removed index {name}"
3645
ret["changes"]["old"] = index[name]
3746
else:
3847
ret[
3948
"comment"
40-
] = "Failed to remove index {} for unknown reasons".format(name)
49+
] = f"Failed to remove index {name} for unknown reasons"
4150
else:
42-
ret["comment"] = "Index {} is already absent".format(name)
51+
ret["comment"] = f"Index {name} is already absent"
4352
except Exception as err: # pylint: disable=broad-except
4453
ret["result"] = False
4554
ret["comment"] = str(err)
@@ -89,15 +98,15 @@ def index_present(name, definition=None):
8998
index=name, body=definition
9099
)
91100
if output:
92-
ret["comment"] = "Successfully created index {}".format(name)
101+
ret["comment"] = f"Successfully created index {name}"
93102
ret["changes"] = {
94103
"new": __salt__["elasticsearch.index_get"](index=name)[name]
95104
}
96105
else:
97106
ret["result"] = False
98-
ret["comment"] = "Cannot create index {}, {}".format(name, output)
107+
ret["comment"] = f"Cannot create index {name}, {output}"
99108
else:
100-
ret["comment"] = "Index {} is already present".format(name)
109+
ret["comment"] = f"Index {name} is already present"
101110
except Exception as err: # pylint: disable=broad-except
102111
ret["result"] = False
103112
ret["comment"] = str(err)
@@ -138,7 +147,7 @@ def alias_absent(name, index):
138147
if ret["result"]:
139148
ret[
140149
"comment"
141-
] = "Successfully removed alias {} for index {}".format(name, index)
150+
] = f"Successfully removed alias {name} for index {index}"
142151
ret["changes"]["old"] = (
143152
alias.get(index, {}).get("aliases", {}).get(name, {})
144153
)
@@ -257,7 +266,7 @@ def index_template_absent(name):
257266
index_template = __salt__["elasticsearch.index_template_get"](name=name)
258267
if index_template and name in index_template:
259268
if __opts__["test"]:
260-
ret["comment"] = "Index template {} will be removed".format(name)
269+
ret["comment"] = f"Index template {name} will be removed"
261270
ret["changes"]["old"] = index_template[name]
262271
ret["result"] = None
263272
else:
@@ -276,7 +285,7 @@ def index_template_absent(name):
276285
name
277286
)
278287
else:
279-
ret["comment"] = "Index template {} is already absent".format(name)
288+
ret["comment"] = f"Index template {name} is already absent"
280289
except Exception as err: # pylint: disable=broad-except
281290
ret["result"] = False
282291
ret["comment"] = str(err)
@@ -318,7 +327,7 @@ def index_template_present(name, definition, check_definition=False):
318327
if __opts__["test"]:
319328
ret[
320329
"comment"
321-
] = "Index template {} does not exist and will be created".format(name)
330+
] = f"Index template {name} does not exist and will be created"
322331
ret["changes"] = {"new": definition}
323332
ret["result"] = None
324333
else:
@@ -371,7 +380,7 @@ def index_template_present(name, definition, check_definition=False):
371380
if output:
372381
ret[
373382
"comment"
374-
] = "Successfully updated index template {}".format(name)
383+
] = f"Successfully updated index template {name}"
375384
ret["changes"] = diff
376385
else:
377386
ret["result"] = False
@@ -387,7 +396,7 @@ def index_template_present(name, definition, check_definition=False):
387396
name
388397
)
389398
else:
390-
ret["comment"] = "Index template {} is already present".format(name)
399+
ret["comment"] = f"Index template {name} is already present"
391400
except Exception as err: # pylint: disable=broad-except
392401
ret["result"] = False
393402
ret["comment"] = str(err)
@@ -409,20 +418,20 @@ def pipeline_absent(name):
409418
pipeline = __salt__["elasticsearch.pipeline_get"](id=name)
410419
if pipeline and name in pipeline:
411420
if __opts__["test"]:
412-
ret["comment"] = "Pipeline {} will be removed".format(name)
421+
ret["comment"] = f"Pipeline {name} will be removed"
413422
ret["changes"]["old"] = pipeline[name]
414423
ret["result"] = None
415424
else:
416425
ret["result"] = __salt__["elasticsearch.pipeline_delete"](id=name)
417426
if ret["result"]:
418-
ret["comment"] = "Successfully removed pipeline {}".format(name)
427+
ret["comment"] = f"Successfully removed pipeline {name}"
419428
ret["changes"]["old"] = pipeline[name]
420429
else:
421430
ret[
422431
"comment"
423-
] = "Failed to remove pipeline {} for unknown reasons".format(name)
432+
] = f"Failed to remove pipeline {name} for unknown reasons"
424433
else:
425-
ret["comment"] = "Pipeline {} is already absent".format(name)
434+
ret["comment"] = f"Pipeline {name} is already absent"
426435
except Exception as err: # pylint: disable=broad-except
427436
ret["result"] = False
428437
ret["comment"] = str(err)
@@ -467,7 +476,7 @@ def pipeline_present(name, definition):
467476
if not pipeline:
468477
ret[
469478
"comment"
470-
] = "Pipeline {} does not exist and will be created".format(name)
479+
] = f"Pipeline {name} does not exist and will be created"
471480
else:
472481
ret["comment"] = (
473482
"Pipeline {} exists with wrong configuration and will be"
@@ -481,7 +490,7 @@ def pipeline_present(name, definition):
481490
)
482491
if output:
483492
if not pipeline:
484-
ret["comment"] = "Successfully created pipeline {}".format(name)
493+
ret["comment"] = f"Successfully created pipeline {name}"
485494
else:
486495
ret["comment"] = "Successfully replaced pipeline {}".format(
487496
name
@@ -492,7 +501,7 @@ def pipeline_present(name, definition):
492501
name, output
493502
)
494503
else:
495-
ret["comment"] = "Pipeline {} is already present".format(name)
504+
ret["comment"] = f"Pipeline {name} is already present"
496505
except Exception as err: # pylint: disable=broad-except
497506
ret["result"] = False
498507
ret["comment"] = str(err)
@@ -514,7 +523,7 @@ def search_template_absent(name):
514523
template = __salt__["elasticsearch.search_template_get"](id=name)
515524
if template:
516525
if __opts__["test"]:
517-
ret["comment"] = "Search template {} will be removed".format(name)
526+
ret["comment"] = f"Search template {name} will be removed"
518527
ret["changes"]["old"] = salt.utils.json.loads(template["template"])
519528
ret["result"] = None
520529
else:
@@ -533,7 +542,7 @@ def search_template_absent(name):
533542
name
534543
)
535544
else:
536-
ret["comment"] = "Search template {} is already absent".format(name)
545+
ret["comment"] = f"Search template {name} is already absent"
537546
except Exception as err: # pylint: disable=broad-except
538547
ret["result"] = False
539548
ret["comment"] = str(err)
@@ -593,20 +602,16 @@ def search_template_present(name, definition):
593602
)
594603
if output:
595604
if not template:
596-
ret[
597-
"comment"
598-
] = "Successfully created search template {}".format(name)
605+
ret["comment"] = f"Successfully created search template {name}"
599606
else:
600-
ret[
601-
"comment"
602-
] = "Successfully replaced search template {}".format(name)
607+
ret["comment"] = f"Successfully replaced search template {name}"
603608
else:
604609
ret["result"] = False
605610
ret["comment"] = "Cannot create search template {}, {}".format(
606611
name, output
607612
)
608613
else:
609-
ret["comment"] = "Search template {} is already present".format(name)
614+
ret["comment"] = f"Search template {name} is already present"
610615
except Exception as err: # pylint: disable=broad-except
611616
ret["result"] = False
612617
ret["comment"] = str(err)

salt/states/elasticsearch_index.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@
1111

1212
log = logging.getLogger(__name__)
1313

14+
__deprecated__ = (
15+
3009,
16+
"elasticsearch",
17+
"https://github.com/cesan3/salt-ext-elasticsearch", # This is the repo with the issues tracker for this module
18+
# and the one that will be used to submit PRs, for now, until
19+
# PR actions are enabled in
20+
# http://salt-extensions/saltext-elasticsearch repo
21+
)
22+
1423

1524
def absent(name):
1625
"""
@@ -26,20 +35,20 @@ def absent(name):
2635
index = __salt__["elasticsearch.index_get"](index=name)
2736
if index and name in index:
2837
if __opts__["test"]:
29-
ret["comment"] = "Index {} will be removed".format(name)
38+
ret["comment"] = f"Index {name} will be removed"
3039
ret["changes"]["old"] = index[name]
3140
ret["result"] = None
3241
else:
3342
ret["result"] = __salt__["elasticsearch.index_delete"](index=name)
3443
if ret["result"]:
35-
ret["comment"] = "Successfully removed index {}".format(name)
44+
ret["comment"] = f"Successfully removed index {name}"
3645
ret["changes"]["old"] = index[name]
3746
else:
3847
ret[
3948
"comment"
40-
] = "Failed to remove index {} for unknown reasons".format(name)
49+
] = f"Failed to remove index {name} for unknown reasons"
4150
else:
42-
ret["comment"] = "Index {} is already absent".format(name)
51+
ret["comment"] = f"Index {name} is already absent"
4352
except Exception as err: # pylint: disable=broad-except
4453
ret["result"] = False
4554
ret["comment"] = str(err)
@@ -94,15 +103,15 @@ def present(name, definition=None):
94103
index=name, body=definition
95104
)
96105
if output:
97-
ret["comment"] = "Successfully created index {}".format(name)
106+
ret["comment"] = f"Successfully created index {name}"
98107
ret["changes"] = {
99108
"new": __salt__["elasticsearch.index_get"](index=name)[name]
100109
}
101110
else:
102111
ret["result"] = False
103-
ret["comment"] = "Cannot create index {}, {}".format(name, output)
112+
ret["comment"] = f"Cannot create index {name}, {output}"
104113
else:
105-
ret["comment"] = "Index {} is already present".format(name)
114+
ret["comment"] = f"Index {name} is already present"
106115
except Exception as err: # pylint: disable=broad-except
107116
ret["result"] = False
108117
ret["comment"] = str(err)

salt/states/elasticsearch_index_template.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@
1111

1212
log = logging.getLogger(__name__)
1313

14+
__deprecated__ = (
15+
3009,
16+
"elasticsearch",
17+
"https://github.com/cesan3/salt-ext-elasticsearch", # This is the repo with the issues tracker for this module
18+
# and the one that will be used to submit PRs, for now, until
19+
# PR actions are enabled in
20+
# http://salt-extensions/saltext-elasticsearch repo
21+
)
22+
1423

1524
def absent(name):
1625
"""
@@ -26,7 +35,7 @@ def absent(name):
2635
index_template = __salt__["elasticsearch.index_template_get"](name=name)
2736
if index_template and name in index_template:
2837
if __opts__["test"]:
29-
ret["comment"] = "Index template {} will be removed".format(name)
38+
ret["comment"] = f"Index template {name} will be removed"
3039
ret["changes"]["old"] = index_template[name]
3140
ret["result"] = None
3241
else:
@@ -45,7 +54,7 @@ def absent(name):
4554
name
4655
)
4756
else:
48-
ret["comment"] = "Index template {} is already absent".format(name)
57+
ret["comment"] = f"Index template {name} is already absent"
4958
except Exception as err: # pylint: disable=broad-except
5059
ret["result"] = False
5160
ret["comment"] = str(err)
@@ -90,7 +99,7 @@ def present(name, definition):
9099
if __opts__["test"]:
91100
ret[
92101
"comment"
93-
] = "Index template {} does not exist and will be created".format(name)
102+
] = f"Index template {name} does not exist and will be created"
94103
ret["changes"] = {"new": definition}
95104
ret["result"] = None
96105
else:
@@ -112,7 +121,7 @@ def present(name, definition):
112121
name, output
113122
)
114123
else:
115-
ret["comment"] = "Index template {} is already present".format(name)
124+
ret["comment"] = f"Index template {name} is already present"
116125
except Exception as err: # pylint: disable=broad-except
117126
ret["result"] = False
118127
ret["comment"] = str(err)

0 commit comments

Comments
 (0)