Add login flag to container image prepare defaults
If a registry requires authentication and --local-push-destination is not used, a user may need to enable the login functionality. This change adds a --enable-registry-login flag to `openstack container image prepare default` that can be used to ensure the ContainerImageRegistryLogin flag is defined as true. Previously this would have needed to be added in elsewhere. Change-Id: I809023604fe119ba162638d921ffec56d4eb72f2
This commit is contained in:
parent
2b6fc058f7
commit
c08c5c2b92
|
@ -927,6 +927,29 @@ class TestTripleoImagePrepareDefault(TestPluginV1):
|
|||
[0]['push_destination']
|
||||
)
|
||||
|
||||
def test_prepare_default_registyr_login(self):
|
||||
temp = tempfile.mkdtemp()
|
||||
self.addCleanup(shutil.rmtree, temp)
|
||||
env_file = os.path.join(temp, 'containers_env.yaml')
|
||||
|
||||
arglist = ['--enable-registry-login', '--output-env-file', env_file]
|
||||
verifylist = []
|
||||
|
||||
self.app.command_options = [
|
||||
'tripleo', 'container', 'image', 'prepare', 'default'
|
||||
] + arglist
|
||||
cmd = container_image.TripleOImagePrepareDefault(self.app, None)
|
||||
parsed_args = self.check_parser(cmd, arglist, verifylist)
|
||||
|
||||
cmd.take_action(parsed_args)
|
||||
|
||||
with open(env_file) as f:
|
||||
result = yaml.safe_load(f)
|
||||
self.assertEqual(
|
||||
True,
|
||||
result['parameter_defaults']['ContainerImageRegistryLogin']
|
||||
)
|
||||
|
||||
|
||||
class TestContainerImageBuild(TestPluginV1):
|
||||
|
||||
|
|
|
@ -905,6 +905,19 @@ class TripleOImagePrepareDefault(command.Command):
|
|||
help=_('Include a push_destination to trigger upload to a local '
|
||||
'registry.')
|
||||
)
|
||||
parser.add_argument(
|
||||
'--enable-registry-login',
|
||||
dest='registry_login',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help=_('Use this flag to enable the flag to have systems attempt '
|
||||
'to login to a remote registry prior to pulling their '
|
||||
'containers. This flag should be used when '
|
||||
'--local-push-destination is *NOT* used and the target '
|
||||
'systems will have network connectivity to the remote '
|
||||
'registries. Do not use this for an overcloud that '
|
||||
'may not have network connectivity to a remote registry.')
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
|
@ -917,6 +930,18 @@ class TripleOImagePrepareDefault(command.Command):
|
|||
params = {
|
||||
'ContainerImagePrepare': cip
|
||||
}
|
||||
if parsed_args.registry_login:
|
||||
if parsed_args.push_destination:
|
||||
self.log.warning('[WARNING] --local-push-destination was used '
|
||||
'with --enable-registry-login. Please make '
|
||||
'sure you understand the use of these '
|
||||
'parameters together as they can cause '
|
||||
'deployment failures.')
|
||||
self.log.warning('[NOTE] Make sure to update the paramter_defaults'
|
||||
' with ContainerImageRegistryCredentials for the '
|
||||
'registries requiring authentication.')
|
||||
params['ContainerImageRegistryLogin'] = True
|
||||
|
||||
env_data = build_env_file(params, self.app.command_options)
|
||||
self.app.stdout.write(env_data)
|
||||
if parsed_args.output_env_file:
|
||||
|
|
Loading…
Reference in New Issue