Skip to content

Commit

Permalink
Run pre-commit after update
Browse files Browse the repository at this point in the history
  • Loading branch information
lkubb committed Aug 12, 2024
1 parent 4e39ad7 commit bcb41c3
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 65 deletions.
1 change: 1 addition & 0 deletions src/saltext/consul/cache/consul.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
.. _`python-consul documentation`: https://python-consul.readthedocs.io/en/latest/#consul
"""

import logging
import time

Expand Down
129 changes: 65 additions & 64 deletions src/saltext/consul/modules/consul.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
https://www.consul.io
"""

import base64
import http.client
import logging
Expand Down Expand Up @@ -298,10 +299,10 @@ def put(consul_url=None, token=None, key=None, value=None, **kwargs):

if "acquire" in kwargs:
if kwargs["acquire"] not in available_sessions:
ret[
"message"
] = "{} is not a valid session.".format( # pylint: disable=consider-using-f-string
kwargs["acquire"]
ret["message"] = (
"{} is not a valid session.".format( # pylint: disable=consider-using-f-string
kwargs["acquire"]
)
)
ret["res"] = False
return ret
Expand All @@ -319,10 +320,10 @@ def put(consul_url=None, token=None, key=None, value=None, **kwargs):
return ret

else:
ret[
"message"
] = "{} is not a valid session.".format( # pylint: disable=consider-using-f-string
kwargs["acquire"]
ret["message"] = (
"{} is not a valid session.".format( # pylint: disable=consider-using-f-string
kwargs["acquire"]
)
)
ret["res"] = False
else:
Expand Down Expand Up @@ -598,10 +599,10 @@ def agent_maintenance(consul_url=None, token=None, **kwargs):
)
if res["res"]:
ret["res"] = True
ret[
"message"
] = "Agent maintenance mode {}ed.".format( # pylint: disable=consider-using-f-string
kwargs["enable"]
ret["message"] = (
"Agent maintenance mode {}ed.".format( # pylint: disable=consider-using-f-string
kwargs["enable"]
)
)
else:
ret["res"] = True
Expand Down Expand Up @@ -780,10 +781,10 @@ def agent_check_register(consul_url=None, token=None, **kwargs):

if res["res"]:
ret["res"] = True
ret[
"message"
] = "Check {} added to agent.".format( # pylint: disable=consider-using-f-string
kwargs["name"]
ret["message"] = (
"Check {} added to agent.".format( # pylint: disable=consider-using-f-string
kwargs["name"]
)
)
else:
ret["res"] = False
Expand Down Expand Up @@ -1095,17 +1096,17 @@ def agent_service_register(consul_url=None, token=None, decode=False, text=True,
)
if res["res"]:
ret["res"] = True
ret[
"message"
] = "Service {} registered on agent.".format( # pylint: disable=consider-using-f-string
kwargs["name"]
ret["message"] = (
"Service {} registered on agent.".format( # pylint: disable=consider-using-f-string
kwargs["name"]
)
)
else:
ret["res"] = False
ret[
"message"
] = "Unable to register service {}.".format( # pylint: disable=consider-using-f-string
kwargs["name"]
ret["message"] = (
"Unable to register service {}.".format( # pylint: disable=consider-using-f-string
kwargs["name"]
)
)
return ret

Expand Down Expand Up @@ -1287,10 +1288,10 @@ def session_create(consul_url=None, token=None, **kwargs):
)
else:
ret["res"] = False
ret[
"message"
] = "Unable to create session {}.".format( # pylint: disable=consider-using-f-string
kwargs["name"]
ret["message"] = (
"Unable to create session {}.".format( # pylint: disable=consider-using-f-string
kwargs["name"]
)
)
return ret

Expand Down Expand Up @@ -1581,17 +1582,17 @@ def catalog_register(consul_url=None, token=None, **kwargs):
res = _query(consul_url=consul_url, function=function, token=token, method="PUT", data=data)
if res["res"]:
ret["res"] = True
ret[
"message"
] = "Catalog registration for {} successful.".format( # pylint: disable=consider-using-f-string
kwargs["node"]
ret["message"] = (
"Catalog registration for {} successful.".format( # pylint: disable=consider-using-f-string
kwargs["node"]
)
)
else:
ret["res"] = False
ret[
"message"
] = "Catalog registration for {} failed.".format( # pylint: disable=consider-using-f-string
kwargs["node"]
ret["message"] = (
"Catalog registration for {} failed.".format( # pylint: disable=consider-using-f-string
kwargs["node"]
)
)
ret["data"] = data
return ret
Expand Down Expand Up @@ -1647,17 +1648,17 @@ def catalog_deregister(consul_url=None, token=None, **kwargs):

if res["res"]:
ret["res"] = True
ret[
"message"
] = "Catalog item {} removed.".format( # pylint: disable=consider-using-f-string
kwargs["node"]
ret["message"] = (
"Catalog item {} removed.".format( # pylint: disable=consider-using-f-string
kwargs["node"]
)
)
else:
ret["res"] = False
ret[
"message"
] = "Removing Catalog item {} failed.".format( # pylint: disable=consider-using-f-string
kwargs["node"]
ret["message"] = (
"Removing Catalog item {} failed.".format( # pylint: disable=consider-using-f-string
kwargs["node"]
)
)
return ret

Expand Down Expand Up @@ -2126,10 +2127,10 @@ def acl_create(consul_url=None, token=None, **kwargs):
)
else:
ret["res"] = False
ret[
"message"
] = "Removing Catalog item {} failed.".format( # pylint: disable=consider-using-f-string
kwargs["name"]
ret["message"] = (
"Removing Catalog item {} failed.".format( # pylint: disable=consider-using-f-string
kwargs["name"]
)
)
return ret

Expand Down Expand Up @@ -2193,10 +2194,10 @@ def acl_update(consul_url=None, token=None, **kwargs):
)
else:
ret["res"] = False
ret[
"message"
] = "Updating ACL {} failed.".format( # pylint: disable=consider-using-f-string
kwargs["name"]
ret["message"] = (
"Updating ACL {} failed.".format( # pylint: disable=consider-using-f-string
kwargs["name"]
)
)

return ret
Expand Down Expand Up @@ -2242,10 +2243,10 @@ def acl_delete(consul_url=None, token=None, **kwargs):
)
else:
ret["res"] = False
ret[
"message"
] = "Removing ACL {} failed.".format( # pylint: disable=consider-using-f-string
kwargs["id"]
ret["message"] = (
"Removing ACL {} failed.".format( # pylint: disable=consider-using-f-string
kwargs["id"]
)
)
ret["changes"] = res

Expand Down Expand Up @@ -2328,10 +2329,10 @@ def acl_clone(consul_url=None, token=None, **kwargs):
ret["ID"] = res["data"]
else:
ret["res"] = False
ret[
"message"
] = "Cloning ACL item {} failed.".format( # pylint: disable=consider-using-f-string
kwargs["name"]
ret["message"] = (
"Cloning ACL item {} failed.".format( # pylint: disable=consider-using-f-string
kwargs["name"]
)
)
return ret

Expand Down Expand Up @@ -2425,10 +2426,10 @@ def event_fire(consul_url=None, token=None, name=None, **kwargs):
ret["data"] = res["data"]
else:
ret["res"] = False
ret[
"message"
] = "Cloning ACL item {} failed.".format( # pylint: disable=consider-using-f-string
kwargs["name"]
ret["message"] = (
"Cloning ACL item {} failed.".format( # pylint: disable=consider-using-f-string
kwargs["name"]
)
)
return ret

Expand Down
2 changes: 1 addition & 1 deletion src/saltext/consul/pillar/consul_pillar.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
- consul: my_consul_config expand_keys=false
"""

import logging
import re

Expand Down Expand Up @@ -312,7 +313,6 @@ def pillar_format(ret, keys, value, expand_keys):


def get_conn(opts, profile):

"""
Return a client object for accessing consul
"""
Expand Down
1 change: 1 addition & 0 deletions src/saltext/consul/sdb/consul.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
The ``driver`` refers to the Consul module, all other options are optional.
For option details see: https://python-consul.readthedocs.io/en/latest/#consul
"""

from salt.exceptions import CommandExecutionError

try:
Expand Down
1 change: 1 addition & 0 deletions src/saltext/consul/states/consul.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
consul.acl_absent:
- id: 38AC8470-4A83-4140-8DFD-F924CD32917F
"""

import logging

log = logging.getLogger(__name__)
Expand Down
1 change: 1 addition & 0 deletions tests/unit/modules/test_consul.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Test case for the consul execution module
"""

import logging
from unittest.mock import MagicMock
from unittest.mock import patch
Expand Down
1 change: 1 addition & 0 deletions tests/unit/states/test_consul.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Test case for the consul state module
"""

import logging
from unittest.mock import MagicMock
from unittest.mock import patch
Expand Down

0 comments on commit bcb41c3

Please sign in to comment.