Skip to content

Commit

Permalink
[OTA-2238] Add rotateRoot() method to ReposerverClient
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Clouser <dev@benclouser.com>
  • Loading branch information
bclouser committed Jun 26, 2024
1 parent 585dca2 commit 97a39fb
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ trait ReposerverClient {
def fetchRoot(namespace: Namespace,
version: Option[Int]): Future[(RepoId, SignedPayload[RootRole])]

def rotateRoot(namespace: Namespace): Future[Unit]

def repoExists(namespace: Namespace)(implicit ec: ExecutionContext): Future[Boolean] =
fetchRoot(namespace, None).transform {
case Success(_) | Failure(KeysNotReady) => Success(true)
Expand Down Expand Up @@ -327,6 +329,11 @@ class ReposerverHttpClient(reposerverUri: Uri,
}
}

override def rotateRoot(namespace: Namespace): Future[Unit] = {
val req = HttpRequest(HttpMethods.PUT, uri = apiUri(Path(s"user_repo/root/rotate")))
execHttpUnmarshalledWithNamespace[Unit](namespace, req).ok
}

private def addTargetErrorHandler[T]: PartialFunction[RemoteServiceError, Future[T]] = {
case error if error.status == StatusCodes.PreconditionFailed =>
Future.failed(PrivateKeysNotInKeyserver)
Expand Down

0 comments on commit 97a39fb

Please sign in to comment.