diff --git a/core/build.sbt b/core/build.sbt index a87157e..9801b8e 100644 --- a/core/build.sbt +++ b/core/build.sbt @@ -1,8 +1,13 @@ +val circeVersion = "0.11.1" libraryDependencies ++= Seq( - "io.argonaut" %% "argonaut" % "6.2.1", - "org.typelevel" %% "cats-free" % "1.1.0", - "org.typelevel" %% "cats-effect" % "0.10" + "io.circe" %% "circe-core" % circeVersion, + "io.circe" %% "circe-generic" % circeVersion, + "io.circe" %% "circe-parser" % circeVersion, + "org.scalacheck" %% "scalacheck" % "1.14.0" % "test", + "org.scalatest" %% "scalatest" % "3.0.8" % "test", + "org.typelevel" %% "cats-free" % "1.3.0", + "org.typelevel" %% "cats-effect" % "1.3.0" ) addCompilerPlugin("org.spire-math" % "kind-projector" % "0.9.5" cross CrossVersion.binary) diff --git a/core/src/main/scala/HealthCheckParameter.scala b/core/src/main/scala/HealthCheckParameter.scala index d669bfb..ef17c4d 100644 --- a/core/src/main/scala/HealthCheckParameter.scala +++ b/core/src/main/scala/HealthCheckParameter.scala @@ -1,6 +1,7 @@ package helm -import argonaut._, Argonaut._ +import io.circe._ +import io.circe.syntax._ /** Case class representing a health check as defined in the Register Service API calls */ final case class HealthCheckParameter( @@ -20,20 +21,22 @@ final case class HealthCheckParameter( ) object HealthCheckParameter { - implicit def HealthCheckParameterEncoder: EncodeJson[HealthCheckParameter] = - EncodeJson((h: HealthCheckParameter) => - ("Name" := h.name) ->: - ("CheckID" :=? h.id) ->?: - ("Interval" :=? h.interval) ->?: - ("Notes" :=? h.notes) ->?: - ("DeregisterCriticalServiceAfter" :=? h.deregisterCriticalServiceAfter) ->?: - ("ServiceID" :=? h.serviceId) ->?: - ("Status" :=? h.initialStatus) ->?: - ("HTTP" :=? h.http) ->?: - ("TLSSkipVerify" :=? h.tlsSkipVerify) ->?: - ("Script" :=? h.script) ->?: - ("DockerContainerID" :=? h.dockerContainerId) ->?: - ("TCP" :=? h.tcp) ->?: - ("TTL" :=? h.ttl) ->?: - jEmptyObject) + implicit def HealthCheckParameterEncoder: Encoder[HealthCheckParameter] = + Encoder.encodeJsonObject.contramapObject { h => + JsonObject( + "Name" := h.name , + "CheckID" := h.id , + "Interval" := h.interval , + "Notes" := h.notes , + "DeregisterCriticalServiceAfter" := h.deregisterCriticalServiceAfter , + "ServiceID" := h.serviceId , + "Status" := h.initialStatus , + "HTTP" := h.http , + "TLSSkipVerify" := h.tlsSkipVerify , + "Script" := h.script , + "DockerContainerID" := h.dockerContainerId , + "TCP" := h.tcp , + "TTL" := h.ttl + ) + } } diff --git a/core/src/main/scala/HealthCheckResponse.scala b/core/src/main/scala/HealthCheckResponse.scala index d14918f..ed06e6e 100644 --- a/core/src/main/scala/HealthCheckResponse.scala +++ b/core/src/main/scala/HealthCheckResponse.scala @@ -1,6 +1,6 @@ package helm -import argonaut._, Argonaut._ +import io.circe._ /** Case class representing a health check as returned from an API call to Consul */ final case class HealthCheckResponse( @@ -18,20 +18,20 @@ final case class HealthCheckResponse( ) object HealthCheckResponse { - implicit def HealthCheckResponseDecoder: DecodeJson[HealthCheckResponse] = - DecodeJson(j => + implicit def HealthCheckResponseDecoder: Decoder[HealthCheckResponse] = + Decoder.instance(c => for { - node <- (j --\ "Node").as[String] - checkId <- (j --\ "CheckID").as[String] - name <- (j --\ "Name").as[String] - status <- (j --\ "Status").as[HealthStatus] - notes <- (j --\ "Notes").as[String] - output <- (j --\ "Output").as[String] - serviceId <- (j --\ "ServiceID").as[String] - serviceName <- (j --\ "ServiceName").as[String] - serviceTags <- (j --\ "ServiceTags").as[List[String]] - createIndex <- (j --\ "CreateIndex").as[Long] - modifyIndex <- (j --\ "ModifyIndex").as[Long] + node <- c.downField("Node").as[String] + checkId <- c.downField("CheckID").as[String] + name <- c.downField("Name").as[String] + status <- c.downField("Status").as[HealthStatus] + notes <- c.downField("Notes").as[String] + output <- c.downField("Output").as[String] + serviceId <- c.downField("ServiceID").as[String] + serviceName <- c.downField("ServiceName").as[String] + serviceTags <- c.downField("ServiceTags").as[List[String]] + createIndex <- c.downField("CreateIndex").as[Long] + modifyIndex <- c.downField("ModifyIndex").as[Long] } yield HealthCheckResponse( node, checkId, diff --git a/core/src/main/scala/HealthNodesForServiceResponse.scala b/core/src/main/scala/HealthNodesForServiceResponse.scala index fb0e6af..4c94203 100644 --- a/core/src/main/scala/HealthNodesForServiceResponse.scala +++ b/core/src/main/scala/HealthNodesForServiceResponse.scala @@ -1,6 +1,6 @@ package helm -import argonaut._, Argonaut._ +import io.circe._ /** Case class representing the response to the Health API's List Nodes For Service function */ final case class HealthNodesForServiceResponse( @@ -10,12 +10,12 @@ final case class HealthNodesForServiceResponse( ) object HealthNodesForServiceResponse { - implicit def HealthNodesForServiceResponseDecoder: DecodeJson[HealthNodesForServiceResponse] = - DecodeJson(j => + implicit def HealthNodesForServiceResponseDecoder: Decoder[HealthNodesForServiceResponse] = + Decoder.instance(c => for { - node <- (j --\ "Node").as[NodeResponse] - service <- (j --\ "Service").as[ServiceResponse] - checks <- (j --\ "Checks").as[List[HealthCheckResponse]] + node <- c.downField("Node").as[NodeResponse] + service <- c.downField("Service").as[ServiceResponse] + checks <- c.downField("Checks").as[List[HealthCheckResponse]] } yield HealthNodesForServiceResponse(node, service, checks) ) } diff --git a/core/src/main/scala/HealthStatus.scala b/core/src/main/scala/HealthStatus.scala index c40d9aa..3dc6367 100644 --- a/core/src/main/scala/HealthStatus.scala +++ b/core/src/main/scala/HealthStatus.scala @@ -1,6 +1,6 @@ package helm -import argonaut._, Argonaut._ +import io.circe._ sealed abstract class HealthStatus extends Product with Serializable @@ -28,16 +28,16 @@ object HealthStatus { case Unknown => "unknown" } - implicit val HealthStatusDecoder: DecodeJson[HealthStatus] = - DecodeJson[HealthStatus] { c => + implicit val HealthStatusDecoder: Decoder[HealthStatus] = + Decoder.instance { c => c.as[String].flatMap { s => fromString(s) match { - case Some(r) => DecodeResult.ok(r) - case None => DecodeResult.fail(s"invalid health status: $s", c.history) + case Some(r) => Right(r) + case None => Left(DecodingFailure(s"invalid health status: $s", c.history)) } } } - implicit val HealthStatusEncoder: EncodeJson[HealthStatus] = - EncodeJson[HealthStatus] { hs => jString(toString(hs)) } + implicit val HealthStatusEncoder: Encoder[HealthStatus] = + Encoder.encodeString.contramap { hs => toString(hs) } } diff --git a/core/src/main/scala/HelmOp.scala b/core/src/main/scala/HelmOp.scala index 3dde981..a0037cd 100644 --- a/core/src/main/scala/HelmOp.scala +++ b/core/src/main/scala/HelmOp.scala @@ -1,7 +1,7 @@ package helm import scala.collection.immutable.{Set => SSet} -import argonaut.{DecodeJson, EncodeJson, StringWrap}, StringWrap.StringToParseWrap +import io.circe._, io.circe.parser._ import cats.data.NonEmptyList import cats.free.Free import cats.free.Free.liftF @@ -104,15 +104,16 @@ object ConsulOp { ): ConsulOpF[QueryResponse[Option[Array[Byte]]]] = liftF(KVGetRaw(key, index, maxWait)) - def kvGetJson[A:DecodeJson]( + def kvGetJson[A]( key: Key, index: Option[Long], maxWait: Option[Interval] - ): ConsulOpF[Either[Err, QueryResponse[Option[A]]]] = + )(implicit decoder: Decoder[A]): ConsulOpF[Either[Error, QueryResponse[Option[A]]]] = kvGetRaw(key, index, maxWait).map { response => response.value match { case Some(bytes) => - new String(bytes, "UTF-8").decodeEither[A].right.map(decoded => response.copy(value = Some(decoded))) + parse(new String(bytes, "UTF-8")).flatMap(decoder.decodeJson) + .right.map(decoded => response.copy(value = Option(decoded))) case None => Right(response.copy(value = None)) } @@ -121,8 +122,8 @@ object ConsulOp { def kvSet(key: Key, value: Array[Byte]): ConsulOpF[Unit] = liftF(KVSet(key, value)) - def kvSetJson[A](key: Key, value: A)(implicit A: EncodeJson[A]): ConsulOpF[Unit] = - kvSet(key, A.encode(value).toString.getBytes("UTF-8")) + def kvSetJson[A](key: Key, value: A)(implicit encoder: Encoder[A]): ConsulOpF[Unit] = + kvSet(key, encoder(value).toString.getBytes("UTF-8")) def kvDelete(key: Key): ConsulOpF[Unit] = liftF(KVDelete(key)) diff --git a/core/src/main/scala/Interval.scala b/core/src/main/scala/Interval.scala index 075859d..04038a4 100644 --- a/core/src/main/scala/Interval.scala +++ b/core/src/main/scala/Interval.scala @@ -1,6 +1,6 @@ package helm -import argonaut._, Argonaut._ +import io.circe._ sealed abstract class Interval @@ -30,6 +30,6 @@ object Interval { } } - implicit val IntervalEncoder: EncodeJson[Interval] = - EncodeJson[Interval] { i => jString(toString(i)) } + implicit val IntervalEncoder: Encoder[Interval] = + Encoder.encodeString.contramap { i => toString(i) } } diff --git a/core/src/main/scala/KVGetResult.scala b/core/src/main/scala/KVGetResult.scala index 7881bc6..1dec6c6 100644 --- a/core/src/main/scala/KVGetResult.scala +++ b/core/src/main/scala/KVGetResult.scala @@ -1,6 +1,6 @@ package helm -import argonaut._, Argonaut._ +import io.circe._ /** Case class representing the response to a KV "Read Key" API call to Consul */ final case class KVGetResult( @@ -14,16 +14,16 @@ final case class KVGetResult( ) object KVGetResult { - implicit def KVGetResultDecoder: DecodeJson[KVGetResult] = - DecodeJson(j => + implicit def KVGetResultDecoder: Decoder[KVGetResult] = + Decoder.instance(c => for { - key <- (j --\ "Key").as[String] - value <- (j --\ "Value").as[Option[String]] - flags <- (j --\ "Flags").as[Long] - session <- (j --\ "Session").as[Option[String]] - lockIndex <- (j --\ "LockIndex").as[Long] - createIndex <- (j --\ "CreateIndex").as[Long] - modifyIndex <- (j --\ "ModifyIndex").as[Long] + key <- c.downField("Key").as[String] + value <- c.downField("Value").as[Option[String]] + flags <- c.downField("Flags").as[Long] + session <- c.downField("Session").as[Option[String]] + lockIndex <- c.downField("LockIndex").as[Long] + createIndex <- c.downField("CreateIndex").as[Long] + modifyIndex <- c.downField("ModifyIndex").as[Long] } yield KVGetResult( key, value, diff --git a/core/src/main/scala/NodeResponse.scala b/core/src/main/scala/NodeResponse.scala index 01dd1be..c2c903b 100644 --- a/core/src/main/scala/NodeResponse.scala +++ b/core/src/main/scala/NodeResponse.scala @@ -1,6 +1,6 @@ package helm -import argonaut._, Argonaut._ +import io.circe._ /** Case class representing a health check as returned from an API call to Consul */ final case class NodeResponse( @@ -15,17 +15,17 @@ final case class NodeResponse( ) object NodeResponse { - implicit def NodeResponseDecoder: DecodeJson[NodeResponse] = - DecodeJson(j => + implicit def NodeResponseDecoder: Decoder[NodeResponse] = + Decoder.instance(c => for { - id <- (j --\ "ID").as[String] - node <- (j --\ "Node").as[String] - address <- (j --\ "Address").as[String] - datacenter <- (j --\ "Datacenter").as[String] - meta <- (j --\ "Meta").as[Map[String, String]] - taggedAddresses <- (j --\ "TaggedAddresses").as[TaggedAddresses] - createIndex <- (j --\ "CreateIndex").as[Long] - modifyIndex <- (j --\ "ModifyIndex").as[Long] + id <- c.downField("ID").as[String] + node <- c.downField("Node").as[String] + address <- c.downField("Address").as[String] + datacenter <- c.downField("Datacenter").as[String] + meta <- c.downField("Meta").as[Map[String, String]] + taggedAddresses <- c.downField("TaggedAddresses").as[TaggedAddresses] + createIndex <- c.downField("CreateIndex").as[Long] + modifyIndex <- c.downField("ModifyIndex").as[Long] } yield NodeResponse( id, node, @@ -41,11 +41,11 @@ object NodeResponse { final case class TaggedAddresses(lan: String, wan: String) object TaggedAddresses { - implicit def TaggedAddressesDecoder: DecodeJson[TaggedAddresses] = - DecodeJson(j => + implicit def TaggedAddressesDecoder: Decoder[TaggedAddresses] = + Decoder.instance(c => for { - lan <- (j --\ "lan").as[String] - wan <- (j --\ "wan").as[String] + lan <- c.downField("lan").as[String] + wan <- c.downField("wan").as[String] } yield TaggedAddresses(lan, wan) ) } diff --git a/core/src/main/scala/ServiceResponse.scala b/core/src/main/scala/ServiceResponse.scala index 401b057..349f49d 100644 --- a/core/src/main/scala/ServiceResponse.scala +++ b/core/src/main/scala/ServiceResponse.scala @@ -1,6 +1,6 @@ package helm -import argonaut._, Argonaut._ +import io.circe._ /** Case class representing a service as returned from an API call to Consul */ final case class ServiceResponse( @@ -15,17 +15,17 @@ final case class ServiceResponse( ) object ServiceResponse { - implicit def ServiceResponseDecoder: DecodeJson[ServiceResponse] = - DecodeJson(j => + implicit def ServiceResponseDecoder: Decoder[ServiceResponse] = + Decoder.instance { c => for { - id <- (j --\ "ID").as[String] - address <- (j --\ "Address").as[String] - enableTagOverride <- (j --\ "EnableTagOverride").as[Boolean] - createIndex <- (j --\ "CreateIndex").as[Long] - modifyIndex <- (j --\ "ModifyIndex").as[Long] - port <- (j --\ "Port").as[Int] - service <- (j --\ "Service").as[String] - tags <- (j --\ "Tags").as[List[String]] + id <- c.downField("ID").as[String] + address <- c.downField("Address").as[String] + enableTagOverride <- c.downField("EnableTagOverride").as[Boolean] + createIndex <- c.downField("CreateIndex").as[Long] + modifyIndex <- c.downField("ModifyIndex").as[Long] + port <- c.downField("Port").as[Int] + service <- c.downField("Service").as[String] + tags <- c.downField("Tags").as[List[String]] } yield ServiceResponse(service, id, tags, address, port, enableTagOverride, createIndex, modifyIndex) - ) + } } diff --git a/core/src/test/scala/ConsulOpTests.scala b/core/src/test/scala/ConsulOpTests.scala index 6c2d2fa..96e6515 100644 --- a/core/src/test/scala/ConsulOpTests.scala +++ b/core/src/test/scala/ConsulOpTests.scala @@ -1,6 +1,6 @@ package helm -import argonaut._, Argonaut._ +import io.circe._ import cats.effect.IO import org.scalatest.{FlatSpec, Matchers} import org.scalactic.TypeCheckedTripleEquals @@ -24,7 +24,7 @@ class ConsulOpTests extends FlatSpec with Matchers with TypeCheckedTripleEquals case ConsulOp.KVGetRaw("foo", None, None) => IO.pure(QueryResponse(Some("42".getBytes), -1, true, -1)) } } yield () - interp.run(kvGetJson[Json]("foo", None, None)).unsafeRunSync should equal(Right(QueryResponse(Some(jNumber(42)), -1, true, -1))) + interp.run(kvGetJson[Json]("foo", None, None)).unsafeRunSync should equal(Right(QueryResponse(Some(Json.fromInt(42)), -1, true, -1))) } it should "return an error when get returns a non-decodeable value" in { @@ -33,6 +33,6 @@ class ConsulOpTests extends FlatSpec with Matchers with TypeCheckedTripleEquals case ConsulOp.KVGetRaw("foo", None, None) => IO.pure(QueryResponse(Some("{".getBytes), -1, true, -1)) } } yield () - interp.run(kvGetJson[Json]("foo", None, None)).unsafeRunSync should equal(Left("JSON terminates unexpectedly.")) + interp.run(kvGetJson[Json]("foo", None, None)).unsafeRunSync.left.map(_.getMessage) should equal(Left("exhausted input")) } } diff --git a/http4s/build.sbt b/http4s/build.sbt index 3c510aa..a51ecdd 100644 --- a/http4s/build.sbt +++ b/http4s/build.sbt @@ -1,15 +1,15 @@ val http4sOrg = "org.http4s" -val http4sVersion = "0.18.11" +val http4sVersion = "0.20.9" val dockeritVersion = "0.9.0" -scalaTestVersion := "3.0.1" -scalaCheckVersion := "1.13.4" - libraryDependencies ++= Seq( "io.verizon.journal" %% "core" % "3.0.18", http4sOrg %% "http4s-blaze-client" % http4sVersion, - http4sOrg %% "http4s-argonaut" % http4sVersion, + http4sOrg %% "http4s-circe" % http4sVersion, + "org.scalactic" %% "scalactic" % "3.0.8", + "org.scalatest" %% "scalatest" % "3.0.8" % "test", + "org.scalacheck" %% "scalacheck" % "1.14.0" % "test", "com.whisk" %% "docker-testkit-scalatest" % dockeritVersion % "test", "com.whisk" %% "docker-testkit-impl-docker-java" % dockeritVersion % "test" ) diff --git a/http4s/src/main/scala/Http4sConsul.scala b/http4s/src/main/scala/Http4sConsul.scala index 44d65c4..7e8e9f5 100644 --- a/http4s/src/main/scala/Http4sConsul.scala +++ b/http4s/src/main/scala/Http4sConsul.scala @@ -1,19 +1,15 @@ package helm package http4s -import argonaut.Json -import argonaut.Json.jEmptyObject -import argonaut.StringWrap.StringToStringWrap +import io.circe._, io.circe.syntax._ import cats.data.NonEmptyList import cats.effect.Effect import cats.~> import cats.implicits._ import journal.Logger -import org.http4s.Method.PUT import org.http4s._ -import org.http4s.argonaut._ +import org.http4s.circe._ import org.http4s.client._ -import org.http4s.client.dsl.Http4sClientDsl import org.http4s.headers.Authorization import org.http4s.Status.Successful import org.http4s.syntax.string.http4sStringSyntax @@ -25,9 +21,6 @@ final class Http4sConsulClient[F[_]]( credentials: Option[(String,String)] = None) (implicit F: Effect[F]) extends (ConsulOp ~> F) { - private[this] val dsl = new Http4sClientDsl[F]{} - import dsl._ - private implicit val keysDecoder: EntityDecoder[F, List[String]] = jsonOf[F, List[String]] private implicit val listKvGetResultDecoder: EntityDecoder[F, List[KVGetResult]] = jsonOf[F, List[KVGetResult]] private implicit val listServicesDecoder: EntityDecoder[F, Map[String, ServiceResponse]] = jsonOf[F, Map[String, ServiceResponse]] @@ -60,12 +53,14 @@ final class Http4sConsulClient[F[_]]( agentEnableMaintenanceMode(id, enable, reason) } - private def addConsulToken(req: Request[F]): Request[F] = + private def addConsulToken: Request[F] => Request[F] = req => accessToken.fold(req)(tok => req.putHeaders(Header("X-Consul-Token", tok))) - private def addCreds(req: Request[F]): Request[F] = + private def addCreds: Request[F] => Request[F] = req => credentials.fold(req){case (un,pw) => req.putHeaders(Authorization(BasicCredentials(un,pw)))} + private def enrichRequest: Request[F] => Request[F] = addConsulToken.andThen(addCreds) + /** A nice place to store the Consul response headers so we can pass them around */ private case class ConsulHeaders( index: Long, @@ -189,7 +184,7 @@ final class Http4sConsulClient[F[_]]( def kvSet(key: Key, value: Array[Byte]): F[Unit] = for { _ <- F.delay(log.debug(s"setting consul key $key to $value")) - req <- PUT(uri = baseUri / "v1" / "kv" / key, value).map(addConsulToken).map(addCreds) + req = enrichRequest(Request[F](method = Method.PUT, uri = baseUri / "v1" / "kv" / key).withEntity(value)) response <- client.expectOr[String](req)(handleConsulErrorResponse) } yield log.debug(s"setting consul key $key resulted in response $response") @@ -329,26 +324,26 @@ final class Http4sConsulClient[F[_]]( check: Option[HealthCheckParameter], checks: Option[NonEmptyList[HealthCheckParameter]] ): F[Unit] = { - val json: Json = - ("Name" := service) ->: - ("ID" :=? id) ->?: - ("Tags" :=? tags.map(_.toList)) ->?: - ("Address" :=? address) ->?: - ("Port" :=? port) ->?: - ("EnableTagOverride" :=? enableTagOverride) ->?: - ("Check" :=? check) ->?: - ("Checks" :=? checks.map(_.toList)) ->?: - jEmptyObject + val json: Json = Json.fromFields(List( + ("Name" , service.asJson) , + ("ID" , id.asJson) , + ("Tags" , tags.map(_.toList).asJson) , + ("Address" , address.asJson) , + ("Port" , port.asJson) , + ("EnableTagOverride" , enableTagOverride.asJson) , + ("Check" , check.asJson) , + ("Checks" , checks.map(_.toList).asJson) + )) for { _ <- F.delay(log.debug(s"registering $service with json: ${json.toString}")) - req <- PUT(baseUri / "v1" / "agent" / "service" / "register", json).map(addConsulToken).map(addCreds) + req = enrichRequest(Request[F](method = Method.PUT, uri = baseUri / "v1" / "agent" / "service" / "register").withEntity(json)) response <- client.expectOr[String](req)(handleConsulErrorResponse) } yield log.debug(s"registering service $service resulted in response $response") } def agentDeregisterService(id: String): F[Unit] = { - val req = addCreds(addConsulToken(Request(Method.PUT, uri = (baseUri / "v1" / "agent" / "service" / "deregister" / id)))) + val req = enrichRequest(Request[F](Method.PUT, uri = (baseUri / "v1" / "agent" / "service" / "deregister" / id))) for { _ <- F.delay(log.debug(s"deregistering service with id $id")) response <- client.expectOr[String](req)(handleConsulErrorResponse) diff --git a/http4s/src/test/scala/Http4sConsulTests.scala b/http4s/src/test/scala/Http4sConsulTests.scala index 8e4ce46..2f2aa03 100644 --- a/http4s/src/test/scala/Http4sConsulTests.scala +++ b/http4s/src/test/scala/Http4sConsulTests.scala @@ -11,6 +11,7 @@ import org.scalactic.TypeCheckedTripleEquals import org.scalatest._ import org.scalatest.matchers.{BeMatcher, MatchResult} import org.http4s.syntax.string.http4sStringSyntax + import scala.reflect.ClassTag class Http4sConsulTests extends FlatSpec with Matchers with TypeCheckedTripleEquals { @@ -235,8 +236,7 @@ object Http4sConsulTests { } def constantResponseClient(response: Response[IO]): Client[IO] = { - val dispResponse = DisposableResponse(response, IO.unit) - Client(Kleisli{req => IO.pure(dispResponse)}, IO.unit) + Client.fromHttpApp[IO](Kleisli{ _ => IO.pure(response) }) } def body(s: String): EntityBody[IO] = diff --git a/http4s/src/test/scala/Integration.scala b/http4s/src/test/scala/Integration.scala index 46e52ef..9bd4b18 100644 --- a/http4s/src/test/scala/Integration.scala +++ b/http4s/src/test/scala/Integration.scala @@ -2,8 +2,7 @@ package helm package http4s import scala.concurrent.duration.DurationInt - -import cats.effect.IO +import cats.effect.{ContextShift, IO} import cats.implicits._ import com.github.dockerjava.core.DefaultDockerClientConfig import com.github.dockerjava.netty.NettyDockerCmdExecFactory @@ -15,7 +14,8 @@ import org.http4s._ import org.http4s.client.blaze._ import org.scalacheck._ import org.scalatest._ -import org.scalatest.enablers.CheckerAsserting +import org.scalatestplus.scalacheck.CheckerAsserting +import org.scalatestplus.scalacheck.Checkers import org.scalatest.prop._ // This is how we use docker-kit. Nothing specific to helm in this trait. @@ -62,7 +62,10 @@ class IntegrationSpec with BeforeAndAfterAll with DockerConsulService with DockerTestKit { - val client = Http1Client[IO]().unsafeRunSync + import scala.concurrent.ExecutionContext.Implicits.global + implicit val ioEff: ContextShift[IO] = IO.contextShift(global) + + val client = BlazeClientBuilder[IO](global).stream.compile.toList.unsafeRunSync().head val baseUrl: Uri = Uri.fromString(s"http://${dockerHost}:${ConsulPort}").valueOr(throw _) diff --git a/project.sbt b/project.sbt index 0442ac2..f36c5f2 100644 --- a/project.sbt +++ b/project.sbt @@ -1,7 +1,6 @@ - organization in Global := "io.verizon.helm" -crossScalaVersions in Global := Seq("2.12.4", "2.11.12") +crossScalaVersions in Global := Seq("2.12.9") scalaVersion in Global := crossScalaVersions.value.head @@ -10,5 +9,3 @@ lazy val helm = project.in(file(".")).aggregate(core, http4s) lazy val core = project lazy val http4s = project dependsOn core - -enablePlugins(DisablePublishingPlugin) diff --git a/project/CentralRequirementsPlugin.scala b/project/CentralRequirementsPlugin.scala deleted file mode 100644 index 375bc6e..0000000 --- a/project/CentralRequirementsPlugin.scala +++ /dev/null @@ -1,59 +0,0 @@ -//: ---------------------------------------------------------------------------- -//: Copyright (C) 2017 Verizon. All Rights Reserved. -//: -//: Licensed under the Apache License, Version 2.0 (the "License"); -//: you may not use this file except in compliance with the License. -//: You may obtain a copy of the License at -//: -//: http://www.apache.org/licenses/LICENSE-2.0 -//: -//: Unless required by applicable law or agreed to in writing, software -//: distributed under the License is distributed on an "AS IS" BASIS, -//: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -//: See the License for the specific language governing permissions and -//: limitations under the License. -//: -//: ---------------------------------------------------------------------------- -package verizon.build - -import sbt._, Keys._ -import xerial.sbt.Sonatype.autoImport.sonatypeProfileName - -object CentralRequirementsPlugin extends AutoPlugin { - - override def trigger = allRequirements - - override def requires = RigPlugin - - override lazy val projectSettings = Seq( - sonatypeProfileName := "io.verizon", - pomExtra in Global := { - - - stew - Stew O'Connor - http://github.com/stew - - - timperrett - Timothy Perrett - http://github.com/timperrett - - - ceedubs - Cody Allen - http://github.com/ceedubs - - - rossabaker - Ross Baker - http://github.com/rossabaker - - - }, - licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.html")), - homepage := Some(url("http://verizon.github.io/helm/")), - scmInfo := Some(ScmInfo(url("https://github.com/verizon/helm"), - "git@github.com:verizon/helm.git")) - ) -} diff --git a/project/build.properties b/project/build.properties index 7d789d4..c0bab04 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.12 \ No newline at end of file +sbt.version=1.2.8 diff --git a/project/plugins.sbt b/project/plugins.sbt index ad7e47f..0a38b78 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1 @@ -addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.3") -addSbtPlugin("io.verizon.build" % "sbt-rig" % "2.0.29") - +addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.7")