Skip to content

Commit

Permalink
Merge pull request #382 from user-cont/1.0.0-release
Browse files Browse the repository at this point in the history
1.0.0 release
  • Loading branch information
jpopelka authored Nov 27, 2020
2 parents 0f5dbc8 + 234a8a4 commit dee6fd9
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 44 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 1.0.0

* Conu is now under MIT license
* New buildah backend
* Docker backend supports Skopeo for copying


# 0.7.1

## Breaking changes
Expand Down
20 changes: 8 additions & 12 deletions conu.spec
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
%global pypi_name conu

Name: %{pypi_name}
Version: 0.7.1
Release: 3%{?dist}
Version: 1.0.0
Release: 1%{?dist}
Summary: library which makes it easy to write tests for your containers

License: MIT
URL: https://github.com/fedora-modularity/conu
Source0: https://files.pythonhosted.org/packages/source/c/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
BuildArch: noarch
# exclude ppc64 because there is no docker package
# exclude ppc64 because there is no moby-engine package
# https://bugzilla.redhat.com/show_bug.cgi?id=1547049
ExcludeArch: ppc64

Expand All @@ -31,14 +31,7 @@ BuildRequires: python3-docker
BuildRequires: python3-requests
BuildRequires: python3-pyxattr
BuildRequires: python3-six
Requires: python3-kubernetes
Requires: python3-docker
Requires: python3-requests
Requires: python3-pyxattr
Requires: python3-six
# this is the only way to create containers right now
Requires: docker
# these are optional but still recommended
Recommends: moby-engine
Recommends: source-to-image
Recommends: acl
Recommends: libselinux-utils
Expand All @@ -52,7 +45,6 @@ images and provides more, very helpful functions.
%package -n python3-%{pypi_name}-pytest
Summary: fixtures which can be utilized via pytest
%{?python_provide:%python_provide python3-%{pypi_name}-pytest}
Requires: python3-pytest
Requires: python3-%{pypi_name}

%description -n python3-%{pypi_name}-pytest
Expand Down Expand Up @@ -98,6 +90,10 @@ rm -rf html/.{doctrees,buildinfo}
%license LICENSE

%changelog
* Thu Nov 26 2020 Jiri Popelka <jpopelka@redhat.com> - 1.0.0-1
- 1.0.0 release
- removed explicit Requires

* Thu Nov 26 2020 Jiri Popelka <jpopelka@redhat.com> - 0.7.1-3
- Change license from GPLv3+ to MIT

Expand Down
2 changes: 1 addition & 1 deletion conu/backend/docker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def inspect_to_metadata(metadata_object, inspect_data):
metadata_object.identifier = identifier

# format of Environment Variables from docker inspect:
# ['DISTTAG=f26container', 'FGC=f26']
# ['DISTTAG=f33container', 'FGC=f33']
raw_env_vars = graceful_get(inspect_data, "Config", "Env") or []
if raw_env_vars:
metadata_object.env_variables = {}
Expand Down
2 changes: 1 addition & 1 deletion conu/backend/podman/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def inspect_to_metadata(metadata_object, inspect_data):
metadata_object.identifier = identifier

# format of Environment Variables from podman inspect:
# ['DISTTAG=f26container', 'FGC=f26']
# ['DISTTAG=f33container', 'FGC=f33']
raw_env_vars = graceful_get(inspect_data, "Config", "Env") or []
if raw_env_vars:
metadata_object.env_variables = {}
Expand Down
2 changes: 1 addition & 1 deletion conu/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# SPDX-License-Identifier: MIT
#
# https://www.python.org/dev/peps/pep-0440/
__version__ = '0.7.1'
__version__ = '1.0.0'
5 changes: 3 additions & 2 deletions tests/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

FEDORA_REPOSITORY = "registry.fedoraproject.org/fedora"
FEDORA_MINIMAL_REPOSITORY = "registry.fedoraproject.org/fedora-minimal"
FEDORA_MINIMAL_REPOSITORY_TAG = "26"
FEDORA_MINIMAL_REPOSITORY_TAG = "33"
FEDORA_MINIMAL_REPOSITORY_DIGEST = "registry.fedoraproject.org/fedora-minimal@" \
"sha256:3b5147b65bf7d124b9ded3959b5e44bf392b405be219853dbcc346f8b9c06e88"
"sha256:51ff92dc28e9ef4bbd6400ea1d0845c00c25149bc6902897eeb73b0ad469b7e9"
FEDORA_MINIMAL_IMAGE = "{}:{}".format(FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG)
FEDORA_RELEASE = "Fedora release 33 (Thirty Three)\n"
S2I_IMAGE = "punchbag"

THE_HELPER_IMAGE = "rudolph"
Expand Down
28 changes: 17 additions & 11 deletions tests/integration/test_buildah.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from conu.backend.buildah.container import BuildahRunBuilder
from conu.backend.buildah.image import BuildahImage, BuildahImagePullPolicy
from conu.utils import check_buildah_command_works
from tests.constants import FEDORA_MINIMAL_IMAGE
from tests.constants import FEDORA_MINIMAL_IMAGE, FEDORA_MINIMAL_REPOSITORY_DIGEST
from ..constants import FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG


Expand All @@ -28,7 +28,7 @@ def test_buildah_image(buildah_backend):
insp = image.inspect()
assert "Config" in insp
assert isinstance(insp["Config"], str)
assert "registry.fedoraproject.org/fedora-minimal:26" == str(image)
assert "registry.fedoraproject.org/fedora-minimal:33" == str(image)
assert "BuildahImage(repository=%s, tag=%s)" % (FEDORA_MINIMAL_REPOSITORY,
FEDORA_MINIMAL_REPOSITORY_TAG) == repr(image)
assert isinstance(image.get_id(), string_types)
Expand Down Expand Up @@ -128,7 +128,7 @@ def test_list_containers(buildah_backend):
cont_under_test = [x for x in container_list
if x.metadata.name == container_name][0]
assert cont_under_test.metadata.image
assert cont_under_test.metadata.image.get_full_name() == FEDORA_MINIMAL_IMAGE
assert cont_under_test.metadata.image.get_full_name() == FEDORA_MINIMAL_REPOSITORY_DIGEST
assert cont_under_test.metadata.command
finally:
c.delete(force=True)
Expand All @@ -137,7 +137,7 @@ def test_list_containers(buildah_backend):
def test_list_images(buildah_backend):
image_list = buildah_backend.list_images()
assert len(image_list) > 0
# id of registry.fedoraproject.org/fedora-minimal:26
# id of registry.fedoraproject.org/fedora-minimal:33
assert isinstance(image_list[0], BuildahImage)
assert image_list[0].get_id()
assert image_list[0].get_full_name()
Expand All @@ -149,10 +149,13 @@ def test_image_metadata(buildah_backend):
im_metadata = image.get_metadata()

assert im_metadata.command == ["/bin/bash"]
assert im_metadata.name == FEDORA_MINIMAL_IMAGE
assert im_metadata.env_variables["FGC"] == "f26"
assert im_metadata.env_variables["DISTTAG"] == "f26container"
assert im_metadata.labels == {}
assert im_metadata.name == FEDORA_MINIMAL_REPOSITORY_DIGEST
assert im_metadata.env_variables["FGC"] == "f33"
assert im_metadata.env_variables["DISTTAG"] == "f33container"
assert im_metadata.labels == {'license': 'MIT',
'name': 'fedora',
'vendor': 'Fedora Project',
'version': '33'}


def test_container_metadata(buildah_backend):
Expand All @@ -169,8 +172,11 @@ def test_container_metadata(buildah_backend):

assert container_metadata.command == ["/bin/bash"]
assert container_metadata.name == "mycontainer"
assert container_metadata.env_variables["FGC"] == "f26"
assert container_metadata.env_variables["DISTTAG"] == "f26container"
assert container_metadata.labels == {}
assert container_metadata.env_variables["FGC"] == "f33"
assert container_metadata.env_variables["DISTTAG"] == "f33container"
assert container_metadata.labels == {'license': 'MIT',
'name': 'fedora',
'vendor': 'Fedora Project',
'version': '33'}
finally:
c.delete(force=True)
13 changes: 7 additions & 6 deletions tests/integration/test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from conu.utils import parse_reference
from ..constants import FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG, \
FEDORA_REPOSITORY
FEDORA_REPOSITORY, FEDORA_RELEASE

from conu.apidefs.metadata import ContainerStatus
from conu.backend.docker.client import get_client
Expand Down Expand Up @@ -125,8 +125,8 @@ def test_image():
image = backend.ImageClass(FEDORA_MINIMAL_REPOSITORY, tag=FEDORA_MINIMAL_REPOSITORY_TAG)
assert "Config" in image.inspect()
assert "Config" in image.inspect()
assert "fedora-minimal:26" in image.get_full_name()
assert "registry.fedoraproject.org/fedora-minimal:26" == str(image)
assert "fedora-minimal:33" in image.get_full_name()
assert "registry.fedoraproject.org/fedora-minimal:33" == str(image)
assert "DockerImage(repository=%s, tag=%s)" % (FEDORA_MINIMAL_REPOSITORY,
FEDORA_MINIMAL_REPOSITORY_TAG) == repr(image)
assert isinstance(image.get_id(), string_types)
Expand Down Expand Up @@ -184,9 +184,9 @@ def test_copy_from(tmpdir):
command=["cat"], additional_opts=["-i", "-t"]
)
try:
c.copy_from("/etc/fedora-release", str(tmpdir))
c.copy_from("/usr/lib/fedora-release", str(tmpdir))
with open(os.path.join(str(tmpdir), "fedora-release")) as fd:
assert fd.read() == "Fedora release 26 (Twenty Six)\n"
assert fd.read() == FEDORA_RELEASE

c.copy_from("/etc", str(tmpdir))
os.path.exists(os.path.join(str(tmpdir), "passwd"))
Expand Down Expand Up @@ -456,7 +456,8 @@ def test_list_images():
with DockerBackend() as backend:
image_list = backend.list_images()
assert len(image_list) > 0
the_id = "756d8881fb18271a1d55f6ee7e355aaf38fb2973f5fbb0416cf5de628624318b"
# buildah inspect --type image registry.fedoraproject.org/fedora-minimal:33 | grep FromImageID
the_id = "4963469931459d30a6645fcde7df97cd1778e073269304bc9002a56f24a6eb74"
image_under_test = [x for x in image_list if x.metadata.identifier == the_id][0]
assert image_under_test.metadata.digest
assert image_under_test.metadata.repo_digests
Expand Down
14 changes: 7 additions & 7 deletions tests/integration/test_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from conu.backend.docker.backend import DockerBackend
from conu.backend.docker.container import ConuException

from ..constants import FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG
from ..constants import FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG, FEDORA_RELEASE


@pytest.fixture()
Expand Down Expand Up @@ -43,14 +43,14 @@ def test_container_read_file(docker_container):
with pytest.raises(ConuException):
fs.read_file("/i/lost/my/banana")
content = fs.read_file("/etc/system-release")
assert content == "Fedora release 26 (Twenty Six)\n"
assert content == FEDORA_RELEASE


def test_container_copy_from(docker_container, tmpdir):
with docker_container.mount() as fs:
fs.copy_from("/etc/system-release", str(tmpdir))
with open(os.path.join(str(tmpdir), "system-release")) as fd:
assert fd.read() == "Fedora release 26 (Twenty Six)\n"
assert fd.read() == FEDORA_RELEASE

tmpdir.mkdir("etc")
if six.PY2:
Expand All @@ -66,7 +66,7 @@ def test_container_get_file(docker_container):
f = fs.get_file("/etc/system-release")
assert f.fileno()
assert "/etc/system-release" in f.name
assert f.read() == "Fedora release 26 (Twenty Six)\n"
assert f.read() == FEDORA_RELEASE
f.close()


Expand Down Expand Up @@ -109,14 +109,14 @@ def test_image_read_file(docker_image):
with pytest.raises(ConuException):
fs.read_file("/i/lost/my/banana")
content = fs.read_file("/etc/system-release")
assert content == "Fedora release 26 (Twenty Six)\n"
assert content == FEDORA_RELEASE


def test_image_copy_from(docker_image, tmpdir):
with docker_image.mount() as fs:
fs.copy_from("/etc/system-release", str(tmpdir))
with open(os.path.join(str(tmpdir), "system-release")) as fd:
assert fd.read() == "Fedora release 26 (Twenty Six)\n"
assert fd.read() == FEDORA_RELEASE

tmpdir.mkdir("etc")
if six.PY2:
Expand All @@ -132,7 +132,7 @@ def test_image_get_file(docker_image):
f = fs.get_file("/etc/system-release")
assert f.fileno()
assert "/etc/system-release" in f.name
assert f.read() == "Fedora release 26 (Twenty Six)\n"
assert f.read() == FEDORA_RELEASE
f.close()


Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_podman.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def test_podman_image(podman_backend):
assert "%s:%s" % (FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG) == image.get_full_name()
assert "%s:%s" % (FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG) in image.inspect()['RepoTags']
assert "Config" in image.inspect()
assert "fedora-minimal:26" in image.get_full_name()
assert "registry.fedoraproject.org/fedora-minimal:26" == str(image)
assert "fedora-minimal:33" in image.get_full_name()
assert "registry.fedoraproject.org/fedora-minimal:33" == str(image)
assert "PodmanImage(repository=%s, tag=%s)" % (FEDORA_MINIMAL_REPOSITORY,
FEDORA_MINIMAL_REPOSITORY_TAG) == repr(image)
assert isinstance(image.get_id(), string_types)
Expand Down Expand Up @@ -321,7 +321,7 @@ def test_list_containers(podman_backend):
def test_list_images(podman_backend):
image_list = podman_backend.list_images()
assert len(image_list) > 0
# id of registry.fedoraproject.org/fedora-minimal:26
# id of registry.fedoraproject.org/fedora-minimal:33
the_id = subprocess.check_output(["podman", "inspect", "-f", "{{.Id}}",
FEDORA_MINIMAL_REPOSITORY + ":" +
FEDORA_MINIMAL_REPOSITORY_TAG]).decode("utf-8").strip()
Expand Down

0 comments on commit dee6fd9

Please sign in to comment.