Skip to content

Commit

Permalink
Set correct BuildConfig names (fixes #217)
Browse files Browse the repository at this point in the history
  • Loading branch information
twaugh committed Aug 16, 2015
1 parent 1f2115f commit 0dc00c0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
8 changes: 4 additions & 4 deletions osbs/build/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import re
from osbs.constants import DEFAULT_GIT_REF
from osbs.exceptions import OsbsValidationException
from osbs.utils import get_imagestreamtag_from_image
from osbs.utils import get_imagestreamtag_from_image, humanish_part


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -147,10 +147,10 @@ def set_params(self, git_uri=None, git_ref=None, git_branch=None, registry_uri=N
raise OsbsValidationException("yum_repourls must be a list")
self.yum_repourls.value = yum_repourls or []
self.use_auth.value = use_auth
self.name.value = name_label.replace('/', '-')
self.name.value = "{repo}-{branch}".format(repo=humanish_part(git_uri),
branch=git_branch)
self.trigger_imagestreamtag.value = get_imagestreamtag_from_image(base_image)
# imagestream and buildconfig have precisely the same name
self.imagestream_name.value = self.name.value
self.imagestream_name.value = name_label.replace('/', '-')
self.imagestream_url.value = os.path.join(self.registry_uri.value, name_label)


Expand Down
2 changes: 1 addition & 1 deletion tests/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from __future__ import absolute_import, unicode_literals

TEST_BUILD = "test-build-123"
TEST_BUILD_CONFIG = "fedora23-something"
TEST_BUILD_CONFIG = "path-master"
TEST_GIT_URI = "git://hostname/path"
TEST_GIT_REF = "01234567"
TEST_GIT_BRANCH = "master"
Expand Down
1 change: 1 addition & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def test_deep_update():
('http://git.example.com/git/repo.git/', 'repo'),
('http://git.example.com/git/repo.git', 'repo'),
('http://git.example.com/git/repo/.git', 'repo'),
('git://hostname/path', 'path'),
])
def test_humanish_part(uri, humanish):
assert humanish_part(uri) == humanish
Expand Down
36 changes: 18 additions & 18 deletions tests/unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from osbs.exceptions import OsbsValidationException
from osbs.http import Response
from osbs import utils
from tests.constants import TEST_BUILD, TEST_LABEL, TEST_LABEL_VALUE
from tests.constants import TEST_BUILD, TEST_BUILD_CONFIG, TEST_LABEL, TEST_LABEL_VALUE
from tests.constants import TEST_GIT_URI, TEST_GIT_REF, TEST_GIT_BRANCH, TEST_USER
from tests.constants import TEST_COMPONENT, TEST_TARGET, TEST_ARCH
from tests.fake_api import ResponseMapping, get_definition_for
Expand Down Expand Up @@ -249,7 +249,7 @@ def test_render_simple_request_incorrect_postbuild(tmpdir):
bm = BuildManager(str(tmpdir))
build_request = bm.get_build_request_by_type("simple")
kwargs = {
'git_uri': "http://git/",
'git_uri': TEST_GIT_URI,
'git_ref': TEST_GIT_REF,
'user': "john-foo",
'component': "component",
Expand Down Expand Up @@ -286,7 +286,7 @@ def test_render_simple_request():
build_request = bm.get_build_request_by_type("simple")
name_label = "fedora/resultingimage"
kwargs = {
'git_uri': "http://git/",
'git_uri': TEST_GIT_URI,
'git_ref': TEST_GIT_REF,
'git_branch': TEST_GIT_BRANCH,
'user': "john-foo",
Expand All @@ -299,9 +299,9 @@ def test_render_simple_request():
build_request.set_params(**kwargs)
build_json = build_request.render()

assert build_json["metadata"]["name"] == name_label.replace('/', '-')
assert build_json["metadata"]["name"] == TEST_BUILD_CONFIG
assert "triggers" not in build_json["spec"]
assert build_json["spec"]["source"]["git"]["uri"] == "http://git/"
assert build_json["spec"]["source"]["git"]["uri"] == TEST_GIT_URI
assert build_json["spec"]["source"]["git"]["ref"] == TEST_GIT_REF
assert build_json["spec"]["output"]["to"]["name"].startswith(
"registry.example.com:5000/john-foo/component:"
Expand Down Expand Up @@ -330,7 +330,7 @@ def test_render_prod_request_with_repo():
name_label = "fedora/resultingimage"
assert isinstance(build_request, ProductionBuild)
kwargs = {
'git_uri': "http://git/",
'git_uri': TEST_GIT_URI,
'git_ref': TEST_GIT_REF,
'git_branch': TEST_GIT_BRANCH,
'user': "john-foo",
Expand All @@ -352,9 +352,9 @@ def test_render_prod_request_with_repo():
build_request.set_params(**kwargs)
build_json = build_request.render()

assert build_json["metadata"]["name"] == name_label.replace('/', '-')
assert build_json["metadata"]["name"] == TEST_BUILD_CONFIG
assert "triggers" not in build_json["spec"]
assert build_json["spec"]["source"]["git"]["uri"] == "http://git/"
assert build_json["spec"]["source"]["git"]["uri"] == TEST_GIT_URI
assert build_json["spec"]["source"]["git"]["ref"] == TEST_GIT_REF
assert build_json["spec"]["output"]["to"]["name"].startswith(
"registry.example.com/john-foo/component:"
Expand Down Expand Up @@ -410,7 +410,7 @@ def test_render_prod_request():
build_request = bm.get_build_request_by_type(PROD_BUILD_TYPE)
name_label = "fedora/resultingimage"
kwargs = {
'git_uri': "http://git/",
'git_uri': TEST_GIT_URI,
'git_ref': TEST_GIT_REF,
'git_branch': TEST_GIT_BRANCH,
'user': "john-foo",
Expand All @@ -431,9 +431,9 @@ def test_render_prod_request():
build_request.set_params(**kwargs)
build_json = build_request.render()

assert build_json["metadata"]["name"] == name_label.replace('/', '-')
assert build_json["metadata"]["name"] == TEST_BUILD_CONFIG
assert "triggers" not in build_json["spec"]
assert build_json["spec"]["source"]["git"]["uri"] == "http://git/"
assert build_json["spec"]["source"]["git"]["uri"] == TEST_GIT_URI
assert build_json["spec"]["source"]["git"]["ref"] == TEST_GIT_REF
assert build_json["spec"]["output"]["to"]["name"].startswith(
"registry.example.com/john-foo/component:"
Expand Down Expand Up @@ -489,7 +489,7 @@ def test_render_prod_without_koji_request():
name_label = "fedora/resultingimage"
assert isinstance(build_request, ProductionBuild)
kwargs = {
'git_uri': "http://git/",
'git_uri': TEST_GIT_URI,
'git_ref': TEST_GIT_REF,
'git_branch': TEST_GIT_BRANCH,
'user': "john-foo",
Expand All @@ -507,9 +507,9 @@ def test_render_prod_without_koji_request():
build_request.set_params(**kwargs)
build_json = build_request.render()

assert build_json["metadata"]["name"] == name_label.replace('/', '-')
assert build_json["metadata"]["name"] == TEST_BUILD_CONFIG
assert "triggers" not in build_json["spec"]
assert build_json["spec"]["source"]["git"]["uri"] == "http://git/"
assert build_json["spec"]["source"]["git"]["uri"] == TEST_GIT_URI
assert build_json["spec"]["source"]["git"]["ref"] == TEST_GIT_REF
assert build_json["spec"]["output"]["to"]["name"].startswith(
"registry.example.com/john-foo/component:"
Expand Down Expand Up @@ -564,7 +564,7 @@ def test_render_prod_with_secret_request():
build_request = bm.get_build_request_by_type(PROD_WITH_SECRET_BUILD_TYPE)
assert isinstance(build_request, ProductionBuild)
kwargs = {
'git_uri': "http://git/",
'git_uri': TEST_GIT_URI,
'git_ref': TEST_GIT_REF,
'git_branch': TEST_GIT_BRANCH,
'user': "john-foo",
Expand Down Expand Up @@ -619,7 +619,7 @@ def test_render_with_yum_repourls():
inputs_path = os.path.join(parent_dir, "inputs")
bm = BuildManager(inputs_path)
kwargs = {
'git_uri': "http://git/",
'git_uri': TEST_GIT_URI,
'git_ref': TEST_GIT_REF,
'git_branch': TEST_GIT_BRANCH,
'user': "john-foo",
Expand Down Expand Up @@ -694,7 +694,7 @@ def test_render_prod_with_pulp_no_auth():
bm = BuildManager(inputs_path)
build_request = bm.get_build_request_by_type(PROD_BUILD_TYPE)
kwargs = {
'git_uri': "http://git/",
'git_uri': TEST_GIT_URI,
'git_ref': TEST_GIT_REF,
'git_branch': TEST_GIT_BRANCH,
'user': "john-foo",
Expand Down Expand Up @@ -752,7 +752,7 @@ def test_render_prod_request_with_trigger(tmpdir):
name_label = "fedora/resultingimage"
push_url = "ssh://{username}git.example.com/git/{component}.git"
kwargs = {
'git_uri': "http://git/",
'git_uri': TEST_GIT_URI,
'git_ref': TEST_GIT_REF,
'git_branch': TEST_GIT_REF,
'user': "john-foo",
Expand Down

0 comments on commit 0dc00c0

Please sign in to comment.