Skip to content

Commit

Permalink
Merge pull request #448 from Honny1/dev/jrodak/dns-options
Browse files Browse the repository at this point in the history
[release-4.6] Fix dns_option typo and add test of container create with DNS option
  • Loading branch information
openshift-merge-bot[bot] authored Oct 16, 2024
2 parents 36ba65a + e601914 commit 79d7acd
Show file tree
Hide file tree
Showing 46 changed files with 109 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:
FEDORA_NAME: "fedora-38"

# Google-cloud VM Images
IMAGE_SUFFIX: "c20230614t132754z-f38f37d13"
IMAGE_SUFFIX: "c20241015t085508z-f40f39d13"
FEDORA_CACHE_IMAGE_NAME: "fedora-podman-py-${IMAGE_SUFFIX}"


Expand Down
1 change: 1 addition & 0 deletions podman/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Podman client module."""

import sys

assert sys.version_info >= (3, 6), "Python 3.6 or greater is required."
Expand Down
1 change: 1 addition & 0 deletions podman/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tools for connecting to a Podman service."""

import re

from podman.api.cached_property import cached_property
Expand Down
1 change: 1 addition & 0 deletions podman/api/adapter_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions for working with Adapters."""

from typing import NamedTuple, Mapping


Expand Down
1 change: 1 addition & 0 deletions podman/api/cached_property.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide cached_property for Python <=3.8 programs."""

import functools

try:
Expand Down
11 changes: 9 additions & 2 deletions podman/api/client.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""APIClient for connecting to Podman service."""

import json
import urllib.parse
from typing import Any, ClassVar, IO, Iterable, List, Mapping, Optional, Tuple, Type, Union

import requests
from requests.adapters import HTTPAdapter

from podman import api
from podman import api # pylint: disable=cyclic-import
from podman.api.ssh import SSHAdapter
from podman.api.uds import UDSAdapter
from podman.errors import APIError, NotFound
Expand Down Expand Up @@ -90,7 +91,7 @@ def __init__(
use_ssh_client=True,
max_pools_size=None,
**kwargs,
): # pylint: disable=unused-argument
): # pylint: disable=unused-argument,too-many-positional-arguments
"""Instantiate APIClient object.
Args:
Expand Down Expand Up @@ -178,6 +179,7 @@ def _normalize_url(base_url: str) -> urllib.parse.ParseResult:
def delete(
self,
path: Union[str, bytes],
*,
params: Union[None, bytes, Mapping[str, str]] = None,
headers: Optional[Mapping[str, str]] = None,
timeout: _Timeout = None,
Expand Down Expand Up @@ -212,6 +214,7 @@ def delete(
def get(
self,
path: Union[str, bytes],
*,
params: Union[None, bytes, Mapping[str, List[str]]] = None,
headers: Optional[Mapping[str, str]] = None,
timeout: _Timeout = None,
Expand Down Expand Up @@ -246,6 +249,7 @@ def get(
def head(
self,
path: Union[str, bytes],
*,
params: Union[None, bytes, Mapping[str, str]] = None,
headers: Optional[Mapping[str, str]] = None,
timeout: _Timeout = None,
Expand Down Expand Up @@ -280,6 +284,7 @@ def head(
def post(
self,
path: Union[str, bytes],
*,
params: Union[None, bytes, Mapping[str, str]] = None,
data: _Data = None,
headers: Optional[Mapping[str, str]] = None,
Expand Down Expand Up @@ -317,6 +322,7 @@ def post(
def put(
self,
path: Union[str, bytes],
*,
params: Union[None, bytes, Mapping[str, str]] = None,
data: _Data = None,
headers: Optional[Mapping[str, str]] = None,
Expand Down Expand Up @@ -355,6 +361,7 @@ def _request(
self,
method: str,
path: Union[str, bytes],
*,
data: _Data = None,
params: Union[None, bytes, Mapping[str, str]] = None,
headers: Optional[Mapping[str, str]] = None,
Expand Down
1 change: 1 addition & 0 deletions podman/api/http_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions for working with URLs."""

import base64
import collections.abc
import json
Expand Down
1 change: 1 addition & 0 deletions podman/api/parse_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Helper functions for parsing strings."""

import base64
import ipaddress
import json
Expand Down
3 changes: 2 additions & 1 deletion podman/api/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
See Podman go bindings for more details.
"""

import collections
import functools
import logging
Expand Down Expand Up @@ -249,7 +250,7 @@ def __init__(
max_retries: int = DEFAULT_RETRIES,
pool_block: int = DEFAULT_POOLBLOCK,
**kwargs,
):
): # pylint: disable=too-many-positional-arguments
"""Initialize SSHAdapter.
Args:
Expand Down
1 change: 1 addition & 0 deletions podman/api/tar_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions for working with tarballs."""

import pathlib
import random
import shutil
Expand Down
6 changes: 4 additions & 2 deletions podman/api/typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,8 @@ class AsyncContextManager(

__all__.append('AsyncContextManager')
elif sys.version_info[:2] >= (3, 5):
exec("""
exec(
"""
class AsyncContextManager(typing.Generic[T_co]):
__slots__ = ()
Expand All @@ -970,7 +971,8 @@ def __subclasshook__(cls, C):
return NotImplemented
__all__.append('AsyncContextManager')
""")
"""
)

if hasattr(typing, 'DefaultDict'):
DefaultDict = typing.DefaultDict
Expand Down
3 changes: 2 additions & 1 deletion podman/api/uds.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Specialized Transport Adapter for UNIX domain sockets."""

import collections
import functools
import logging
Expand Down Expand Up @@ -136,7 +137,7 @@ def __init__(
max_retries=DEFAULT_RETRIES,
pool_block=DEFAULT_POOLBLOCK,
**kwargs,
):
): # pylint: disable=too-many-positional-arguments
"""Initialize UDSAdapter.
Args:
Expand Down
2 changes: 2 additions & 0 deletions podman/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Client for connecting to Podman service."""

import logging
import os
from contextlib import AbstractContextManager
Expand Down Expand Up @@ -84,6 +85,7 @@ def __exit__(self, exc_type, exc_value, traceback) -> None:
@classmethod
def from_env(
cls,
*,
version: str = "auto",
timeout: Optional[int] = None,
max_pool_size: Optional[int] = None,
Expand Down
1 change: 1 addition & 0 deletions podman/domain/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Read containers.conf file."""

import sys
import urllib
from pathlib import Path
Expand Down
12 changes: 7 additions & 5 deletions podman/domain/containers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Model and Manager for Container resources."""

import json
import logging
import shlex
Expand Down Expand Up @@ -124,22 +125,23 @@ def diff(self) -> List[Dict[str, int]]:
response.raise_for_status()
return response.json()

# pylint: disable=too-many-arguments,unused-argument
# pylint: disable=too-many-arguments
def exec_run(
self,
cmd: Union[str, List[str]],
*,
stdout: bool = True,
stderr: bool = True,
stdin: bool = False,
tty: bool = True,
privileged: bool = False,
user=None,
detach: bool = False,
stream: bool = False,
socket: bool = False,
stream: bool = False, # pylint: disable=unused-argument
socket: bool = False, # pylint: disable=unused-argument
environment: Union[Mapping[str, str], List[str]] = None,
workdir: str = None,
demux: bool = False,
demux: bool = False, # pylint: disable=unused-argument
) -> Tuple[Optional[int], Union[Iterator[bytes], Any, Tuple[bytes, bytes]]]:
"""Run given command inside container and return results.
Expand Down Expand Up @@ -216,7 +218,7 @@ def export(self, chunk_size: int = api.DEFAULT_CHUNK_SIZE) -> Iterator[bytes]:
response = self.client.get(f"/containers/{self.id}/export", stream=True)
response.raise_for_status()

for out in response.iter_content(chunk_size=chunk_size):
for out in response.iter_content(chunk_size=chunk_size): # pylint: disable=use-yield-from
yield out

def get_archive(
Expand Down
3 changes: 2 additions & 1 deletion podman/domain/containers_create.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Mixin to provide Container create() method."""

import copy
import logging
import re
Expand Down Expand Up @@ -384,7 +385,7 @@ def to_bytes(size: Union[int, str, None]) -> Union[int, None]:
"conmon_pid_file": pop("conmon_pid_file"), # TODO document, podman only
"containerCreateCommand": pop("containerCreateCommand"), # TODO document, podman only
"devices": [],
"dns_options": pop("dns_opt"),
"dns_option": pop("dns_opt"),
"dns_search": pop("dns_search"),
"dns_server": pop("dns"),
"entrypoint": pop("entrypoint"),
Expand Down
1 change: 1 addition & 0 deletions podman/domain/containers_manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""PodmanResource manager subclassed for Containers."""

import logging
import urllib
from typing import Any, Dict, List, Mapping, Union
Expand Down
1 change: 1 addition & 0 deletions podman/domain/containers_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def run(
self,
image: Union[str, Image],
command: Union[str, List[str], None] = None,
*,
stdout=True,
stderr=False,
remove: bool = False,
Expand Down
1 change: 1 addition & 0 deletions podman/domain/events.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Model and Manager for Event resources."""

import json
import logging
from datetime import datetime
Expand Down
1 change: 1 addition & 0 deletions podman/domain/images.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Model and Manager for Image resources."""

import logging
from typing import Any, Dict, Iterator, List, Optional, Union

Expand Down
1 change: 1 addition & 0 deletions podman/domain/images_build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Mixin for Image build support."""

import json
import logging
import pathlib
Expand Down
1 change: 1 addition & 0 deletions podman/domain/images_manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""PodmanResource manager subclassed for Images."""

import io
import json
import logging
Expand Down
1 change: 1 addition & 0 deletions podman/domain/ipam.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Provided for compatibility
"""

from typing import Any, List, Mapping, Optional


Expand Down
1 change: 1 addition & 0 deletions podman/domain/manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base classes for PodmanResources and Manager's."""

from abc import ABC, abstractmethod
from collections import abc
from typing import Any, List, Mapping, Optional, TypeVar, Union
Expand Down
1 change: 1 addition & 0 deletions podman/domain/manifests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Model and Manager for Manifest resources."""

import logging
import urllib.parse
from contextlib import suppress
Expand Down
1 change: 1 addition & 0 deletions podman/domain/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
net = client.networks.get("db_network")
print(net.name, "\n")
"""

import hashlib
import json
import logging
Expand Down
1 change: 1 addition & 0 deletions podman/domain/networks_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
for net in client.networks.list():
print(net.id, "\n")
"""

import ipaddress
import logging
import sys
Expand Down
1 change: 1 addition & 0 deletions podman/domain/pods.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Model and Manager for Pod resources."""

import logging
from typing import Any, Dict, Optional, Tuple, Union

Expand Down
1 change: 1 addition & 0 deletions podman/domain/pods_manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""PodmanResource manager subclassed for Networks."""

import json
import logging
from typing import Any, Dict, List, Optional, Union, Iterator
Expand Down
1 change: 1 addition & 0 deletions podman/domain/registry_data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for tracking registry metadata."""

import logging
from typing import Any, Mapping, Optional, Union

Expand Down
1 change: 1 addition & 0 deletions podman/domain/secrets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Model and Manager for Secrets resources."""

from contextlib import suppress
from typing import Any, List, Mapping, Optional, Union

Expand Down
3 changes: 2 additions & 1 deletion podman/domain/system.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""SystemManager to provide system level information from Podman service."""

import logging
from typing import Any, Dict, Optional

Expand Down Expand Up @@ -35,7 +36,7 @@ def info(self, *_, **__) -> Dict[str, Any]:
response.raise_for_status()
return response.json()

def login(
def login( # pylint: disable=too-many-arguments,too-many-positional-arguments,unused-argument
self,
username: str,
password: Optional[str] = None,
Expand Down
1 change: 1 addition & 0 deletions podman/domain/volumes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Model and Manager for Volume resources."""

import logging
from typing import Any, Dict, List, Optional, Union

Expand Down
1 change: 1 addition & 0 deletions podman/errors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
ApiConnection and associated classes have been deprecated.
"""

import warnings
from http.client import HTTPException

Expand Down
3 changes: 2 additions & 1 deletion podman/errors/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Podman API Errors."""

import typing
from typing import Iterable, List, Optional, Union

Expand Down Expand Up @@ -115,7 +116,7 @@ def __init__(
command: Union[str, List[str]],
image: str,
stderr: Optional[Iterable[str]] = None,
):
): # pylint: disable=too-many-positional-arguments
"""Initialize ContainerError.
Args:
Expand Down
Loading

0 comments on commit 79d7acd

Please sign in to comment.