Skip to content

Commit f4e4748

Browse files
authored
add property configFiles to API (#19)
1 parent 1569df0 commit f4e4748

File tree

6 files changed

+47
-10
lines changed

6 files changed

+47
-10
lines changed

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,28 @@ spec:
2222
replicas: 2
2323
config:
2424
input:
25-
generate:
26-
mapping: root = "woof"
27-
interval: 5s
28-
count: 0
25+
broker:
26+
inputs:
27+
- file:
28+
paths: ["./config/meow.txt"]
29+
- generate:
30+
mapping: root = "woof"
31+
interval: 10s
32+
count: 0
2933

3034
pipeline:
3135
processors:
3236
- mapping: root = content().uppercase()
3337

3438
output:
3539
stdout: {}
40+
41+
configFiles:
42+
meow.txt: |
43+
meow
3644
```
3745
38-
Once the resource is deployed, you can monitor the state of the resoure:
46+
Once the resource is deployed, you can monitor the state of the resource:
3947
4048
```bash
4149
kubectl get pipelines

api/v1alpha1/pipeline_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ type PipelineSpec struct {
2525
// Image defines the image and tag to use for the Benthos deployment.
2626
// +optional
2727
Image string `json:"image,omitempty"`
28+
29+
// ConfigFiles Additional configuration, as Key/Value pairs, that will be mounted as files with the /config
30+
// directory on the pod. The key should be the file name and the value should be its content.
31+
ConfigFiles map[string]string `json:"configFiles,omitempty"`
2832
}
2933

3034
// PipelineStatus defines the observed state of Pipeline

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/captain.benthos.dev_pipelines.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ spec:
6363
config:
6464
description: Config defines the Benthos configuration as a string.
6565
x-kubernetes-preserve-unknown-fields: true
66+
configFiles:
67+
additionalProperties:
68+
type: string
69+
description: |-
70+
ConfigFiles Additional configuration, as Key/Value pairs, that will be mounted as files with the /config
71+
directory on the pod. The key should be the file name and the value should be it's content.
72+
type: object
6673
image:
6774
description: Image defines the image and tag to use for the Benthos
6875
deployment.

config/samples/captain_v1alpha1_pipeline.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,22 @@ spec:
1212
replicas: 1
1313
config:
1414
input:
15-
generate:
16-
mapping: root = "woof"
17-
interval: 5s
18-
count: 0
15+
broker:
16+
inputs:
17+
- file:
18+
paths: ["./config/meow.txt"]
19+
- generate:
20+
mapping: root = "woof"
21+
interval: 10s
22+
count: 0
1923

2024
pipeline:
2125
processors:
2226
- mapping: root = content().uppercase()
2327

2428
output:
2529
stdout: {}
30+
31+
configFiles:
32+
meow.txt: |
33+
meow

internal/controller/pipeline_controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ func (r *PipelineReconciler) createOrPatchConfigMap(scope *PipelineScope) (ctrl.
257257
sc.Data = map[string]string{
258258
"benthos.yaml": string(scope.Pipeline.Spec.Config.Raw),
259259
}
260+
for file, config := range scope.Pipeline.Spec.ConfigFiles {
261+
sc.Data[file] = config
262+
}
260263
err := controllerutil.SetControllerReference(scope.Pipeline, sc, r.Scheme)
261264
if err != nil {
262265
return errors.Wrapf(err, "Failed to set controller reference on configmap %s", name)
@@ -267,7 +270,7 @@ func (r *PipelineReconciler) createOrPatchConfigMap(scope *PipelineScope) (ctrl.
267270
return reconcile.Result{}, errors.Wrapf(err, "Failed to reconcile config map %s", name)
268271
}
269272

270-
scope.Log.Info("Succesfully reconciled config map", "name", name, "operation", op)
273+
scope.Log.Info("Successfully reconciled config map", "name", name, "operation", op)
271274

272275
// rollout the deployment if the configmap changes
273276
if op == controllerutil.OperationResultUpdated {

0 commit comments

Comments
 (0)