Repository: cekit/cekit

Issue:
Building images with Podman does not tag the resulting image
```
$ podman images
REPOSITORY                                                  TAG      IMAGE ID       CREATED          SIZE
<none>                                                      <none>   6fee3d0b86b6   37 seconds ago   253 MB
```

Discussion:
goldmann: We should add tests for this.

Patch:
diff --git a/cekit/builders/buildah.py b/cekit/builders/buildah.py
index 004e543..111b77b 100644
--- a/cekit/builders/buildah.py
+++ b/cekit/builders/buildah.py
@@ -30,6 +30,9 @@ class BuildahBuilder(Builder):
         tags = self.params.tags
         cmd = ["/usr/bin/buildah", "build-using-dockerfile"]
 
+        if not tags:
+            tags = self.generator.get_tags()
+
         if self.params.pull:
             cmd.append('--pull-always')
 
diff --git a/cekit/builders/podman.py b/cekit/builders/podman.py
index 5ccfdd2..1ac3bbe 100644
--- a/cekit/builders/podman.py
+++ b/cekit/builders/podman.py
@@ -30,6 +30,9 @@ class PodmanBuilder(Builder):
         tags = self.params.tags
         cmd = ["/usr/bin/podman", "build"]
 
+        if not tags:
+            tags = self.generator.get_tags()
+
         if self.params.pull:
             cmd.append('--pull-always')
 
diff --git a/cekit/generator/docker.py b/cekit/generator/docker.py
index 9b00e5b..ec6e701 100644
--- a/cekit/generator/docker.py
+++ b/cekit/generator/docker.py
@@ -48,12 +48,12 @@ class DockerGenerator(Generator):
         arch = platform.machine()
 
         if arch not in content_sets:
-            raise CekitError("There are no contet_sets defined for platform '{}'!".format(arch))
+            raise CekitError("There are no content_sets defined for platform '{}'!".format(arch))
 
         repos = ' '.join(content_sets[arch])
 
         try:
-            # idealy this will be API for ODCS, but there is no python3 package for ODCS
+            # ideally this will be API for ODCS, but there is no python3 package for ODCS
             cmd = ['/usr/bin/odcs']
 
             if config.get('common', 'redhat'):


Test patch:
diff --git a/tests/test_builder.py b/tests/test_builder.py
index 86911b9..d45a40e 100644
--- a/tests/test_builder.py
+++ b/tests/test_builder.py
@@ -7,7 +7,9 @@ import time
 import pytest
 import yaml
 
+from cekit.descriptor import Image
 from cekit.errors import CekitError
+from cekit.generator.docker import DockerGenerator
 from cekit.tools import Map
 
 try:
@@ -572,3 +574,55 @@ def test_podman_builder_run_pull(mocker):
                                         '-t', 'foo',
                                         '-t', 'bar',
                                         'something/image'])
+
+
+def test_podman_builder_run_with_generator(mocker):
+    params = Map({'tags': []})
+    check_call = mocker.patch.object(subprocess, 'check_call')
+    builder = create_builder_object(mocker, 'podman', params)
+    builder.generator = DockerGenerator("", "", {})
+    builder.generator.image = Image(yaml.safe_load("""
+    name: foo
+    version: 1.9
+    labels:
+      - name: test
+        value: val1
+      - name: label2
+        value: val2
+    envs:
+      - name: env1
+        value: env1val
+    """), 'foo')
+    builder.run()
+
+    check_call.assert_called_once_with(['/usr/bin/podman',
+                                        'build',
+                                        '-t', 'foo:1.9',
+                                        '-t', 'foo:latest',
+                                        'something/image'])
+
+
+def test_buildah_builder_run_with_generator(mocker):
+    params = Map({'tags': []})
+    check_call = mocker.patch.object(subprocess, 'check_call')
+    builder = create_builder_object(mocker, 'buildah', params)
+    builder.generator = DockerGenerator("", "", {})
+    builder.generator.image = Image(yaml.safe_load("""
+    name: foo
+    version: 1.9
+    labels:
+      - name: test
+        value: val1
+      - name: label2
+        value: val2
+    envs:
+      - name: env1
+        value: env1val
+    """), 'foo')
+    builder.run()
+
+    check_call.assert_called_once_with(['/usr/bin/buildah',
+                                        'build-using-dockerfile',
+                                        '-t', 'foo:1.9',
+                                        '-t', 'foo:latest',
+                                        'something/image'])
diff --git a/tests/test_unit_generator_docker.py b/tests/test_unit_generator_docker.py
index b7fc8fe..dbf2d3f 100644
--- a/tests/test_unit_generator_docker.py
+++ b/tests/test_unit_generator_docker.py
@@ -98,7 +98,7 @@ def test_prepare_content_sets_should_fail_when_cs_are_note_defined_for_current_p
 
     with docker_generator(tmpdir) as generator:
         with cekit_config(redhat=True):
-            with pytest.raises(CekitError, match="There are no contet_sets defined for platform 'current_platform'!"):
+            with pytest.raises(CekitError, match="There are no content_sets defined for platform 'current_platform'!"):
                 assert generator._prepare_content_sets(
                     {'invalid_platform': ['ca1', 'cs2']}) is False
 
diff --git a/tests/test_validate.py b/tests/test_validate.py
index de50189..b2694b6 100644
--- a/tests/test_validate.py
+++ b/tests/test_validate.py
@@ -107,7 +107,7 @@ def run_cekit_cs_overrides(image_dir, mocker, overrides_descriptor):
 
 
 def test_content_sets_file_container_file(tmpdir, mocker, caplog):
-    # Do not try to validate dependencies while running tests, these are not neccessary
+    # Do not try to validate dependencies while running tests, these are not necessary
     mocker.patch('cekit.generator.docker.DockerGenerator.dependencies').return_value({})
     overrides_descriptor = {
         'schema_version': 1,
@@ -132,7 +132,7 @@ def test_content_sets_file_container_file(tmpdir, mocker, caplog):
 
 
 def test_content_sets_file_container_embedded(tmpdir, mocker, caplog):
-    # Do not try to validate dependencies while running tests, these are not neccessary
+    # Do not try to validate dependencies while running tests, these are not necessary
     mocker.patch('cekit.generator.docker.DockerGenerator.dependencies').return_value({})
     overrides_descriptor = {
         'schema_version': 1,
@@ -153,7 +153,7 @@ def test_content_sets_file_container_embedded(tmpdir, mocker, caplog):
 
 
 def test_content_sets_embedded_container_embedded(tmpdir, mocker, caplog):
-    # Do not try to validate dependencies while running tests, these are not neccessary
+    # Do not try to validate dependencies while running tests, these are not necessary
     mocker.patch('cekit.generator.docker.DockerGenerator.dependencies').return_value({})
     overrides_descriptor = {
         'schema_version': 1,
@@ -169,7 +169,7 @@ def test_content_sets_embedded_container_embedded(tmpdir, mocker, caplog):
 
 
 def test_content_sets_embedded_container_file(tmpdir, mocker, caplog):
-    # Do not try to validate dependencies while running tests, these are not neccessary
+    # Do not try to validate dependencies while running tests, these are not necessary
     mocker.patch('cekit.generator.docker.DockerGenerator.dependencies').return_value({})
     overrides_descriptor = {
         'schema_version': 1,