def delete_tag(self, repository_ref, tag_name): """ Deletes the latest, *active* tag with the given name in the repository. """ with db_disallow_replica_use(): deleted_tag = oci.tag.delete_tag(repository_ref._db_id, tag_name) if deleted_tag is None: # TODO: This is only needed because preoci raises an exception. Remove and fix # expected status codes once PreOCIModel is gone. msg = "Invalid repository tag '%s' on repository" % tag_name raise model.DataModelException(msg) return Tag.for_tag(deleted_tag, self._legacy_image_id_handler)
def _setup_robot_for_mirroring(self, namespace_name, repo_name, robot_username): """ Validate robot exists and give write permissions. """ robot = model.user.lookup_robot(robot_username) assert robot.robot namespace, _ = parse_robot_username(robot_username) if namespace != namespace_name: raise model.DataModelException('Invalid robot') # Ensure the robot specified has access to the repository. If not, grant it. permissions = model.permission.get_user_repository_permissions(robot, namespace_name, repo_name) if not permissions or permissions[0].role.name == 'read': model.permission.set_user_repo_permission(robot.username, namespace_name, repo_name, 'write') return robot