podman correction

This commit is contained in:
Matthieu Lamalle 2023-04-18 16:09:00 +02:00
parent 21c7fb0e61
commit 1d35892e87
1 changed files with 3 additions and 7 deletions

View File

@ -1,28 +1,26 @@
void buildCadolesPodPackage(String imageName, String imageTag, Map options = [:]) { String buildCadolesPodPackage(String imageName, String imageTag, Map options = [:]) {
String destDir = options.get('destDir', env.WORKSPACE + '/dist') String destDir = options.get('destDir', env.WORKSPACE + '/dist')
Map nfpmOptions = options.get('nfpmOptions', [:]) Map nfpmOptions = options.get('nfpmOptions', [:])
nfpmOptions['target'] = destDir nfpmOptions['target'] = destDir
Map env = options.get('env', [:]) Map env = options.get('env', [:])
env['IMAGE_NAME'] = imageName env['IMAGE_NAME'] = imageName
env['IMAGE_TAG'] = imageTag env['IMAGE_TAG'] = imageTag
withPodmanPackagingTempDir { return withPodmanPackagingTempDir {
gomplate('post-install.sh.gotmpl', 'post-install.sh', env) gomplate('post-install.sh.gotmpl', 'post-install.sh', env)
gomplate('pod.service.gotmpl', 'pod.service', env) gomplate('pod.service.gotmpl', 'pod.service', env)
gomplate('pod.conf.gotmpl', 'pod.conf', env) gomplate('pod.conf.gotmpl', 'pod.conf', env)
gomplate('nfpm.yaml.gotmpl', 'nfpm.yaml', env) gomplate('nfpm.yaml.gotmpl', 'nfpm.yaml', env)
nfpm(nfpmOptions) nfpm(nfpmOptions)
} }
} }
void withPodmanPackagingTempDir(Closure fn) { void withPodmanPackagingTempDir(Closure fn) {
File tempDir = File.createTempDir() File tempDir = File.createTempDir()
tempDir.deleteOnExit()
tempDir.deleteOnExit()
tempDir.mkdirs() tempDir.mkdirs()
dir(tempDir.getAbsolutePath()) { dir(tempDir.getAbsolutePath()) {
@ -32,13 +30,11 @@ void withPodmanPackagingTempDir(Closure fn) {
'com/cadoles/podman/pod.service.gotmpl', 'com/cadoles/podman/pod.service.gotmpl',
'com/cadoles/podman/post-install.sh.gotmpl', 'com/cadoles/podman/post-install.sh.gotmpl',
] ]
for (res in resources) { for (res in resources) {
String fileContent = libraryResource res String fileContent = libraryResource res
String fileName = res.substring(res.lastIndexOf('/') + 1) String fileName = res.substring(res.lastIndexOf('/') + 1)
writeFile file:fileName, text:fileContent writeFile file:fileName, text:fileContent
} }
fn() fn()
} }
} }