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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.7.0](https://github.com/cloudogu/gitops-build-lib/releases/tag/0.7.0) - 2024-10-14

### Added
- Add additional docker runs args support
- Add welcome message and print configs at application start
Expand Down
26 changes: 16 additions & 10 deletions src/com/cloudogu/gitopsbuildlib/deployment/Deployment.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,22 @@ abstract class Deployment {
}
}

String createConfigMap(String key, String filePath, String name, String namespace) {
String configMap = ""
withDockerImage(gitopsConfig.buildImages.kubectl) {
String kubeScript = "kubectl create configmap ${name} " +
"--from-file=${key}=${filePath} " +
"--dry-run=client -o yaml -n ${namespace}"

configMap = script.sh returnStdout: true, script: kubeScript
}
return configMap
String createConfigMap(String key, String filePath, String metadataName, String namespace) {
def fileContent = script.readFile(file: filePath)

def configMap = [
'apiVersion': 'v1',
'kind': 'ConfigMap',
'metadata': [
'name': metadataName,
'namespace' : namespace
],
'data': [
(key): fileContent
]
]

return script.writeYaml(data: configMap, returnText: true)
}

void withDockerImage(def imageConfig, Closure body) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,7 @@ class DeploymentTest {
void 'create configmaps from files'() {

deploymentUnderTest.createFileConfigmaps('staging')

assertThat(scriptMock.dockerMock.actualRegistryArgs[0]).isEqualTo('https://http://my-private-registry.com/repo')
assertThat(scriptMock.dockerMock.actualRegistryArgs[1]).isEqualTo('credentials')

assertThat(scriptMock.actualShArgs[0]).isEqualTo('[returnStdout:true, script:kubectl create configmap index --from-file=index.html=workspace/k8s/../index.html --dry-run=client -o yaml -n fluxv1-staging]')

assertThat(scriptMock.actualWriteYamlArgs[0]).contains('apiVersion', 'kind', 'metadata', 'ConfigMap')
assertThat(scriptMock.actualWriteFileArgs[0]).contains('[file:staging/app/generatedResources/index.yaml')
}

Expand Down