Skip to content

Commit 052560a

Browse files
authored
*: allow relative paths for helm charts in watches.yaml file (#2287)
1 parent e598f60 commit 052560a

File tree

5 files changed

+7
-28
lines changed

5 files changed

+7
-28
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### Added
44
- Support for vars in top level ansible watches. ([#2147](https://github.com/operator-framework/operator-sdk/pull/2147))
55
- Support for `"ansible.operator-sdk/verbosity"` annotation on Custom Resources watched by Ansible based operators to override verbosity on an individual resource. ([#2102](https://github.com/operator-framework/operator-sdk/pull/2102))
6+
- Support for relative helm chart paths in the Helm operator's watches.yaml file. ([#2287](https://github.com/operator-framework/operator-sdk/pull/2287))
67

78
### Changed
89
- Upgrade minimal Ansible version in the init projects from `2.4` to `2.6`. ([#2107](https://github.com/operator-framework/operator-sdk/pull/2107))

doc/helm/dev/developer_guide.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ mandatory fields:
228228
**chart**: This is the path to the Helm chart that you have added to the
229229
container. For example, if your Helm charts directory is at
230230
`/opt/helm/helm-charts/` and your Helm chart is named `busybox`, this value
231-
will be `/opt/helm/helm-charts/busybox`.
231+
will be `/opt/helm/helm-charts/busybox`. If the path is relative, it is
232+
relative to the current working directory.
232233

233234
Example specifying a Helm chart watch:
234235

@@ -267,18 +268,6 @@ when we were testing our Helm chart locally. This section assumes the developer
267268
has read the [Helm Operator user guide][helm_operator_user_guide] and has the
268269
proper dependencies installed.
269270

270-
Since `up local` reads from `./watches.yaml`, there are a couple options
271-
available to the developer. If `chart` is left alone (by default
272-
`/opt/helm/helm-charts/<name>`) the Helm chart must exist at that location in
273-
the filesystem. It is recommended that the developer create a symlink at this
274-
location, pointed to the Helm chart in the project directory, so that changes
275-
to the Helm chart are reflected where necessary.
276-
277-
```sh
278-
sudo mkdir -p /opt/helm/helm-charts
279-
sudo ln -s $PWD/helm-charts/<name> /opt/helm/helm-charts/<name>
280-
```
281-
282271
Create a Custom Resource Definition (CRD) for resource Foo. `operator-sdk` autogenerates this file
283272
inside of the `deploy` folder:
284273

doc/helm/user-guide.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ in `watches.yaml` and executes Helm releases using the specified chart:
8888
- version: v1alpha1
8989
group: example.com
9090
kind: Nginx
91-
chart: /opt/helm/helm-charts/nginx
91+
chart: helm-charts/nginx
9292
```
9393
9494
### Reviewing the Nginx Helm Chart
@@ -210,18 +210,6 @@ nginx-operator 1 1 1 1 1m
210210

211211
This method is preferred during the development cycle to speed up deployment and testing.
212212

213-
It is important that the `chart` path referenced in `watches.yaml` exists
214-
on your machine. By default, the `watches.yaml` file is scaffolded to work with
215-
an operator image built with `operator-sdk build`. When developing and
216-
testing your operator with `operator-sdk up local`, the SDK will look in your
217-
local filesystem for this path. The SDK team recommends creating a symlink at
218-
this location to point to your helm chart's path:
219-
220-
```sh
221-
sudo mkdir -p /opt/helm/helm-charts
222-
sudo ln -s $PWD/helm-charts/nginx /opt/helm/helm-charts/nginx
223-
```
224-
225213
Run the operator locally with the default Kubernetes config file present at
226214
`$HOME/.kube/config`:
227215

internal/scaffold/helm/entrypoint.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,6 @@ if ! whoami &>/dev/null; then
4545
fi
4646
fi
4747
48-
exec ${OPERATOR} run helm --watches-file=/opt/helm/watches.yaml $@
48+
cd $HOME
49+
exec ${OPERATOR} run helm --watches-file=$HOME/watches.yaml $@
4950
`

internal/scaffold/helm/watches.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ const watchesYAMLTmpl = `---
4747
- version: {{.Resource.Version}}
4848
group: {{.Resource.FullGroup}}
4949
kind: {{.Resource.Kind}}
50-
chart: /opt/helm/{{.HelmChartsDir}}/{{.ChartName}}
50+
chart: {{.HelmChartsDir}}/{{.ChartName}}
5151
`

0 commit comments

Comments
 (0)