Added lowercase validation for image name argument
@@ -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(
