From 5390d0c88db5586708f905bb9c1161bd4432eb54 Mon Sep 17 00:00:00 2001 From: Roman Timushev Date: Sun, 6 Feb 2022 23:59:55 +0100 Subject: [PATCH] Fix loading credentials from a file --- .../RepositoryAuthentication.scala | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/main/scala/com/timushev/sbt/updates/authentication/RepositoryAuthentication.scala b/src/main/scala/com/timushev/sbt/updates/authentication/RepositoryAuthentication.scala index fbb08a0f..f965b2d9 100644 --- a/src/main/scala/com/timushev/sbt/updates/authentication/RepositoryAuthentication.scala +++ b/src/main/scala/com/timushev/sbt/updates/authentication/RepositoryAuthentication.scala @@ -22,19 +22,15 @@ case class RepositoryAuthentication( object RepositoryAuthentication { def fromCredentials(c: Credentials): Option[RepositoryAuthentication] = - c match { - case d: DirectCredentials => - Some( - RepositoryAuthentication( - repositoryId = None, - realm = Some(d.realm), - host = Some(d.host), - user = d.userName, - password = d.passwd, - headers = Nil - ) - ) - case _ => None + allCatch.opt(Credentials.toDirect(c)).map { d => + RepositoryAuthentication( + repositoryId = None, + realm = Some(d.realm), + host = Some(d.host), + user = d.userName, + password = d.passwd, + headers = Nil + ) } def fromCoursier(c: CoursierConfiguration): Seq[RepositoryAuthentication] =