Skip to content

Commit

Permalink
Merge branch 'feat/OTA-2238' into 'master'
Browse files Browse the repository at this point in the history
[OTA-2238] Add rotateRoot() method to ReposerverClient

Closes OTA-2238

See merge request torizon-platform/ota-tuf!333
  • Loading branch information
Ben Clouser committed Jun 27, 2024
2 parents 585dca2 + 97a39fb commit 199b6c1
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 199b6c1

Please sign in to comment.