Skip to content

Commit 2a79884

Browse files
committed
Add pre-commit hooks
1 parent 8e42a32 commit 2a79884

6 files changed

Lines changed: 48 additions & 8 deletions

File tree

.pre-commit-config.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v6.0.0
4+
hooks:
5+
- id: check-added-large-files
6+
args: ['--maxkb=1024']
7+
- id: check-merge-conflict
8+
- id: check-vcs-permalinks
9+
- id: forbid-new-submodules
10+
- id: end-of-file-fixer
11+
- id: trailing-whitespace
12+
args: [--markdown-linebreak-ext=md]
13+
exclude: CHANGELOG.md
14+
- id: check-yaml
15+
args: [--allow-multiple-documents]
16+
- id: check-executables-have-shebangs
17+
- id: check-symlinks
18+
- id: destroyed-symlinks
19+
20+
# Cross platform
21+
- id: check-case-conflict
22+
- id: mixed-line-ending
23+
args: [--fix=lf]
24+
25+
# Security
26+
- id: detect-aws-credentials
27+
args: ['--allow-missing-credentials']
28+
- id: detect-private-key
29+
- repo: local
30+
hooks:
31+
- id: license-check
32+
name: format license headers using maven
33+
always_run: true
34+
language: script
35+
entry: /bin/sh -c "mvn validate license:format"
36+
pass_filenames: false
37+
- repo: https://github.com/crate-ci/typos
38+
rev: v1.35.8
39+
hooks:
40+
- id: typos

LICENSE_HEADER

100755100644
File mode changed.

docs/deployment/bases/namespaced/resources/shinyproxy-operator.rbac.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ kind: ServiceAccount
55
metadata:
66
name: shinyproxy-operator-sa
77
---
8-
# Role for the SerivceAcount of the operator
8+
# Role for the ServiceAccount of the operator
99
kind: Role
1010
apiVersion: rbac.authorization.k8s.io/v1
1111
metadata:

src/main/kotlin/eu/openanalytics/shinyproxyoperator/extensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fun JsonNode.getTextValueOrNull(key: String): String? {
6767

6868
fun Exception.prettyMessage(): String? {
6969
val name = javaClass.simpleName
70-
if (listOf("Exception", "RuntimeException", "IllegalArgumentException", "IllegalStateException", "IOExecption").contains(name)) {
70+
if (listOf("Exception", "RuntimeException", "IllegalArgumentException", "IllegalStateException", "IOException").contains(name)) {
7171
// don't include name of exception if it's too generic
7272
return message
7373
}

src/main/kotlin/eu/openanalytics/shinyproxyoperator/impl/docker/DockerOrchestrator.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class DockerOrchestrator(channel: Channel<ShinyProxyEvent>,
160160
if (instance.isLatestInstance) {
161161
throw IllegalStateException("Instance being removed is latest")
162162
}
163-
val status = state[instance.realmId] ?: error("No status found") // TOOD
163+
val status = state[instance.realmId] ?: error("No status found") // TODO
164164
val instances = ArrayList(status.instances)
165165
instances.remove(instance)
166166
state[instance.realmId] = status.copy(instances = instances)
@@ -248,7 +248,7 @@ class DockerOrchestrator(channel: Channel<ShinyProxyEvent>,
248248
copyTemplates(shinyProxy, dir)
249249
val mountCaBundle = copyCaBundle(shinyProxy, inputDir, dir)
250250
fileManager.createDirectories(dir.resolve("logs"))
251-
val additioanlConfigFiles = copyAdditionalConfigFiles(shinyProxy, dir)
251+
val additionalConfigFiles = copyAdditionalConfigFiles(shinyProxy, dir)
252252
val envVars = arrayListOf("PROXY_VERSION=${version}", "PROXY_REALM_ID=${shinyProxy.realmId}", "SPRING_CONFIG_IMPORT_0=/opt/shinyproxy/generated.yml", "USE_SYSTEM_CA_CERTS=true")
253253

254254
val binds = mutableListOf(HostConfig.Bind.builder()
@@ -288,7 +288,7 @@ class DockerOrchestrator(channel: Channel<ShinyProxyEvent>,
288288
.build())
289289
}
290290

291-
for ((idx, file) in additioanlConfigFiles.withIndex()) {
291+
for ((idx, file) in additionalConfigFiles.withIndex()) {
292292
val destination = "/opt/shinyproxy/${file}"
293293
binds.add(HostConfig.Bind.builder()
294294
.from(dir.resolve(file).toString())

src/main/kotlin/eu/openanalytics/shinyproxyoperator/impl/kubernetes/components/PodTemplateSpecFactory.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,14 @@ class PodTemplateSpecFactory(config: Config) {
196196
val resourceBuilder = ResourceRequirementsBuilder()
197197
if (shinyProxy.memoryRequest != null) {
198198
try {
199-
resourceBuilder.addToRequests("memory", parseMemorQuantity(shinyProxy.memoryRequest!!))
199+
resourceBuilder.addToRequests("memory", parseMemoryQuantity(shinyProxy.memoryRequest!!))
200200
} catch (e: Exception) {
201201
throw RuntimeException("Invalid memoryRequest: " + e.prettyMessage(), e)
202202
}
203203
}
204204
if (shinyProxy.memoryLimit != null) {
205205
try {
206-
resourceBuilder.addToLimits("memory", parseMemorQuantity(shinyProxy.memoryLimit!!))
206+
resourceBuilder.addToLimits("memory", parseMemoryQuantity(shinyProxy.memoryLimit!!))
207207
} catch (e: Exception) {
208208
throw RuntimeException("Invalid memoryLimit: " + e.prettyMessage(), e)
209209
}
@@ -240,7 +240,7 @@ class PodTemplateSpecFactory(config: Config) {
240240
return quantity
241241
}
242242

243-
private fun parseMemorQuantity(value: String): Quantity {
243+
private fun parseMemoryQuantity(value: String): Quantity {
244244
var converted = value
245245
// convert lower case suffixes automatically to a value accepted by k8s
246246
for (suffix in listOf("p", "t", "g", "m", "k")) {

0 commit comments

Comments
 (0)