From 4606855d778b7ed68b60c5f245f57c93ae50c006 Mon Sep 17 00:00:00 2001 From: Laszlo Fogas Date: Tue, 8 Oct 2024 13:56:22 +0200 Subject: [PATCH] fix: undefined error when no registries are configured --- web/src/views/envConfig/imageWidget.jsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/web/src/views/envConfig/imageWidget.jsx b/web/src/views/envConfig/imageWidget.jsx index da9f40e0f..8df21438a 100644 --- a/web/src/views/envConfig/imageWidget.jsx +++ b/web/src/views/envConfig/imageWidget.jsx @@ -33,8 +33,7 @@ export default function ImageWidget(props) { } const setStrategy = (strategy) => { - let registry = {} - registry = registries.find(r => r.variable === "customRegistry") + let registry = registries.find(r => r.variable === "customRegistry") if (!registry) { registry = registries.find(r => r.variable === "containerizedRegistry") } @@ -55,7 +54,7 @@ export default function ImageWidget(props) { setImage({ ...image, "strategy": strategy, - "registry": registry.variable, + "registry": registry ? registry.variable : "", "repository": repository, "tag": "{{ .SHA }}", "context": ".", @@ -66,7 +65,7 @@ export default function ImageWidget(props) { setImage({ ...image, "strategy": strategy, - "registry": registry.variable, + "registry": registry ? registry.variable : "", "repository": repository, "tag": "{{ .SHA }}", "dockerfile": "" @@ -89,6 +88,9 @@ export default function ImageWidget(props) { }, [image]); const repositoryFromRegistry = (registry) => { + if (!registry) { + return "" + } const login = registry.login ?? "your-company" let repository = ""