Added lowercase validation for image name argument

pull/175/head
Mukundan Sundararajan 2017-12-20 19:41:20 -08:00
rodzic 1c7bd6e589
commit 5372b09333
1 zmienionych plików z 13 dodań i 1 usunięć

Wyświetl plik

@ -122,6 +122,17 @@ class Repo2Docker(Application):
extra=dict(phase='failed'))
sys.exit(1)
def validate_image_name(self, image_name):
"""
Validate that the image_name read by argparse contains only lowercase characters
:param image_name: string argument read by argparse
:return: test and return image_name if it only contains lowercase characters else raise error
"""
if not image_name.islower():
msg = "%r is not a valid docker image name. Image name can contain only lowercase characters." % image_name
raise argparse.ArgumentTypeError(msg)
return image_name
def get_argparser(self):
argparser = argparse.ArgumentParser()
argparser.add_argument(
@ -146,7 +157,8 @@ class Repo2Docker(Application):
argparser.add_argument(
'--image-name',
help=('Name of image to be built. If unspecified will be '
'autogenerated')
'autogenerated'),
type=self.validate_image_name
)
argparser.add_argument(