Skip to content

Commit

Permalink
Update documentation of encoding kwarg
Browse files Browse the repository at this point in the history
  • Loading branch information
dwoz committed Dec 11, 2023
1 parent 7a36644 commit c51c7e8
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions salt/states/postgres_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ def present(
Default tablespace for the database
encoding
The character encoding scheme to be used in this database
The character encoding scheme to be used in this database. The encoding
has to be defined in the following format (without hyphen).
.. code-block:: yaml
- encoding: UTF8
lc_collate
The LC_COLLATE setting to be used in this database
Expand Down Expand Up @@ -89,7 +94,7 @@ def present(
"name": name,
"changes": {},
"result": True,
"comment": "Database {} is already present".format(name),
"comment": f"Database {name} is already present",
}

db_args = {
Expand Down Expand Up @@ -138,11 +143,11 @@ def present(
if __opts__["test"]:
ret["result"] = None
if name not in dbs:
ret["comment"] = "Database {} is set to be created".format(name)
ret["comment"] = f"Database {name} is set to be created"
else:
ret[
"comment"
] = "Database {} exists, but parameters need to be changed".format(name)
] = f"Database {name} exists, but parameters need to be changed"
return ret
if name not in dbs and __salt__["postgres.db_create"](
name,
Expand All @@ -152,20 +157,20 @@ def present(
lc_ctype=lc_ctype,
owner=owner,
template=template,
**db_args
**db_args,
):
ret["comment"] = "The database {} has been created".format(name)
ret["comment"] = f"The database {name} has been created"
ret["changes"][name] = "Present"
elif name in dbs and __salt__["postgres.db_alter"](
name, tablespace=tablespace, owner=owner, owner_recurse=owner_recurse, **db_args
):
ret["comment"] = "Parameters for database {} have been changed".format(name)
ret["comment"] = f"Parameters for database {name} have been changed"
ret["changes"][name] = "Parameters changed"
elif name in dbs:
ret["comment"] = "Failed to change parameters for database {}".format(name)
ret["comment"] = f"Failed to change parameters for database {name}"
ret["result"] = False
else:
ret["comment"] = "Failed to create database {}".format(name)
ret["comment"] = f"Failed to create database {name}"
ret["result"] = False

return ret
Expand Down Expand Up @@ -217,13 +222,13 @@ def absent(
if __salt__["postgres.db_exists"](name, **db_args):
if __opts__["test"]:
ret["result"] = None
ret["comment"] = "Database {} is set to be removed".format(name)
ret["comment"] = f"Database {name} is set to be removed"
return ret
if __salt__["postgres.db_remove"](name, **db_args):
ret["comment"] = "Database {} has been removed".format(name)
ret["comment"] = f"Database {name} has been removed"
ret["changes"][name] = "Absent"
return ret

# fallback
ret["comment"] = "Database {} is not present, so it cannot be removed".format(name)
ret["comment"] = f"Database {name} is not present, so it cannot be removed"
return ret

0 comments on commit c51c7e8

Please sign in to comment.