diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ba4df0..1686994 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,10 +51,12 @@ jobs: - name: Check that workflows are up to date run: sbt ++${{ matrix.scala }} githubWorkflowCheck - - name: Login to Docker - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: echo ${GITHUB_TOKEN} | docker login docker.pkg.github.com -u ${GITHUB_ACTOR} --password-stdin + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: docker.pkg.github.com + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Launch Nakadi run: docker-compose up -d diff --git a/build.sbt b/build.sbt index 943005c..cb051e7 100644 --- a/build.sbt +++ b/build.sbt @@ -159,11 +159,13 @@ pomIncludeRepository := (_ => false) resolvers += Resolver.jcenterRepo ThisBuild / githubWorkflowBuild := Seq( - WorkflowStep.Run( - List("echo ${GITHUB_TOKEN} | docker login docker.pkg.github.com -u ${GITHUB_ACTOR} --password-stdin"), - name = Some("Login to Docker"), - env = Map( - "GITHUB_TOKEN" -> "${{ secrets.GITHUB_TOKEN }}" + WorkflowStep.Use( + UseRef.Public("docker", "login-action", "v1"), + name = Some("Login to GitHub Container Registry"), + params = Map( + "registry" -> "docker.pkg.github.com", + "username" -> "${{ github.actor }}", + "password" -> "${{ secrets.GITHUB_TOKEN }}" ) ), WorkflowStep.Run(List("docker-compose up -d"), name = Some("Launch Nakadi")), diff --git a/src/main/scala/org/zalando/kanadi/api/Events.scala b/src/main/scala/org/zalando/kanadi/api/Events.scala index 1080d18..9cbaa48 100644 --- a/src/main/scala/org/zalando/kanadi/api/Events.scala +++ b/src/main/scala/org/zalando/kanadi/api/Events.scala @@ -151,11 +151,12 @@ final case class Metadata(eid: EventId = EventId.random, flowId: Option[FlowId] = None, partition: Option[Partition] = None, partitionCompactionKey: Option[PartitionCompactionKey] = None, - spanCtx: Option[SpanCtx] = None) + spanCtx: Option[SpanCtx] = None, + publishedBy: Option[PublishedBy] = None) object Metadata { - implicit val metadataEncoder: Encoder[Metadata] = Encoder.forProduct9( + implicit val metadataEncoder: Encoder[Metadata] = Encoder.forProduct10( "eid", "occurred_at", "event_type", @@ -164,10 +165,11 @@ object Metadata { "flow_id", "partition", "partition_compaction_key", - "span_ctx" + "span_ctx", + "published_by" )(x => Metadata.unapply(x).get) - implicit val metadataDecoder: Decoder[Metadata] = Decoder.forProduct9( + implicit val metadataDecoder: Decoder[Metadata] = Decoder.forProduct10( "eid", "occurred_at", "event_type", @@ -176,7 +178,8 @@ object Metadata { "flow_id", "partition", "partition_compaction_key", - "span_ctx" + "span_ctx", + "published_by" )(Metadata.apply) } diff --git a/src/main/scala/org/zalando/kanadi/models/PublishedBy.scala b/src/main/scala/org/zalando/kanadi/models/PublishedBy.scala new file mode 100644 index 0000000..45f8c8e --- /dev/null +++ b/src/main/scala/org/zalando/kanadi/models/PublishedBy.scala @@ -0,0 +1,13 @@ +package org.zalando.kanadi.models + +import io.circe.syntax._ +import io.circe.{Decoder, Encoder} + +final case class PublishedBy(name: String) extends AnyVal + +object PublishedBy { + implicit val publishedByEncoder: Encoder[PublishedBy] = + Encoder.instance[PublishedBy](_.name.asJson) + implicit val publishedByDecoder: Decoder[PublishedBy] = + Decoder[String].map(PublishedBy.apply) +} diff --git a/src/test/scala/org/zalando/kanadi/api/JsonSpec.scala b/src/test/scala/org/zalando/kanadi/api/JsonSpec.scala index 86bda87..ea3e3cb 100644 --- a/src/test/scala/org/zalando/kanadi/api/JsonSpec.scala +++ b/src/test/scala/org/zalando/kanadi/api/JsonSpec.scala @@ -10,7 +10,7 @@ import org.specs2.specification.core.SpecStructure import io.circe._ import io.circe.parser._ import io.circe.syntax._ -import org.zalando.kanadi.models.{EventId, SpanCtx} +import org.zalando.kanadi.models.{EventId, SpanCtx, PublishedBy} import java.time.OffsetDateTime import io.circe.CursorOp.DownField @@ -28,7 +28,9 @@ class JsonSpec extends Specification { val uuid = UUID.randomUUID() val testEvent = SomeEvent("Bart", "Simpson", uuid) val now = OffsetDateTime.now() - val md = Metadata(eid = EventId(UUID.fromString("4ae5011e-eb01-11e5-8b4a-1c6f65464fc6")), occurredAt = now) + val md = Metadata(eid = EventId(UUID.fromString("4ae5011e-eb01-11e5-8b4a-1c6f65464fc6")), + occurredAt = now, + publishedBy = Some(PublishedBy("bart_simpson"))) val coreEventJson = s""" "first_name": "Bart", @@ -37,7 +39,7 @@ class JsonSpec extends Specification { """ val metadata = - s""""eid": "4ae5011e-eb01-11e5-8b4a-1c6f65464fc6", "occurred_at": ${now.asJson}""" + s""""eid": "4ae5011e-eb01-11e5-8b4a-1c6f65464fc6", "occurred_at": ${now.asJson}, "published_by": "bart_simpson"""" val businessEventJson = s"""{ "metadata": {$metadata},