Skip to content

Commit 3ad8905

Browse files
mdrollschnatterer
andauthored
Replaced the dependency for the kubectl call. / The functionality can be tested inside the GOP. (#46)
* add replacement for kubectl configmap creation * Release 0.7.0 --------- Co-authored-by: Johannes Schnatterer <[email protected]>
1 parent 611feca commit 3ad8905

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.7.0](https://github.com/cloudogu/gitops-build-lib/releases/tag/0.7.0) - 2024-10-14
11+
1012
### Added
1113
- Add additional docker runs args support
1214
- Add welcome message and print configs at application start

src/com/cloudogu/gitopsbuildlib/deployment/Deployment.groovy

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,22 @@ abstract class Deployment {
5454
}
5555
}
5656

57-
String createConfigMap(String key, String filePath, String name, String namespace) {
58-
String configMap = ""
59-
withDockerImage(gitopsConfig.buildImages.kubectl) {
60-
String kubeScript = "kubectl create configmap ${name} " +
61-
"--from-file=${key}=${filePath} " +
62-
"--dry-run=client -o yaml -n ${namespace}"
63-
64-
configMap = script.sh returnStdout: true, script: kubeScript
65-
}
66-
return configMap
57+
String createConfigMap(String key, String filePath, String metadataName, String namespace) {
58+
def fileContent = script.readFile(file: filePath)
59+
60+
def configMap = [
61+
'apiVersion': 'v1',
62+
'kind': 'ConfigMap',
63+
'metadata': [
64+
'name': metadataName,
65+
'namespace' : namespace
66+
],
67+
'data': [
68+
(key): fileContent
69+
]
70+
]
71+
72+
return script.writeYaml(data: configMap, returnText: true)
6773
}
6874

6975
void withDockerImage(def imageConfig, Closure body) {

test/com/cloudogu/gitopsbuildlib/deployment/DeploymentTest.groovy

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,7 @@ class DeploymentTest {
9191
void 'create configmaps from files'() {
9292

9393
deploymentUnderTest.createFileConfigmaps('staging')
94-
95-
assertThat(scriptMock.dockerMock.actualRegistryArgs[0]).isEqualTo('https://http://my-private-registry.com/repo')
96-
assertThat(scriptMock.dockerMock.actualRegistryArgs[1]).isEqualTo('credentials')
97-
98-
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]')
99-
94+
assertThat(scriptMock.actualWriteYamlArgs[0]).contains('apiVersion', 'kind', 'metadata', 'ConfigMap')
10095
assertThat(scriptMock.actualWriteFileArgs[0]).contains('[file:staging/app/generatedResources/index.yaml')
10196
}
10297

0 commit comments

Comments
 (0)