Skip to content

Commit

Permalink
fix(buildtool): Use image project from BOM (spinnaker#2675)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Wiseblatt authored and ezimanyi committed Apr 18, 2018
1 parent cda1206 commit da95dff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
6 changes: 4 additions & 2 deletions dev/buildtool/bom_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import buildtool.container_commands
import buildtool.debian_commands
import buildtool.image_commands

from buildtool import (
DEFAULT_BUILD_NUMBER,
Expand Down Expand Up @@ -294,7 +293,10 @@ def init_argparser(self, parser, defaults):
HalRunner.add_parser_args(parser, defaults)
buildtool.container_commands.add_bom_parser_args(parser, defaults)
buildtool.debian_commands.add_bom_parser_args(parser, defaults)
buildtool.image_commands.add_bom_parser_args(parser, defaults)

self.add_argument(
parser, 'publish_gce_image_project', defaults, None,
help='Project to publish images to.')

self.add_argument(
parser, 'build_number', defaults, DEFAULT_BUILD_NUMBER,
Expand Down
30 changes: 8 additions & 22 deletions dev/buildtool/image_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
GitRunner,
HalRunner,

add_parser_argument,
check_subprocess,
check_subprocesses_to_logfile,
check_options_set,
Expand Down Expand Up @@ -72,11 +71,15 @@ def __init__(self, factory, options, **kwargs):
check_options_set(
options,
['build_gce_service_account',
'build_gce_project',
'publish_gce_image_project'])
'build_gce_project'])

options.github_disable_upstream_push = True
super(BuildGceComponentImages, self).__init__(factory, options, **kwargs)
artifact_sources = self.source_code_manager.bom['artifactSources']
self.__image_project = artifact_sources['googleImageProject']
if not self.__image_project:
raise_and_log_error(
ConfigError('BOM has no artifactSources.googleImageProject'))

def __determine_repo_install_args(self, repository):
"""Determine --spinnaker_dev-github_[owner|user] args for install script."""
Expand Down Expand Up @@ -118,7 +121,7 @@ def have_image(self, repository):
version=build_version.replace('.', '-').replace(':', '-'))
lookup_command = ['gcloud', '--account', options.build_gce_service_account,
'compute', 'images', 'list', '--filter', image_name,
'--project', options.build_gce_project,
'--project', self.__image_project,
'--quiet', '--format=json']
logging.debug('Checking for existing image for "%s"', repository.name)
got = check_subprocess(' '.join(lookup_command))
Expand Down Expand Up @@ -174,7 +177,7 @@ def _do_repository(self, repository):
'--hal_daemon_endpoint', 'http://' + options.halyard_daemon,
'--build_project', options.build_gce_project,
'--install_script', options.install_image_script,
'--publish_project', options.publish_gce_image_project,
'--publish_project', self.__image_project,
'--publish_script', options.publish_gce_image_script,
'--version', bom_version,
'--zone', options.build_gce_zone]
Expand Down Expand Up @@ -215,22 +218,10 @@ def __init__(self):
'Build Google Compute Engine VM Images For Each Service.',
BomSourceCodeManager)

@staticmethod
def add_bom_parser_args(parser, defaults):
"""Adds arguments shared with creating boms."""
if hasattr(parser, 'added_gce_image_project'):
return
parser.added_gce_image_project = True

add_parser_argument(
parser, 'publish_gce_image_project', defaults, None,
help='Project to publish images to.')

def init_argparser(self, parser, defaults):
super(BuildGceComponentImagesFactory, self).init_argparser(
parser, defaults)
HalRunner.add_parser_args(parser, defaults)
self.add_bom_parser_args(parser, defaults)

self.add_argument(
parser, 'halyard_release_track', defaults, 'stable',
Expand Down Expand Up @@ -281,10 +272,5 @@ def init_argparser(self, parser, defaults):
help='The bucket manaing halyard BOMs and config profiles.')


def add_bom_parser_args(parser, defaults):
"""Adds parser arguments pertaining to publishing boms."""
BuildGceComponentImagesFactory.add_bom_parser_args(parser, defaults)


def register_commands(registry, subparsers, defaults):
BuildGceComponentImagesFactory().register(registry, subparsers, defaults)

0 comments on commit da95dff

Please sign in to comment.