Skip to content

Commit

Permalink
Merge pull request #620 from MAIF/technical/upgrade-js-deps
Browse files Browse the repository at this point in the history
Upgrade dependencies
Upgrade sbt, scala & play framework
leave mongo support
new documentation support with docusaurus
  • Loading branch information
quentinovega authored Dec 12, 2023
2 parents a834f9c + d10fdeb commit 98c6ab9
Show file tree
Hide file tree
Showing 321 changed files with 27,954 additions and 29,656 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/front-office-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v1
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
java-version: '21'
# install node lts
- name: setup node
uses: actions/setup-node@v3
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
steps:
- uses: actions/[email protected]
# setup java to use sbt (?)
- name: Set up JDK 11
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
java-version: '21'
- uses: coursier/cache-action@v5
# install node 16
# install node lts
- name: setup node
uses: actions/setup-node@v3
with:
Expand Down Expand Up @@ -54,8 +54,7 @@ jobs:
- name: update version number
id: version
run: |
find ./manual/src/main/paradox -type f -name '*.md' | xargs node ./scripts/version.js ${{ github.event.inputs.lastVersion }} ${{ github.event.inputs.releaseversion }}
find ./docs -type f -name '*.html' -d 1 | xargs node ./scripts/version.js ${{ github.event.inputs.lastVersion }} ${{ github.event.inputs.releaseversion }}
find ./manual -type f -name '*.md' | xargs node ./scripts/version.js ${{ github.event.inputs.lastVersion }} ${{ github.event.inputs.releaseversion }}
find ./daikoku/public/swaggers -type f -name 'admin-api-openapi.*' -d 1 | xargs node ./scripts/version.js ${{ github.event.inputs.lastVersion }} ${{ github.event.inputs.releaseversion }}
echo "diff=$(git diff --numstat | wc -l)" >> $GITHUB_OUTPUT
- name: Commit formatted sources
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ jobs:
steps:
- uses: actions/[email protected]
# setup java to use sbt
- name: Set up JDK 11
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
java-version: '21'
#test DK
- uses: coursier/cache-action@v6
- name: test
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/update-dev-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,18 @@ jobs:
name: Build developer documentation
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
cache: 'npm'
- name: copy openapi
id: openapi
run: cp ./public/swaggers/admin-api-openapi.yaml ./manual/static/admin-api-openapi.yaml
- name: Generate dev documentation website
id: doc
run: |
sh ./scripts/build.sh devdoc
sh ./scripts/build.sh manual
echo "::set-output name=diff::$(git diff --numstat | wc -l)"
- name: Commit files
run: |
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ daikoku/javascript/cypress/screenshots
daikoku/javascript/index.json
.yalc
yalc.lock
daikoku/javascript/yarn-error.log
daikoku/javascript/yarn-error.log
manual/.docusaurus
2 changes: 1 addition & 1 deletion daikoku/app/actions/actions.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.maif.otoroshi.daikoku.actions

import akka.http.scaladsl.util.FastFuture
import org.apache.pekko.http.scaladsl.util.FastFuture
import cats.implicits.catsSyntaxOptionId
import fr.maif.otoroshi.daikoku.domain.TeamPermission.{Administrator, ApiEditor}
import fr.maif.otoroshi.daikoku.domain._
Expand Down
55 changes: 26 additions & 29 deletions daikoku/app/audit/audit.scala
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
package fr.maif.otoroshi.daikoku.audit

import java.util.Base64
import java.util.concurrent.{ConcurrentHashMap, TimeUnit}
import akka.actor.{Actor, ActorSystem, PoisonPill, Props, Terminated}
import akka.http.scaladsl.util.FastFuture
import akka.http.scaladsl.util.FastFuture._
import akka.kafka.ProducerSettings
import akka.stream.scaladsl.{Flow, Keep, Sink, Source}
import akka.stream.{OverflowStrategy, QueueOfferResult}
import akka.{Done, NotUsed}
import org.apache.pekko.Done
import org.apache.pekko.actor.{Actor, ActorSystem, PoisonPill, Props, Terminated}
import org.apache.pekko.http.scaladsl.util.FastFuture
import org.apache.pekko.http.scaladsl.util.FastFuture._
import org.apache.pekko.stream.scaladsl.{Keep, Sink, Source}
import org.apache.pekko.stream.{Materializer, OverflowStrategy, QueueOfferResult}
import cats.data.EitherT
import controllers.AppError
import diffson.DiffOps
import fr.maif.otoroshi.daikoku.audit.config.{ElasticAnalyticsConfig, Webhook}
import fr.maif.otoroshi.daikoku.domain._
import fr.maif.otoroshi.daikoku.env.Env
import fr.maif.otoroshi.daikoku.logger.AppLogger
import fr.maif.otoroshi.daikoku.utils.RequestImplicits._
import fr.maif.otoroshi.daikoku.utils.Translator
import fr.maif.otoroshi.daikoku.utils.{IdGenerator, Translator}
import org.apache.kafka.clients.CommonClientConfigs
import org.apache.kafka.clients.producer.{Callback, KafkaProducer, Producer, ProducerRecord, RecordMetadata}
import org.apache.kafka.clients.producer.{Callback, Producer, ProducerRecord, RecordMetadata}
import org.apache.kafka.common.config.SslConfigs
import org.apache.kafka.common.config.internals.BrokerSecurityConfigs
import org.apache.kafka.common.serialization.{ByteArraySerializer, StringSerializer}
import org.apache.pekko.kafka.ProducerSettings
import org.joda.time.DateTime
import org.joda.time.format.ISODateTimeFormat
import play.api.Logger
import play.api.i18n.{I18nSupport, Lang, MessagesApi}
import play.api.i18n.MessagesApi
import play.api.libs.json._
import play.api.libs.ws.WSRequest
import play.api.mvc.RequestHeader
import reactivemongo.bson.BSONObjectID

import java.util.Base64
import java.util.concurrent.{ConcurrentHashMap, TimeUnit}
import scala.collection.concurrent.TrieMap
import scala.concurrent.duration.{FiniteDuration, _}
import scala.concurrent.{Await, ExecutionContext, Future, Promise}
Expand Down Expand Up @@ -188,10 +185,10 @@ case class TenantAuditEvent(evt: AuditEvent,
}

def toJson(implicit env: Env): JsObject = Json.obj(
"_id" -> BSONObjectID.generate().stringify,
"_id" -> IdGenerator.token(32),
"@type" -> theType,
"@id" -> env.snowflakeGenerator.nextIdStr(),
"@timestamp" -> play.api.libs.json.JodaWrites.JodaDateTimeNumberWrites
"@timestamp" -> json.DateTimeFormat
.writes(DateTime.now()),
"@tenantId" -> tenant.id.value,
"@userId" -> user.id.value,
Expand Down Expand Up @@ -234,10 +231,10 @@ object AuditActor {

class AuditActor(implicit env: Env, messagesApi: MessagesApi, translator: Translator) extends Actor {

implicit lazy val ec = env.defaultExecutionContext
implicit lazy val ec: ExecutionContext = env.defaultExecutionContext

lazy val logger = Logger("audit-actor")
lazy val console = Logger("audit-console")
lazy val logger: Logger = Logger("audit-actor")
lazy val console: Logger = Logger("audit-console")

lazy val kafkaWrapperAudit =
new KafkaWrapper(env.defaultActorSystem, env, _.auditTopic)
Expand Down Expand Up @@ -437,7 +434,7 @@ case class KafkaConfig(servers: Seq[String],
)

object KafkaConfig {
implicit val format = Json.format[KafkaConfig]
implicit val format: OFormat[KafkaConfig] = Json.format[KafkaConfig]
}

object KafkaSettings {
Expand Down Expand Up @@ -500,12 +497,12 @@ class KafkaWrapper(actorSystem: ActorSystem,
class KafkaWrapperActor(env: Env, topicFunction: KafkaConfig => String)
extends Actor {

implicit val ec = env.defaultExecutionContext
implicit val ec: ExecutionContext = env.defaultExecutionContext

var config: Option[KafkaConfig] = None
var eventProducer: Option[KafkaEventProducer] = None

lazy val logger = play.api.Logger("kafka-wrapper")
lazy val logger: Logger = play.api.Logger("kafka-wrapper")

override def receive: Receive = {
case event: KafkaWrapperEvent
Expand Down Expand Up @@ -549,9 +546,9 @@ class KafkaEventProducer(_env: Env,
config: KafkaConfig,
topicFunction: KafkaConfig => String) {

implicit val ec = _env.defaultExecutionContext
implicit val ec: ExecutionContext = _env.defaultExecutionContext

lazy val logger = play.api.Logger("kafka-connector")
lazy val logger: Logger = play.api.Logger("kafka-connector")

lazy val topic = topicFunction(config)

Expand All @@ -560,10 +557,10 @@ class KafkaEventProducer(_env: Env,
private lazy val producerSettings =
KafkaSettings.producerSettings(_env, config)
private lazy val producer: Producer[Array[Byte], String] =
producerSettings.createKafkaProducer
producerSettings.createKafkaProducer()

def publish(event: JsValue): Future[Done] = {
val promise = Promise[RecordMetadata]
val promise = Promise[RecordMetadata]()
try {
val message = Json.stringify(event)
producer.send(new ProducerRecord[Array[Byte], String](topic, message),
Expand Down Expand Up @@ -667,7 +664,7 @@ class ElasticWritesAnalytics(config: ElasticAnalyticsConfig, env: Env) {
private val index: String = config.index.getOrElse("otoroshi-events")
private val `type`: String = config.`type`.getOrElse("event")
private val searchUri = urlFromPath(s"/$index*/_search")
private implicit val mat = env.defaultMaterializer
private implicit val mat: Materializer = env.defaultMaterializer

private def url(url: String): WSRequest = {
val builder = env.wsClient.url(url)
Expand Down Expand Up @@ -818,7 +815,7 @@ class ElasticReadsAnalytics(config: ElasticAnalyticsConfig, env: Env) {
private val index: String = config.index.getOrElse("otoroshi-events")
private val `type`: String = config.`type`.getOrElse("event")
private val searchUri = urlFromPath(s"/$index*/_search")
private implicit val mat = env.defaultMaterializer
private implicit val mat: Materializer = env.defaultMaterializer

private def url(url: String): WSRequest = {
val builder = env.wsClient.url(url)
Expand Down
4 changes: 2 additions & 2 deletions daikoku/app/audit/config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ case class ElasticAnalyticsConfig(
}

object ElasticAnalyticsConfig {
val format = new Format[ElasticAnalyticsConfig] {
val format: Format[ElasticAnalyticsConfig] = new Format[ElasticAnalyticsConfig] {
override def writes(o: ElasticAnalyticsConfig) = {
Json.obj(
"clusterUri" -> o.clusterUri,
Expand Down Expand Up @@ -57,5 +57,5 @@ case class Webhook(url: String,
}

object Webhook {
implicit val format = Json.format[Webhook]
implicit val format: OFormat[Webhook] = Json.format[Webhook]
}
30 changes: 16 additions & 14 deletions daikoku/app/controllers/AdminApiController.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package fr.maif.otoroshi.daikoku.ctrls

import akka.http.scaladsl.util.FastFuture
import akka.util.ByteString
import org.apache.pekko.http.scaladsl.util.FastFuture
import org.apache.pekko.stream.Materializer
import org.apache.pekko.util.ByteString
import cats.implicits._
import fr.maif.otoroshi.daikoku.actions.{DaikokuAction, DaikokuActionContext}
import fr.maif.otoroshi.daikoku.audit.AuditTrailEvent
Expand All @@ -13,14 +14,15 @@ import fr.maif.otoroshi.daikoku.logger.AppLogger
import fr.maif.otoroshi.daikoku.utils.OtoroshiClient
import fr.maif.otoroshi.daikoku.utils.admin._
import io.vertx.pgclient.PgPool
import org.apache.pekko.stream.scaladsl.Source
import play.api.http.HttpEntity
import play.api.libs.json.{JsArray, JsObject, JsValue, Json}
import play.api.libs.streams.Accumulator
import play.api.mvc._
import storage.drivers.postgres.PostgresDataStore
import storage.{DataStore, Repo}

import scala.io.Source
import scala.concurrent.ExecutionContext
import scala.util.{Failure, Success, Using}

class StateController(DaikokuAction: DaikokuAction,
Expand All @@ -30,11 +32,11 @@ class StateController(DaikokuAction: DaikokuAction,
pgPool: PgPool)
extends AbstractController(cc) {

implicit val ec = env.defaultExecutionContext
implicit val mat = env.defaultMaterializer
implicit val ev = env
implicit val ec: ExecutionContext = env.defaultExecutionContext
implicit val mat: Materializer = env.defaultMaterializer
implicit val ev: Env = env

val bodyParser = BodyParser("Import parser") { _ =>
val bodyParser: BodyParser[Source[ByteString, _]] = BodyParser("Import parser") { _ =>
Accumulator.source[ByteString].map(Right.apply)
}

Expand Down Expand Up @@ -185,11 +187,11 @@ class StateAdminApiController(
cc: ControllerComponents)
extends AbstractController(cc) {

implicit val ec = env.defaultExecutionContext
implicit val mat = env.defaultMaterializer
implicit val ev = env
implicit val ec: ExecutionContext = env.defaultExecutionContext
implicit val mat: Materializer = env.defaultMaterializer
implicit val ev: Env = env

val bodyParser = BodyParser("Import parser") { _ =>
val bodyParser: BodyParser[Source[ByteString, _]] = BodyParser("Import parser") { _ =>
Accumulator.source[ByteString].map(Right.apply)
}

Expand Down Expand Up @@ -406,8 +408,8 @@ class CredentialsAdminApiController(DaikokuApiAction: DaikokuApiAction,
env: Env,
cc: ControllerComponents)
extends AbstractController(cc) {
implicit val ec = env.defaultExecutionContext
implicit val ev = env
implicit val ec: ExecutionContext = env.defaultExecutionContext
implicit val ev: Env = env

def getCredentials(token: String) = DaikokuApiAction.async { ctx =>
env.dataStore.apiSubscriptionRepo
Expand Down Expand Up @@ -614,7 +616,7 @@ class AdminApiSwaggerController(
ctrl1.pathForIntegrationApi()

def swagger() = Action {
Using(Source.fromResource("public/swaggers/admin-api-openapi.json")) {
Using(scala.io.Source.fromResource("public/swaggers/admin-api-openapi.json")) {
source =>
source.mkString
} match {
Expand Down
Loading

0 comments on commit 98c6ab9

Please sign in to comment.