Skip to content

Commit

Permalink
Vendored Docker SDK for Python code: remove unused constants (#1037)
Browse files Browse the repository at this point in the history
* Remove constants that are never used.

* Adjust unit tests.
  • Loading branch information
felixfontein authored Feb 1, 2025
1 parent 511cfe5 commit bcd6e57
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
4 changes: 0 additions & 4 deletions plugins/module_utils/_api/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import sys

DEFAULT_DOCKER_API_VERSION = '1.41'
MINIMUM_DOCKER_API_VERSION = '1.21'
DEFAULT_TIMEOUT_SECONDS = 60
STREAM_HEADER_SIZE_BYTES = 8
Expand Down Expand Up @@ -45,6 +44,3 @@
DEFAULT_MAX_POOL_SIZE = 10

DEFAULT_DATA_CHUNK_SIZE = 1024 * 2048

DEFAULT_SWARM_ADDR_POOL = ['10.0.0.0/8']
DEFAULT_SWARM_SUBNET_SIZE = 24
4 changes: 2 additions & 2 deletions tests/unit/plugins/module_utils/_api/api/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

from ansible_collections.community.docker.plugins.module_utils._api import constants, errors
from ansible_collections.community.docker.plugins.module_utils._api.api.client import APIClient
from ansible_collections.community.docker.plugins.module_utils._api.constants import DEFAULT_DOCKER_API_VERSION
from ansible_collections.community.docker.tests.unit.plugins.module_utils._api.constants import DEFAULT_DOCKER_API_VERSION
from requests.packages import urllib3

from .. import fake_api
Expand Down Expand Up @@ -109,7 +109,7 @@ def fake_read_from_socket(self, response, stream, tty=False, demux=False):
url_base = '{prefix}/'.format(prefix=fake_api.prefix)
url_prefix = '{0}v{1}/'.format(
url_base,
constants.DEFAULT_DOCKER_API_VERSION)
DEFAULT_DOCKER_API_VERSION)


class BaseAPIClientTest(unittest.TestCase):
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/plugins/module_utils/_api/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
# This code is part of the Ansible collection community.docker, but is an independent component.
# This particular file, and this file only, is based on the Docker SDK for Python (https://github.com/docker/docker-py/)
#
# Copyright (c) 2016-2022 Docker, Inc.
#
# It is licensed under the Apache 2.0 license (see LICENSES/Apache-2.0.txt in this collection)
# SPDX-License-Identifier: Apache-2.0

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

DEFAULT_DOCKER_API_VERSION = '1.45'
3 changes: 2 additions & 1 deletion tests/unit/plugins/module_utils/_api/fake_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
__metaclass__ = type

from ansible_collections.community.docker.plugins.module_utils._api import constants
from ansible_collections.community.docker.tests.unit.plugins.module_utils._api.constants import DEFAULT_DOCKER_API_VERSION

from . import fake_stat

CURRENT_VERSION = 'v{api_version}'.format(api_version=constants.DEFAULT_DOCKER_API_VERSION)
CURRENT_VERSION = 'v{api_version}'.format(api_version=DEFAULT_DOCKER_API_VERSION)

FAKE_CONTAINER_ID = '3cc2351ab11b'
FAKE_IMAGE_ID = 'e9aa60c60128'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
pytestmark = pytest.mark.skip('Python 2.6 is not supported')

from ansible_collections.community.docker.plugins.module_utils._api.api.client import APIClient
from ansible_collections.community.docker.plugins.module_utils._api.constants import DEFAULT_DOCKER_API_VERSION
from ansible_collections.community.docker.plugins.module_utils._api.utils.decorators import update_headers
from ansible_collections.community.docker.tests.unit.plugins.module_utils._api.constants import DEFAULT_DOCKER_API_VERSION


class DecoratorsTest(unittest.TestCase):
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/plugins/module_utils/_api/utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@
pytestmark = pytest.mark.skip('Python 2.6 is not supported')

from ansible_collections.community.docker.plugins.module_utils._api.api.client import APIClient
from ansible_collections.community.docker.plugins.module_utils._api.constants import IS_WINDOWS_PLATFORM, DEFAULT_DOCKER_API_VERSION
from ansible_collections.community.docker.plugins.module_utils._api.constants import IS_WINDOWS_PLATFORM
from ansible_collections.community.docker.plugins.module_utils._api.errors import DockerException
from ansible_collections.community.docker.plugins.module_utils._api.utils.utils import (
convert_filters, convert_volume_binds,
decode_json_header, kwargs_from_env, parse_bytes,
parse_devices, parse_env_file, parse_host,
parse_repository_tag, split_command, format_environment,
)
from ansible_collections.community.docker.tests.unit.plugins.module_utils._api.constants import DEFAULT_DOCKER_API_VERSION


TEST_CERT_DIR = os.path.join(
Expand Down

0 comments on commit bcd6e57

Please sign in to comment.