Skip to content

Commit

Permalink
Apply pre-commit fix
Browse files Browse the repository at this point in the history
From the artifact of the previous workflow run
  • Loading branch information
geo-ghci-int[bot] committed Dec 2, 2024
1 parent c9ce2a4 commit 9923ea3
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 36 deletions.
11 changes: 11 additions & 0 deletions c2cciutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def merge(default_config: Any, config: Any) -> Any:
Arguments:
default_config: The default config that will be applied
config: The base config, will be modified
"""
if not isinstance(default_config, dict) or not isinstance(config, dict):
return config
Expand Down Expand Up @@ -155,6 +156,7 @@ def error(
line: The line number of the error
col: The column number of the error
error_type: The kind of error (error or warning)
"""
result = ""
on_ci = os.environ.get("CI", "false").lower() == "true"
Expand Down Expand Up @@ -197,6 +199,7 @@ def compile_re(config: c2cciutils.configuration.VersionTransform, prefix: str =
prefix: The version prefix
Return the compiled transform config.
"""
result = []
for conf in config:
Expand Down Expand Up @@ -226,6 +229,7 @@ def match(
Returns the re match object, the matched config and the value as a tuple
On no match it returns None, value
"""
for conf in config:
matched = conf["from"].match(value)
Expand All @@ -243,6 +247,7 @@ def does_match(value: str, config: list[VersionTransform]) -> bool:
config: The result of `compile`
Returns True it it does match else False
"""
matched, _, _ = match(value, config)
return matched is not None
Expand All @@ -262,6 +267,7 @@ def get_value(matched: Optional[Match[str]], config: Optional[VersionTransform],
value: The default value on returned no match
Return the value
"""
return matched.expand(config.get("to", r"\1")) if matched is not None and config is not None else value

Expand All @@ -272,6 +278,7 @@ def print_versions(config: c2cciutils.configuration.PrintVersions) -> bool:
Arguments:
config: The print configuration
"""
for version in config.get("versions", c2cciutils.configuration.PRINT_VERSIONS_VERSIONS_DEFAULT):
try:
Expand Down Expand Up @@ -310,6 +317,7 @@ def gopass(key: str, default: Optional[str] = None) -> Optional[str]:
default: the value to return if gopass is not found
Return the value
"""
try:
return subprocess.check_output(["gopass", "show", key]).strip().decode()
Expand All @@ -326,6 +334,7 @@ def gopass_put(secret: str, key: str) -> None:
Arguments:
secret: The secret value
key: The key
"""
subprocess.check_output(["gopass", "insert", "--force", key], input=secret.encode())

Expand All @@ -338,6 +347,7 @@ def add_authorization_header(headers: dict[str, str]) -> dict[str, str]:
headers: The headers
Return the headers (to be chained)
"""
try:
token = (
Expand Down Expand Up @@ -375,6 +385,7 @@ def graphql(query_file: str, variables: dict[str, Any], default: Any = None) ->
Return the data result
In case of error it throw an exception
"""
with open(os.path.join(os.path.dirname(__file__), query_file), encoding="utf-8") as query_open:
query = query_open.read()
Expand Down
6 changes: 3 additions & 3 deletions c2cciutils/applications_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Automatically generated file from a JSON schema.
"""

from typing import Literal, TypedDict, Union
from typing import Dict, List, Literal, TypedDict, Union

# | Application configuration.
# |
Expand All @@ -29,13 +29,13 @@
# | The tile name to get in the tar file.
"tar-file-name": str,
# | The commands to run after the tile creation.
"finish-commands": list[list[str]],
"finish-commands": List[List[str]],
},
total=False,
)


ApplicationsConfiguration = dict[str, "ApplicationConfiguration"]
ApplicationsConfiguration = Dict[str, "ApplicationConfiguration"]
"""
Applications configuration.
Expand Down
64 changes: 32 additions & 32 deletions c2cciutils/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Automatically generated file from a JSON schema.
"""

from typing import Any, Literal, TypedDict, Union
from typing import Any, Dict, List, Literal, TypedDict, Union


class Configuration(TypedDict, total=False):
Expand Down Expand Up @@ -61,11 +61,11 @@ class Configuration(TypedDict, total=False):
"""


DB_CONFIGURATION_DEFAULT: dict[str, Any] = {}
DB_CONFIGURATION_DEFAULT: Dict[str, Any] = {}
""" Default value of the field path 'K8s configuration db' """


DISPATCH_CONFIG_DEFAULT: dict[str, Any] = {}
DISPATCH_CONFIG_DEFAULT: Dict[str, Any] = {}
""" Default value of the field path 'Publish Docker config dispatch oneof0' """


Expand Down Expand Up @@ -101,7 +101,7 @@ class Configuration(TypedDict, total=False):
# | tls.autoGenerated: 'true'
# | tls.enabled: 'true'
# | volumePermissions.enabled: 'true'
"chart-options": dict[str, str],
"chart-options": Dict[str, str],
},
total=False,
)
Expand Down Expand Up @@ -140,14 +140,14 @@ class Dpkg(TypedDict, total=False):
The configuration use t manage the dpkg packages
"""

packages_mapping: dict[str, str]
packages_mapping: Dict[str, str]
"""
dpkg packages mapping.
The mapping of source package found in the image to package present in repology.org
"""

ignored_packages: list[str]
ignored_packages: List[str]
"""
dpkg ignored packages.
Expand All @@ -171,13 +171,13 @@ class Dpkg(TypedDict, total=False):
# | - test-cluster
# | - --no-lb
# | - --no-rollback
"install-commands": list[list[str]],
"install-commands": List[List[str]],
},
total=False,
)


K3D_CONFIGURATION_DEFAULT: dict[str, Any] = {}
K3D_CONFIGURATION_DEFAULT: Dict[str, Any] = {}
""" Default value of the field path 'K8s configuration k3d' """


Expand Down Expand Up @@ -212,7 +212,7 @@ class K8SConfiguration(TypedDict, total=False):
"""


K8S_CONFIGURATION_DEFAULT: dict[str, Any] = {}
K8S_CONFIGURATION_DEFAULT: Dict[str, Any] = {}
""" Default value of the field path 'configuration k8s' """


Expand Down Expand Up @@ -272,11 +272,11 @@ class K8SConfiguration(TypedDict, total=False):
""" Default value of the field path 'Publish Docker config snyk test_args' """


PUBLISH_GOOGLE_CALENDAR_CONFIG_DEFAULT: dict[str, Any] = {}
PUBLISH_GOOGLE_CALENDAR_CONFIG_DEFAULT: Dict[str, Any] = {}
""" Default value of the field path 'Publish Google calendar oneof0' """


PUBLISH_GOOGLE_CALENDAR_DEFAULT: dict[str, Any] = {}
PUBLISH_GOOGLE_CALENDAR_DEFAULT: Dict[str, Any] = {}
""" Default value of the field path 'publish_google_calendar' """


Expand All @@ -288,11 +288,11 @@ class K8SConfiguration(TypedDict, total=False):
""" Default value of the field path 'publish pypi package group' """


PUBLISH_PYPI_CONFIG_DEFAULT: dict[str, Any] = {}
PUBLISH_PYPI_CONFIG_DEFAULT: Dict[str, Any] = {}
""" Default value of the field path 'publish pypi oneof0' """


PUBLISH_PYPI_DEFAULT: dict[str, Any] = {}
PUBLISH_PYPI_DEFAULT: Dict[str, Any] = {}
""" Default value of the field path 'publish_pypi' """


Expand All @@ -303,7 +303,7 @@ class PrintVersions(TypedDict, total=False):
The print versions configuration
"""

versions: list["_PrintVersionsVersionsItem"]
versions: List["_PrintVersionsVersionsItem"]
"""
Print versions versions.
Expand Down Expand Up @@ -446,10 +446,10 @@ class PublishDockerConfig(TypedDict, total=False):
default: True
"""

images: list["PublishDockerImage"]
images: List["PublishDockerImage"]
""" List of images to be published """

repository: dict[str, "PublishDockerRepository"]
repository: Dict[str, "PublishDockerRepository"]
"""
Docker repository.
Expand Down Expand Up @@ -495,7 +495,7 @@ class PublishDockerImage(TypedDict, total=False):
name: str
""" The image name """

tags: list[str]
tags: List[str]
"""
publish docker image tags.
Expand All @@ -512,7 +512,7 @@ class PublishDockerRepository(TypedDict, total=False):
server: str
""" The server URL """

versions: list[str]
versions: List[str]
"""
Publish Docker repository versions.
Expand Down Expand Up @@ -550,7 +550,7 @@ class PublishGoogleCalendarConfig(TypedDict, total=False):
{}
"""

on: list[str]
on: List[str]
"""
Publish Google calendar on.
Expand Down Expand Up @@ -579,10 +579,10 @@ class PublishHelmConfig(TypedDict, total=False):
Configuration to publish on Helm charts on GitHub release
"""

folders: list[str]
folders: List[str]
""" The folders that will be published """

versions: list[str]
versions: List[str]
""" The kind or version that should be published, tag, branch or value of the --version argument of the c2cciutils-publish script """


Expand Down Expand Up @@ -610,10 +610,10 @@ class PublishPypiConfig(TypedDict, total=False):
{}
"""

packages: list["PublishPypiPackage"]
packages: List["PublishPypiPackage"]
""" The configuration of packages that will be published """

versions: list[str]
versions: List[str]
""" The kind or version that should be published, tag, branch or value of the --version argument of the c2cciutils-publish script """


Expand All @@ -636,7 +636,7 @@ class PublishPypiPackage(TypedDict, total=False):
path: str
""" The path of the pypi package """

build_command: list[str]
build_command: List[str]
""" The command used to do the build """


Expand All @@ -662,19 +662,19 @@ class Version(TypedDict, total=False):
"""


VersionTransform = list["_VersionTransformItem"]
VersionTransform = List["_VersionTransformItem"]
"""
Version transform.
A version transformer definition
"""


_PUBLISH_DOCKER_CONFIG_DISPATCH_DEFAULT: dict[str, Any] = {}
_PUBLISH_DOCKER_CONFIG_DISPATCH_DEFAULT: Dict[str, Any] = {}
""" Default value of the field path 'Publish Docker config dispatch' """


_PUBLISH_DOCKER_CONFIG_DISPATCH_ONEOF1_DEFAULT: dict[str, Any] = {}
_PUBLISH_DOCKER_CONFIG_DISPATCH_ONEOF1_DEFAULT: Dict[str, Any] = {}
""" Default value of the field path 'Publish Docker config dispatch oneof1' """


Expand All @@ -694,16 +694,16 @@ class Version(TypedDict, total=False):
""" Default value of the field path 'Publish Docker Snyk test args oneof1' """


_PUBLISH_GOOGLE_CALENDAR_ONEOF1_DEFAULT: dict[str, Any] = {}
_PUBLISH_GOOGLE_CALENDAR_ONEOF1_DEFAULT: Dict[str, Any] = {}
""" Default value of the field path 'Publish Google calendar oneof1' """


_PUBLISH_PYPI_ONEOF1_DEFAULT: dict[str, Any] = {}
_PUBLISH_PYPI_ONEOF1_DEFAULT: Dict[str, Any] = {}
""" Default value of the field path 'publish pypi oneof1' """


class _PrintVersionsVersionsItem(TypedDict, total=False):
cmd: list[str]
cmd: List[str]
""" The command that should be used """

name: str
Expand Down Expand Up @@ -749,7 +749,7 @@ class _PublishDockerConfigSnyk(TypedDict, total=False):
"""


_PublishDockerSnykMonitorArgsOneof0 = list[str]
_PublishDockerSnykMonitorArgsOneof0 = List[str]
"""
default:
- --app-vulns
Expand All @@ -763,7 +763,7 @@ class _PublishDockerConfigSnyk(TypedDict, total=False):
"""


_PublishDockerSnykTestArgsOneof0 = list[str]
_PublishDockerSnykTestArgsOneof0 = List[str]
"""
default:
- --app-vulns
Expand Down
2 changes: 2 additions & 0 deletions c2cciutils/lib/oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ def pypi_login() -> None:
Connect to PyPI using OpenID Connect and mint a token for the user.
See Also
--------
- https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/about-security-hardening-with-openid-connect
- https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-pypi
"""
pypirc_filename = os.path.expanduser("~/.pypirc")

Expand Down
Loading

0 comments on commit 9923ea3

Please sign in to comment.