Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/app-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6

- name: Run ktlint Check
run: ./gradlew :ktlintCheck --stacktrace --configuration-cache
- name: Run Spotless Check
run: ./gradlew :spotlessCheck --stacktrace --configuration-cache

unit-tests:
name: Run Unit Tests
Expand Down
11 changes: 10 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
kotlin("jvm")
application
alias(libs.plugins.fabric8.generator)
alias(libs.plugins.ktlint)
alias(libs.plugins.spotless)
}

group = "no.fintlabs"
Expand Down Expand Up @@ -187,6 +187,15 @@ tasks {
}
}

spotless {
kotlin {
ktlint(libs.versions.ktlint.get())
}
kotlinGradle {
ktlint(libs.versions.ktlint.get())
}
}

fun fetchNumCores(): Int =
Runtime
.getRuntime()
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jackson = "2.21.5"
logunit = "2.0.0"
http4k = "6.53.0.0"
micrometer = "1.17.0"
ktlint = "1.8.0"
spotless = "8.8.0"

[libraries]
fabric8-kubernetes-client = { module = "io.fabric8:kubernetes-client", version.ref = "fabric8" }
Expand Down Expand Up @@ -51,7 +53,7 @@ koin-test-junit5 = { module = "io.insert-koin:koin-test-junit5" }
[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version = "2.4.0"}
fabric8-generator = { id = "io.fabric8.java-generator", version.ref = "fabric8" }
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version="14.2.0" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }

[bundles]
operator = ["operator-framework-core", "operator-micrometer-support"]
Expand Down
8 changes: 4 additions & 4 deletions scripts/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
repository_root=$(git rev-parse --show-toplevel)
cd "$repository_root" || exit 1

echo "[git pre-commit hook] Running ktlintFormat before commit."
echo "[git pre-commit hook] Running spotlessApply before commit."

staged_files=$(git diff --name-only --cached --diff-filter=d)
if [ -z "$staged_files" ]; then
echo "No staged files, skipping formatting."
exit 0
fi

./gradlew :ktlintFormat --configuration-cache
./gradlew :spotlessApply --configuration-cache --daemon
status=$?

echo "Finished ktlintFormat with status: $status"
echo "Finished spotlessApply with status: $status"

if [ "$status" -ne 0 ]; then
echo "Error running ktlintFormat, aborting commit."
echo "Error running spotlessApply, aborting commit."
exit "$status"
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,25 @@ class CustomGenericKubernetesResourceMatcher<R : HasMetadata> {
resourceMap: MutableMap<String, Any>,
) {
when (resource) {
is Pod -> resource.spec.containers.normalizeContainers(resourceMap)
is Deployment ->
is Pod -> {
resource.spec.containers.normalizeContainers(resourceMap)
}

is Deployment -> {
resource.spec.template.spec.containers
.normalizeContainers(resourceMap)
is Job ->
}

is Job -> {
resource.spec.template.spec.containers
.normalizeContainers(resourceMap)
is ReplicaSet ->
}

is ReplicaSet -> {
resource.spec.template.spec.containers
.normalizeContainers(resourceMap)
}

is StatefulSet -> {
resource.spec.template.spec.containers
.normalizeContainers(resourceMap)
Expand All @@ -162,10 +171,14 @@ class CustomGenericKubernetesResourceMatcher<R : HasMetadata> {
)
}
}
is PersistentVolumeClaim ->

is PersistentVolumeClaim -> {
resource.spec.resources?.normalizeResources(resourceMap, "spec", "resources")
is PersistentVolume ->
}

is PersistentVolume -> {
resource.spec.capacity?.normalizeQuantity(resourceMap, "spec", "capacity")
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ class KubernetesResourceSource(

private fun fromPath(path: Path): List<KubernetesResourceSource> =
when {
Files.isDirectory(path) ->
Files.isDirectory(path) -> {
path.toFile().listFiles()?.flatMap { fromPath(it.toPath()) } ?: emptyList()
else -> listOf(KubernetesResourceSource(path.toFile()))
}

else -> {
listOf(KubernetesResourceSource(path.toFile()))
}
}

fun fromResources(resources: List<String>): List<KubernetesResourceSource> =
Expand Down
Loading