refactor checkLocalFile

merge-requests/2/head
az 2 years ago
parent 66dc4ee8bc
commit acd42c63c6

@ -6,6 +6,19 @@ import java.io.File
import java.util.*
/**
* Returns true if the given file exists in the LOCAL file system.
*/
fun checkLocalFile(fileName: String): Boolean {
if (fileName.isEmpty()) {
return false
} else if ((!File(fileName).exists())) {
return false
}
return true
}
/**
* Returns true if the given file exists.
*/

@ -1,15 +1,14 @@
package org.domaindrivenarchitecture.provs.server.infrastructure
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.checkLocalFile
import org.domaindrivenarchitecture.provs.server.domain.k3s.ApplicationFileName
import org.domaindrivenarchitecture.provs.server.domain.k3s.ApplicationFileRepository
class DefaultApplicationFileRepository : ApplicationFileRepository {
override fun assertExists(applicationFileName: ApplicationFileName?) {
if (applicationFileName != null) {
if (!genericFileExistenceCheck(applicationFileName.fullqualified())) {
throw RuntimeException("Application file ${applicationFileName.fileName} not found. Please check if path is correct.")
}
if (applicationFileName != null && !checkLocalFile(applicationFileName.fullqualified())) {
throw RuntimeException("Application file ${applicationFileName.fileName} not found. Please check if path is correct.")
}
}
}

@ -1,12 +0,0 @@
package org.domaindrivenarchitecture.provs.server.infrastructure
import java.io.File
fun genericFileExistenceCheck(fileName: String): Boolean {
if (fileName.isEmpty()) {
return false
} else if ((!File(fileName).exists())) {
return false
}
return true
}

24
°

@ -1,24 +0,0 @@
#!/bin/bash
set -e
set -o noglob
function usage() {
echo "Requires argument cluster_name and domain_name in server fqdn {cluster_name} {domain_name}"
}
function main() {
local cluster_name="${1}"; shift
local domain_name="${1:-meissa-gmbh.de}"; shift
/usr/local/bin/k3s-create-context.sh ${cluster_name}
kubectl config use-context ${cluster_name}
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${cluster_name}.${domain_name} -L 8002:localhost:8002 -L 6443:192.168.5.1:6443
}
if [ $# -gt 0 ]
then
main $1
else
usage
exit -1
fi
Loading…
Cancel
Save