Skip to content

Commit 1b69e1e

Browse files
ThomasMichael1811Thomas Michael
andauthored
allow own values for ArgoCD Operator (#334)
Co-authored-by: Thomas Michael <[email protected]>
1 parent 2ab5cfe commit 1b69e1e

File tree

4 files changed

+34
-11
lines changed

4 files changed

+34
-11
lines changed

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -410,17 +410,18 @@ That is, if you pass a param via CLI, for example, it will overwrite the corresp
410410

411411
###### ArgoCD
412412

413-
| CLI | Config | Default | Type | Description |
414-
|-----|--------|---------|------|-------------|
415-
| `--argocd` | `features.argocd.active` | `false` | Boolean | Installs ArgoCD as GitOps CD tool |
416-
| `--argocd-operator` | `features.argocd.operator` | `false` | Boolean | Install ArgoCD operator |
417-
| `--argocd-url` | `features.argocd.url` | `''` | String | The url of your external argocd |
418-
| `--argocd-email-from` | `features.argocd.emailFrom` | `'[email protected]'` | String | Email from address for ArgoCD notifications |
419-
| `--argocd-email-to-user` | `features.argocd.emailToUser` | `'[email protected]'` | String | Email to address for user notifications |
420-
| `--argocd-email-to-admin` | `features.argocd.emailToAdmin` | `'[email protected]'` | String | Email to address for admin notifications |
421-
| `--argocd-resource-inclusions-cluster` | `features.argocd.resourceInclusionsCluster` | `''` | String | ArgoCD resource inclusions for cluster |
422-
| `--argocd-namespace` | `features.argocd.namespace` | `'argocd'` | String | ArgoCD namespace |
423-
| - | `features.argocd.env` | - | List | Environment variables for ArgoCD |
413+
| CLI | Config | Default | Type | Description |
414+
|-----|---------------------------------------------|---------|---------|---------------------------------------------|
415+
| `--argocd` | `features.argocd.active` | `false` | Boolean | Installs ArgoCD as GitOps CD tool |
416+
| `--argocd-operator` | `features.argocd.operator` | `false` | Boolean | Install ArgoCD operator |
417+
| `--argocd-url` | `features.argocd.url` | `''` | String | The url of your external argocd |
418+
| `--argocd-email-from` | `features.argocd.emailFrom` | `'[email protected]'` | String | Email from address for ArgoCD notifications |
419+
| `--argocd-email-to-user` | `features.argocd.emailToUser` | `'[email protected]'` | String | Email to address for user notifications |
420+
| `--argocd-email-to-admin` | `features.argocd.emailToAdmin` | `'[email protected]'` | String | Email to address for admin notifications |
421+
| `--argocd-resource-inclusions-cluster` | `features.argocd.resourceInclusionsCluster` | `''` | String | ArgoCD resource inclusions for cluster |
422+
| `--argocd-namespace` | `features.argocd.namespace` | `'argocd'` | String | ArgoCD namespace |
423+
| - | `features.argocd.env` | - | List | Environment variables for ArgoCD |
424+
| - | `features.argocd.values` | - | Map | To override ArgoCD Operator file |
424425

425426
###### Mail
426427

docs/configuration.schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@
270270
"url" : {
271271
"type" : [ "string", "null" ],
272272
"description" : "The URL where argocd is accessible. It has to be the full URL with http:// or https://"
273+
},
274+
"values" : {
275+
"$ref" : "#/$defs/Map(String,Object)-nullable",
276+
"description" : "Helm values of the chart, allows overriding defaults and setting values that are not exposed as explicit configuration"
273277
}
274278
},
275279
"additionalProperties" : false,

src/main/groovy/com/cloudogu/gitops/config/Config.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,9 @@ class Config {
489489
@Option(names = ['--argocd-namespace'], description = ARGOCD_CUSTOM_NAMESPACE_DESCRIPTION)
490490
@JsonPropertyDescription(ARGOCD_CUSTOM_NAMESPACE_DESCRIPTION)
491491
String namespace = 'argocd'
492+
493+
@JsonPropertyDescription(HELM_CONFIG_VALUES_DESCRIPTION)
494+
Map<String, Object> values = [:]
492495
}
493496

494497
static class MailSchema {

src/main/groovy/com/cloudogu/gitops/features/argocd/ArgoCD.groovy

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ import com.cloudogu.gitops.kubernetes.rbac.Role
1010
import com.cloudogu.gitops.utils.FileSystemUtils
1111
import com.cloudogu.gitops.utils.HelmClient
1212
import com.cloudogu.gitops.utils.K8sClient
13+
import com.cloudogu.gitops.utils.MapUtils
1314
import groovy.util.logging.Slf4j
1415
import io.micronaut.core.annotation.Order
1516
import jakarta.inject.Singleton
17+
1618
import org.springframework.security.crypto.bcrypt.BCrypt
1719

1820
import java.nio.file.Path
@@ -226,6 +228,19 @@ class ArgoCD extends Feature {
226228
private void deployWithOperator() {
227229
// Apply argocd yaml from operator folder
228230
String argocdConfigPath = Path.of(argocdRepoInitializationAction.repo.getAbsoluteLocalRepoTmpDir(), OPERATOR_CONFIG_PATH)
231+
if (this.config.features.argocd?.values) {
232+
log.debug("extend Argocd.yaml with ${this.config.features.argocd.values}")
233+
def argocdYaml = fileSystemUtils.readYaml(
234+
Path.of(argocdRepoInitializationAction.repo.getAbsoluteLocalRepoTmpDir(), OPERATOR_CONFIG_PATH))
235+
236+
def result = MapUtils.deepMerge(this.config.features.argocd.values, argocdYaml)
237+
fileSystemUtils.writeYaml(result, new File (argocdConfigPath))
238+
log.debug("Argocd.yaml for operator contains ${result}")
239+
// reload file
240+
argocdConfigPath = Path.of(argocdRepoInitializationAction.repo.getAbsoluteLocalRepoTmpDir(), OPERATOR_CONFIG_PATH)
241+
242+
}
243+
229244
k8sClient.applyYaml(argocdConfigPath)
230245

231246
// ArgoCD is not installed until the ArgoCD-Operator did his job.

0 commit comments

Comments
 (0)