Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit 9d919f6

Browse files
🔧 Improve plugin configuration by being more consistent about plugin name vs plugin field (#1211)
1 parent 07f8597 commit 9d919f6

29 files changed

Lines changed: 324 additions & 208 deletions

File tree

‎cmd/rig-ops/cmd/migrate/plugins.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ func (c *Cmd) getPlugins(ctx context.Context, migration *Migration) error {
3636
for _, plugin := range resp.Msg.Plugins {
3737
switch v := plugin.GetPlugin().(type) {
3838
case *capabilities.GetPluginsResponse_Plugin_Builtin:
39-
if v.Builtin.GetName() == p.Name {
40-
plugins = append(plugins, p.Name)
39+
if v.Builtin.GetName() == p.GetPlugin() {
40+
plugins = append(plugins, p.GetPlugin())
4141
}
4242
case *capabilities.GetPluginsResponse_Plugin_ThirdParty:
43-
if v.ThirdParty.Name == p.Name {
44-
plugins = append(plugins, p.Name)
43+
if v.ThirdParty.Name == p.GetPlugin() {
44+
plugins = append(plugins, p.GetPlugin())
4545
}
4646
}
4747
}

‎cmd/rig-ops/cmd/plugins/list.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ func (c *Cmd) listSteps(ctx context.Context, _ *cobra.Command, _ []string) error
2929
}
3030
for _, p := range s.Plugins {
3131
plugin := pluginInfo{
32-
Name: p.Name,
32+
Name: p.GetPlugin(),
3333
}
3434
if showConfig {
3535
plugin.Config = map[string]any{}
3636
if err := yaml.Unmarshal([]byte(p.Config), &plugin.Config); err != nil {
37-
return fmt.Errorf("plugin '%s' had malformed config: %q", p.Name, err)
37+
return fmt.Errorf("plugin '%s' had malformed config: %q", p.GetPlugin(), err)
3838
}
3939
}
4040
step.Plugins = append(step.Plugins, plugin)
@@ -112,7 +112,7 @@ func (c *Cmd) get(ctx context.Context, _ *cobra.Command, args []string) error {
112112
for idx, s := range cfg.Pipeline.Steps {
113113
var plugins []string
114114
for _, p := range s.Plugins {
115-
plugins = append(plugins, p.Name)
115+
plugins = append(plugins, p.GetPlugin())
116116
}
117117
choices = append(choices, []string{strconv.Itoa(idx), strings.Join(plugins, ", ")})
118118
}
@@ -141,7 +141,7 @@ func (c *Cmd) get(ctx context.Context, _ *cobra.Command, args []string) error {
141141
}
142142
for _, p := range s.Plugins {
143143
plugin := pluginInfo{
144-
Name: p.Name,
144+
Name: p.GetPlugin(),
145145
}
146146
if err := yaml.Unmarshal([]byte(p.Config), &plugin.Config); err != nil {
147147
return fmt.Errorf("plugin had malformed config: %q", err)

‎deploy/charts/rig-operator/values.yaml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ config:
2727
steps:
2828
[]
2929
# - plugins:
30-
# - name: rigdev.env_mapping
31-
# - name: rigdev.object_template
30+
# - plugin: rigdev.env_mapping
31+
# - plugin: rigdev.object_template
3232
# config: |
3333
# group: apps
3434
# kind: Deployment
@@ -40,27 +40,27 @@ config:
4040
# - name: {{ .capsule.metadata.name }}
4141
# image: alpine
4242
# command: ['sh', '-c', 'echo "Hello from {{ .capsule.metadata.name }}!"']
43-
# - name: rigdev.sidecar
43+
# - plugin: rigdev.sidecar
4444
# config: |
4545
# container:
4646
# name: foobar
4747
# image: alpine
4848
# command: ['sh', '-c', 'sleep 1000']
49-
# - name: rigdev.init_container
49+
# - plugin: rigdev.init_container
5050
# config: |
5151
# container:
5252
# name: startup
5353
# image: alpine
5454
# command: ['sh', '-c', 'echo "Startup!"']
55-
# - name: rigdev.annotations
55+
# - plugin: rigdev.annotations
5656
# config: |
5757
# group: apps
5858
# kind: Deployment
5959
# annotations:
6060
# some-annotation: some-value
6161
# templated-annotation: value-{{ .capsule.spec.image }}
6262
# deleted-annotation: ""
63-
# - name: rigdev.datadog
63+
# - plugin: rigdev.datadog
6464
# config: |
6565
# libraryTag:
6666
# java: latest

‎docs/docs/api/config/v1alpha1.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,8 @@ _Appears in:_
649649
| Field | Description |
650650
| --- | --- |
651651
| `tag` _string_ | Optional tag which is readable by plugin when executed |
652-
| `name` _string_ | Name of the plugin to run. |
652+
| `name` _string_ | Name of the plugin to run. Deprecated, use Plugin. |
653+
| `plugin` _string_ | Name of the plugin to run. |
653654
| `config` _string_ | Config is a string defining the plugin-specific configuration of the plugin. |
654655

655656

‎docs/docs/operator-manual/cli.mdx‎

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ Available Commands:
5252
**check**
5353
```
5454
% rig-ops plugins check
55-
Namespace Capsule StepIndex
56-
myproject mycapsule 0
57-
myproject mycapsule2 0
58-
myproject-staging mycapsule 0
59-
myproject-staging mycapsule 1
55+
Namespace Capsule StepIndex
56+
myproject mycapsule 0
57+
myproject mycapsule2 0
58+
myproject-staging mycapsule 0
59+
myproject-staging mycapsule 1
6060
```
6161

6262
**dry-run**
@@ -73,28 +73,28 @@ plugins:
7373
- config:
7474
annotations:
7575
key: value
76-
name: rigdev.annotations
76+
plugin: rigdev.annotations
7777
```
7878

7979
**list**
8080
```
81-
% rig-ops plugins list
82-
Type Name
83-
Builtin rigdev.annotations
84-
Builtin rigdev.cron_jobs
85-
Builtin rigdev.datadog
86-
Builtin rigdev.deployment
87-
Builtin rigdev.env_mapping
88-
Builtin rigdev.google_cloud_sql_auth_proxy
89-
Builtin rigdev.ingress_routes
90-
Builtin rigdev.init_container
91-
Builtin rigdev.object_create
92-
Builtin rigdev.object_template
93-
Builtin rigdev.placement
94-
Builtin rigdev.service_account
95-
Builtin rigdev.service_monitor
96-
Builtin rigdev.sidecar
97-
Builtin rigdev.vpa
81+
% rig-ops plugins list
82+
Type Name
83+
Builtin rigdev.annotations
84+
Builtin rigdev.cron_jobs
85+
Builtin rigdev.datadog
86+
Builtin rigdev.deployment
87+
Builtin rigdev.env_mapping
88+
Builtin rigdev.google_cloud_sql_auth_proxy
89+
Builtin rigdev.ingress_routes
90+
Builtin rigdev.init_container
91+
Builtin rigdev.object_create
92+
Builtin rigdev.object_template
93+
Builtin rigdev.placement
94+
Builtin rigdev.service_account
95+
Builtin rigdev.service_monitor
96+
Builtin rigdev.sidecar
97+
Builtin rigdev.vpa
9898
```
9999

100100
### Migrate

‎docs/docs/operator-manual/plugins/builtin/annotations.mdx‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,34 @@ The annotations plugin can insert annotations and labels into a given object.
44
If any of the given annotations or labels are already present in the object, they will be overwritten.
55

66
The config can be templated with standard Go templating and has
7+
78
```
89
.capsule
910
```
11+
1012
as its templating context.
1113

1214
## Example
15+
1316
Config:
17+
1418
```yaml title="Helm values - Operator"
1519
config:
1620
pipeline:
1721
steps:
1822
- plugins:
19-
- name: rigdev.annotations
20-
config: |
21-
annotations:
22-
key1: value1
23-
labels:
24-
key2: value2
25-
group: apps
26-
kind: Deployment
23+
- plugin: rigdev.annotations
24+
config: |
25+
annotations:
26+
key1: value1
27+
labels:
28+
key2: value2
29+
group: apps
30+
kind: Deployment
2731
```
2832
2933
If the name of the capsule in the request context is `my-capsule` with corresponding `Deployment`
34+
3035
```
3136
apiVersion: apps/v1
3237
kind: Deployment
@@ -38,7 +43,9 @@ metadata:
3843
label: value
3944
....
4045
```
46+
4147
The resulting config of the `Deployment` is
48+
4249
```
4350
apiVersion: apps/v1
4451
kind: Deployment
@@ -51,6 +58,7 @@ metadata:
5158
key2: value2
5259
....
5360
```
61+
5462
## Config
5563
5664

‎docs/docs/operator-manual/plugins/builtin/datadog.mdx‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,34 @@
33
The `rigdev.datadog` plugin adds Datadog specific tags to the Deployment and Pods of the capsule as requested [here](https://docs.datadoghq.com/tracing/trace_collection/library_injection_local/?tab=kubernetes). It can enable/disable the execution of the [Datadog Admission Controller](https://docs.datadoghq.com/containers/cluster_agent/admission_controller/?tab=operator) on the pods and sets the necessary library and unified service tags.
44

55
The config can be templated with standard Go templating and has
6+
67
```
78
.capsule
89
```
10+
911
as its templating context.
1012

1113
## Example
14+
1215
Config:
16+
1317
```yaml title="Helm values - Operator"
1418
config:
1519
pipeline:
1620
steps:
1721
- plugins:
18-
- name: rigdev.datadog
19-
config: |
20-
libraryTag:
21-
java: v1.31.0
22-
unifiedServiceTags:
23-
env: my-env
24-
service: my-service
25-
versin: my-version
22+
- plugin: rigdev.datadog
23+
config: |
24+
libraryTag:
25+
java: v1.31.0
26+
unifiedServiceTags:
27+
env: my-env
28+
service: my-service
29+
versin: my-version
2630
```
2731
2832
The resulting `Deployment` resource of the Capsule
33+
2934
```
3035
kind: Deployment
3136
metadata:
@@ -45,6 +50,7 @@ spec:
4550
admission.datadoghq.com/java-lib.version: v1.31.0,
4651
...
4752
```
53+
4854
## Config
4955
5056

‎docs/docs/operator-manual/plugins/builtin/google_cloud_sql_auth_proxy.mdx‎

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,43 @@ The `rigdev.google_cloud_sql_auth_proxy` plugins injects a Google Cloud SQL auth
44
It will append a container named `google-cloud-sql-proxy` running the `gcr.io/cloud-sql-connectors/cloud-sql-proxy` image to your deployment and set its arguments, environment variables and config files according the the configuration of this plugin.
55

66
The config can be templated with standard Go templating and has
7+
78
```
89
.capsule
910
```
11+
1012
as its templating context.
1113

1214
## Example
15+
1316
Config:
17+
1418
```yaml title="Helm value - Operator"
1519
config:
1620
pipeline:
1721
steps:
1822
- plugins:
19-
- name: rigdev.google_cloud_sql_auth_proxy
20-
config: |
21-
tag: 2.9
22-
args
23-
- arg1
24-
- arg2
25-
envFromSource:
26-
- kind: ConfigMap
27-
name: my-configmap
28-
envVars:
29-
name: MY_ENV_VAR
30-
value: some-value
31-
resources:
32-
cpu: 0.1
33-
memory: 128M
34-
instanceConnectionNames:
35-
- instance-name
23+
- plugin: rigdev.google_cloud_sql_auth_proxy
24+
config: |
25+
tag: 2.9
26+
args
27+
- arg1
28+
- arg2
29+
envFromSource:
30+
- kind: ConfigMap
31+
name: my-configmap
32+
envVars:
33+
name: MY_ENV_VAR
34+
value: some-value
35+
resources:
36+
cpu: 0.1
37+
memory: 128M
38+
instanceConnectionNames:
39+
- instance-name
3640
```
41+
3742
Resulting Deployment
43+
3844
```
3945
kind: Deployment
4046
spec:
@@ -57,6 +63,7 @@ spec:
5763
runAsNonRoot: true
5864
restartPolicy: Always
5965
```
66+
6067
## Config
6168
6269

‎docs/docs/operator-manual/plugins/builtin/init_container.mdx‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,31 @@
33
The `rigdev.init_container` plugin adds an init container to the Capsule's deployment.
44

55
The config can be templated with standard Go templating and has
6+
67
```
78
.capsule
89
```
10+
911
as its templating context.
1012

1113
## Example
14+
1215
Config:
16+
1317
```yaml title="Helm values - Operator"
1418
config:
1519
pipeline:
1620
steps:
1721
- plugins:
18-
- name: rigdev.init_container
19-
config: |
20-
container:
21-
name: my-initcontainer
22-
image: my-container-image:v1.1
22+
- plugin: rigdev.init_container
23+
config: |
24+
container:
25+
name: my-initcontainer
26+
image: my-container-image:v1.1
2327
```
28+
2429
The resulting Deployment resource of the Capsule
30+
2531
```
2632
kind: Deployment
2733
...
@@ -33,6 +39,7 @@ spec:
3339
image: my-container-image:v1.1
3440
...
3541
```
42+
3643
## Config
3744

3845

0 commit comments

Comments
 (0)