Skip to content

Commit

Permalink
Support to specify a certain version for extra node modules instead o…
Browse files Browse the repository at this point in the history
…f latest every time (#318)

* chore(deps): update aquasecurity/trivy-action action to v0.16.1 (#311)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: GregorTallig <[email protected]>

* feat: allow to specify version within extra node module

Signed-off-by: GregorTallig <[email protected]>

* docs: adding example for providing a module version

Signed-off-by: GregorTallig <[email protected]>

* fix: modules starting with namespace

Signed-off-by: GregorTallig <[email protected]>

* docs: fix typo in chart README (#320)

Signed-off-by: Jan Pieper <[email protected]>

* fix: missed README.md.gotmpl

Signed-off-by: GregorTallig <[email protected]>

* fix: typo

Signed-off-by: GregorTallig <[email protected]>

---------

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: GregorTallig <[email protected]>
Signed-off-by: Jan Pieper <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jan Pieper <[email protected]>
  • Loading branch information
3 people authored Dec 23, 2024
1 parent c0bde29 commit 0ea91ef
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions charts/node-red/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# node-red ⚙
****# node-red ⚙

![Version: 0.33.1](https://img.shields.io/badge/Version-0.33.1-informational?style=for-the-badge) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=for-the-badge) ![AppVersion: 4.0.3](https://img.shields.io/badge/AppVersion-4.0.3-informational?style=for-the-badge)

Expand Down Expand Up @@ -131,7 +131,7 @@ The command removes all the Kubernetes components associated with the chart and
| sidecar.env.sleep_time_sidecar | string | `"5s"` | Set the sleep time for refresh script |
| sidecar.env.username | string | `""` | |
| sidecar.extraEnv | list | `[]` | Extra Environments for the sidecar |
| sidecar.extraNodeModules | list | `[]` | Extra Node-Modules that will be installed from the sidecar script |
| sidecar.extraNodeModules | list | `[]` | Extra Node-Modules that will be installed from the sidecar script (specifying a version like [email protected] is supported) |
| sidecar.image.pullPolicy | string | `"IfNotPresent"` | The image pull policy, default: `IfNotPresent` |
| sidecar.image.registry | string | `"quay.io"` | The image registry to pull the sidecar from |
| sidecar.image.repository | string | `"kiwigrid/k8s-sidecar"` | The image repository to pull from |
Expand Down Expand Up @@ -179,15 +179,15 @@ Default values are: `node-red-settings:1`.
The `k8s-sidecar` will then call the `node-red` api to reload the flows. This will be done via a script. To run this script successfully you need to provide the `username` and `password`
of your admin user. The admin user needs to have the right to use the `node-red` API.

The `k8s-sidecar` can also call the `node-red` api to install additional node modules (npm packages) before refreshing or importing the flow.json.
The `k8s-sidecar` can also call the `node-red` api to install additional node modules (npm packages) before refreshing or importing the flow.json. Specifying a version for a module is supported (s. example below).
You need to list your flows required 'NODE_MODULES' in the `sidecar.extraNodeModules`: e.g.

```yaml
sidecar:
extraNodeModules:
- node-red-contrib-xkeys_setunitid
- node-red-contrib-microsoft-teams-tasks
- node-red-contrib-json
- node-red-contrib-json@0.2.0
```
To install the node modules successfully, the node red pod needs access to the `npmrc.registry` to download the declaired modules/packages.

Expand Down
2 changes: 1 addition & 1 deletion charts/node-red/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Default values are: `node-red-settings:1`.
The `k8s-sidecar` will then call the `node-red` api to reload the flows. This will be done via a script. To run this script successfully you need to provide the `username` and `password`
of your admin user. The admin user needs to have the right to use the `node-red` API.

The `k8s-sidecar` can also call the `node-red` api to install additional node modules (npm packages) before refreshing or importing the flow.json.
The `k8s-sidecar` can also call the `node-red` api to install additional node modules (npm packages) before refreshing or importing the flow.json. Specifying a version for a module is supported (s. example below).
You need to list your flows required 'NODE_MODULES' in the `sidecar.extraNodeModules`: e.g.

```yaml
Expand Down
10 changes: 9 additions & 1 deletion charts/node-red/scripts/flow_refresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,15 @@ def main():

for module in EXTRA_NODE_MODULES:
if module not in modules_installed:
payload_node_module = '{"module": "' + module + '"}'
try:
module_name, version = module.rsplit('/', 1)[-1].split('@', 1) if '@' in module else (module, None)
except:
module_name, version = module, None
payload_node_module = ''
if version is not None:
payload_node_module = '{"module": "' + module_name + '", "version": "' + version + '"}'
else:
payload_node_module = '{"module": "' + module_name + '"}'
headers_node_module = {
"Content-type": "application/json",
}
Expand Down

0 comments on commit 0ea91ef

Please sign in to comment.