import re


def tag_parts(image_tag):
  """Decomposes a container image tag into its registry, repository and tag."""
  match = re.match(r"([^/\n]+)/([^:]+):(.+)", image_tag)
  if not match:
    raise Exception("invalid image tag '%s'" % image_tag)
  return (match.group(1), match.group(2), match.group(3))