Skip to content

Commit

Permalink
Merge pull request #45 from lensesio/chore/reformat
Browse files Browse the repository at this point in the history
Chore/reformat
  • Loading branch information
davidsloan authored Mar 10, 2023
2 parents d49106e + f95f8d8 commit 7523823
Show file tree
Hide file tree
Showing 38 changed files with 855 additions and 836 deletions.
32 changes: 31 additions & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
version = "2.4.2"
version=2.6.1
maxColumn = 120
preset = IntelliJ
align.preset = most
align.openParenCallSite = true
align.tokens.add = [{code = "="},{code = ":"}]
align.multiline = false
align.arrowEnumeratorGenerator = false
assumeStandardLibraryStripMargin = true
newlines.source=keep
newlines.sometimesBeforeColonInMethodReturnType = false
newlines.alwaysBeforeMultilineDef = false
verticalMultiline.atDefnSite = true
verticalMultiline.excludeDanglingParens = []
newlines.implicitParamListModifierForce = [before,after]
optIn.breakChainOnFirstMethodDot = false
optIn.configStyleArguments = true
runner.optimizer.forceConfigStyleOnOffset = 120
runner.optimizer.forceConfigStyleMinArgCount = 1
trailingCommas = always
spaces.inImportCurlyBraces = true

rewrite.rules = [
PreferCurlyFors,
RedundantBraces,
ExpandImportSelectors,
RedundantParens
]
rewrite.redundantBraces.generalExpressions = false

project.git = true
7 changes: 3 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ name := "secret-provider"
javacOptions ++= Seq("--release", "11")
javaOptions ++= Seq("-Xms512M", "-Xmx2048M")


lazy val subProjects: Seq[Project] = Seq(
`secret-provider`
`secret-provider`,
)
lazy val subProjectsRefs: Seq[ProjectReference] = subProjects.map(projectToLocalProject)

Expand Down Expand Up @@ -38,9 +37,9 @@ lazy val `secret-provider` = (project in file("secret-provider"))

addCommandAlias(
"validateAll",
";scalafmtCheck;scalafmtSbtCheck;test:scalafmtCheck;"
";scalafmtCheck;scalafmtSbtCheck;test:scalafmtCheck;",
)
addCommandAlias(
"formatAll",
";scalafmt;scalafmtSbt;test:scalafmt;"
";scalafmt;scalafmtSbt;test:scalafmt;",
)
54 changes: 27 additions & 27 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ trait Dependencies {

object Versions {

val scalaLoggingVersion = "3.9.5"
val kafkaVersion = "3.4.0"
val vaultVersion = "5.1.0"
val scalaLoggingVersion = "3.9.5"
val kafkaVersion = "3.4.0"
val vaultVersion = "5.1.0"
val azureKeyVaultVersion = "4.5.2"
val azureIdentityVersion = "1.8.0"
val awsSecretsVersion = "1.12.411"
val awsSecretsVersion = "1.12.411"

//test
val scalaTestVersion = "3.2.15"
val mockitoVersion = "3.2.15.0"
val byteBuddyVersion = "1.14.0"
val slf4jVersion = "2.0.5"
val commonsIOVersion = "1.3.2"
val jettyVersion = "11.0.13"
val scalaTestVersion = "3.2.15"
val mockitoVersion = "3.2.15.0"
val byteBuddyVersion = "1.14.0"
val slf4jVersion = "2.0.5"
val commonsIOVersion = "1.3.2"
val jettyVersion = "11.0.13"
val testContainersVersion = "1.12.3"
val flexmarkVersion = "0.64.0"
val flexmarkVersion = "0.64.0"

val scalaCollectionCompatVersion = "2.8.1"
val jakartaServletVersion = "6.0.0"
val jakartaServletVersion = "6.0.0"

}

Expand All @@ -45,13 +45,13 @@ trait Dependencies {
val `aws-secrets-manager` =
"com.amazonaws" % "aws-java-sdk-secretsmanager" % awsSecretsVersion

val `mockito` = "org.scalatestplus" %% "mockito-4-6" % mockitoVersion
val `scalatest` = "org.scalatest" %% "scalatest" % scalaTestVersion
val `jetty` = "org.eclipse.jetty" % "jetty-server" % jettyVersion
val `commons-io` = "org.apache.commons" % "commons-io" % commonsIOVersion
val `flexmark` = "com.vladsch.flexmark" % "flexmark-all" % flexmarkVersion
val `slf4j-api` = "org.slf4j" % "slf4j-api" % slf4jVersion
val `slf4j-simple` = "org.slf4j" % "slf4j-simple" % slf4jVersion
val `mockito` = "org.scalatestplus" %% "mockito-4-6" % mockitoVersion
val `scalatest` = "org.scalatest" %% "scalatest" % scalaTestVersion
val `jetty` = "org.eclipse.jetty" % "jetty-server" % jettyVersion
val `commons-io` = "org.apache.commons" % "commons-io" % commonsIOVersion
val `flexmark` = "com.vladsch.flexmark" % "flexmark-all" % flexmarkVersion
val `slf4j-api` = "org.slf4j" % "slf4j-api" % slf4jVersion
val `slf4j-simple` = "org.slf4j" % "slf4j-simple" % slf4jVersion

val `byteBuddy` = "net.bytebuddy" % "byte-buddy" % byteBuddyVersion
val `scalaCollectionCompat` =
Expand All @@ -71,14 +71,14 @@ trait Dependencies {
`aws-secrets-manager`,
`scalaCollectionCompat`,
`jakartaServlet` % Test,
`mockito` % Test,
`byteBuddy` % Test,
`scalatest` % Test,
`jetty` % Test,
`commons-io` % Test,
`flexmark` % Test,
`slf4j-api` % Test,
`slf4j-simple` % Test
`mockito` % Test,
`byteBuddy` % Test,
`scalatest` % Test,
`jetty` % Test,
`commons-io` % Test,
`flexmark` % Test,
`slf4j-api` % Test,
`slf4j-simple` % Test,
)

}
32 changes: 16 additions & 16 deletions project/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,28 @@
*/

import sbt.Keys._
import sbt.{Def, _}
import sbt.Def
import sbt._
import sbtassembly.AssemblyKeys._
import sbtassembly.MergeStrategy

object Settings extends Dependencies {

val scala212 = "2.12.14"
val scala213 = "2.13.10"
val scala3 = "3.2.2"
val scala3 = "3.2.2"

val nextVersion = "2.1.7"
val artifactVersion = {
sys.env.get("LENSES_TAG_NAME") match {
case Some(tag) => tag
case _ => s"$nextVersion-SNAPSHOT"
case _ => s"$nextVersion-SNAPSHOT"
}
}

object ScalacFlags {
val FatalWarnings212 = "-Xfatal-warnings"
val FatalWarnings213 = "-Werror"
val FatalWarnings212 = "-Xfatal-warnings"
val FatalWarnings213 = "-Werror"
val WarnUnusedImports212 = "-Ywarn-unused-import"
val WarnUnusedImports213 = "-Ywarn-unused:imports"
}
Expand All @@ -34,31 +35,30 @@ object Settings extends Dependencies {
scalaOrganization := "org.scala-lang",
resolvers ++= Seq(
Resolver.mavenLocal,
Resolver.mavenCentral
Resolver.mavenCentral,
),
crossScalaVersions := List(/*scala3, */ scala213 /*scala212*/),
crossScalaVersions := List( /*scala3, */ scala213 /*scala212*/ ),
Compile / scalacOptions ++= Seq(
"-release:11",
"-encoding",
"utf8",
"-deprecation",
"-unchecked",
"-feature",
"11"
"11",
),
Compile / scalacOptions ++= {
Seq(
ScalacFlags.WarnUnusedImports213
ScalacFlags.WarnUnusedImports213,
)
},
Compile / console / scalacOptions --= Seq(
ScalacFlags.FatalWarnings212,
ScalacFlags.FatalWarnings213,
ScalacFlags.WarnUnusedImports212,
ScalacFlags.WarnUnusedImports213
ScalacFlags.WarnUnusedImports213,
),

Test / fork := true
Test / fork := true,
)

implicit final class AssemblyConfigurator(project: Project) {
Expand All @@ -71,7 +71,7 @@ object Settings extends Dependencies {
"org.apache.avro",
"org.apache.kafka",
"io.confluent",
"org.apache.zookeeper"
"org.apache.zookeeper",
)
cp filter { f => excludes.exists(f.data.getName.contains(_)) }
},
Expand All @@ -82,9 +82,9 @@ object Settings extends Dependencies {
case x =>
val oldStrategy = (assembly / assemblyMergeStrategy).value
oldStrategy(x)
}
},
)

}
}

}
}
3 changes: 2 additions & 1 deletion project/Versioning.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import java.util.regex.{Matcher, Pattern}
import java.util.regex.Matcher
import java.util.regex.Pattern

case class SemanticVersioning(version: String) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,52 @@ package io.lenses.connect.secrets.async

import com.typesafe.scalalogging.StrictLogging

import java.util.concurrent.atomic.{AtomicBoolean, AtomicLong}
import java.util.concurrent.{Executors, TimeUnit}
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicLong
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
import scala.concurrent.duration.Duration

class AsyncFunctionLoop(interval: Duration, description: String)(thunk: => Unit)
extends AutoCloseable
with StrictLogging {

private val running = new AtomicBoolean(false)
private val success = new AtomicLong(0L)
private val failure = new AtomicLong(0L)
private val running = new AtomicBoolean(false)
private val success = new AtomicLong(0L)
private val failure = new AtomicLong(0L)
private val executorService = Executors.newFixedThreadPool(1)

def start(): Unit = {
if (!running.compareAndSet(false, true)) {
throw new IllegalStateException(s"$description already running.")
}
logger.info(
s"Starting $description loop with an interval of ${interval.toMillis}ms."
s"Starting $description loop with an interval of ${interval.toMillis}ms.",
)
executorService.submit(new Runnable {
override def run(): Unit = {
while (running.get()) {
try {
Thread.sleep(interval.toMillis)
thunk
success.incrementAndGet()
} catch {
case _: InterruptedException =>
case t: Throwable =>
logger.warn("Failed to renew the Kerberos ticket", t)
failure.incrementAndGet()
executorService.submit(
new Runnable {
override def run(): Unit =
while (running.get()) {
try {
Thread.sleep(interval.toMillis)
thunk
success.incrementAndGet()
} catch {
case _: InterruptedException =>
case t: Throwable =>
logger.warn("Failed to renew the Kerberos ticket", t)
failure.incrementAndGet()
}
}
}
}
})
},
)
}

override def close(): Unit = {
override def close(): Unit =
if (running.compareAndSet(true, false)) {
executorService.shutdownNow()
executorService.awaitTermination(10000, TimeUnit.MILLISECONDS)
}
}

def successRate: Long = success.get()
def failureRate: Long = failure.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,42 @@

package io.lenses.connect.secrets.config

import io.lenses.connect.secrets.connect.{AuthMode, _}
import org.apache.kafka.common.config.ConfigDef.{Importance, Type}
import org.apache.kafka.common.config.{AbstractConfig, ConfigDef}
import io.lenses.connect.secrets.connect.AuthMode
import io.lenses.connect.secrets.connect._
import org.apache.kafka.common.config.ConfigDef.Importance
import org.apache.kafka.common.config.ConfigDef.Type
import org.apache.kafka.common.config.AbstractConfig
import org.apache.kafka.common.config.ConfigDef

import java.util

object AWSProviderConfig {

val AWS_REGION: String = "aws.region"
val AWS_REGION: String = "aws.region"
val AWS_ACCESS_KEY: String = "aws.access.key"
val AWS_SECRET_KEY: String = "aws.secret.key"
val AUTH_METHOD: String = "aws.auth.method"
val AUTH_METHOD: String = "aws.auth.method"

val config: ConfigDef = new ConfigDef()
.define(
AWS_REGION,
Type.STRING,
Importance.HIGH,
"AWS region the Secrets manager is in"
"AWS region the Secrets manager is in",
)
.define(
AWS_ACCESS_KEY,
Type.STRING,
null,
Importance.HIGH,
"AWS access key"
"AWS access key",
)
.define(
AWS_SECRET_KEY,
Type.PASSWORD,
null,
Importance.HIGH,
"AWS password key"
"AWS password key",
)
.define(
AUTH_METHOD,
Expand All @@ -49,16 +52,15 @@ object AWSProviderConfig {
| AWS authenticate method, 'credentials' to use the provided credentials
| or 'default' for the standard AWS provider chain.
| Default is 'credentials'
|""".stripMargin
|""".stripMargin,
)
.define(
FILE_DIR,
Type.STRING,
"",
Importance.MEDIUM,
FILE_DIR_DESC
FILE_DIR_DESC,
)
}

case class AWSProviderConfig(props: util.Map[String, _])
extends AbstractConfig(AWSProviderConfig.config, props)
case class AWSProviderConfig(props: util.Map[String, _]) extends AbstractConfig(AWSProviderConfig.config, props)
Loading

0 comments on commit 7523823

Please sign in to comment.