def Run(self, args): """This is what gets called when the user runs this command. Args: args: an argparse namespace. All the arguments that were provided to this command invocation. Returns: A list of all supported locations. """ return [{"name": loc} for loc in util.GetLocationList(args)]
def _ParseInput(input_str): """Parses user input into project, location, and repository values. Args: input_str: str, user input. Ex: us-docker.pkg.dev/my-proj/my-repo/my-img Raises: ar_exceptions.InvalidInputValueError if user input is invalid. ar_exceptions.UnsupportedLocationError if provided location is invalid. Returns: A DockerRepo. """ matches = re.match(DOCKER_REPO_REGEX, input_str) if not matches: raise ar_exceptions.InvalidInputValueError() location = matches.group("location") if not util.IsValidLocation(location): raise ar_exceptions.UnsupportedLocationError( "{} is not a valid location. Valid locations are [{}].".format( location, ", ".join(util.GetLocationList()))) return DockerRepo(matches.group("project"), location, matches.group("repo"))