From 005396e3ea855080d2f2601c4fa06e7c43b552dc Mon Sep 17 00:00:00 2001 From: Andrei Kvapil Date: Sun, 16 Jun 2024 07:30:35 +0200 Subject: [PATCH] Allow cluster domain to be unspicified Signed-off-by: Andrei Kvapil --- internal/builder/build.go | 6 +++++- internal/builder/options.go | 2 +- internal/builder/templates.go | 9 ++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/internal/builder/build.go b/internal/builder/build.go index ab5f016..a60c610 100644 --- a/internal/builder/build.go +++ b/internal/builder/build.go @@ -59,7 +59,11 @@ func Build(srcDir, tmpDir string, options Options) (*Result, error) { func generate(base string, options Options) error { if containsItemString(options.Components, options.NotificationController) { - options.EventsAddr = fmt.Sprintf("http://%s.%s.svc.%s./", options.NotificationController, options.Namespace, options.ClusterDomain) + if options.ClusterDomain == "" { + options.EventsAddr = fmt.Sprintf("http://%s.%s.svc/", options.NotificationController, options.Namespace) + } else { + options.EventsAddr = fmt.Sprintf("http://%s.%s.svc.%s./", options.NotificationController, options.Namespace, options.ClusterDomain) + } } if err := execTemplate(options, namespaceTmpl, path.Join(base, "namespace.yaml")); err != nil { diff --git a/internal/builder/options.go b/internal/builder/options.go index b56cb5e..e14fef1 100644 --- a/internal/builder/options.go +++ b/internal/builder/options.go @@ -43,7 +43,7 @@ func MakeDefaultOptions() Options { NetworkPolicy: true, LogLevel: "info", NotificationController: "notification-controller", - ClusterDomain: "cluster.local", + ClusterDomain: "", } } diff --git a/internal/builder/templates.go b/internal/builder/templates.go index e36609f..dc70585 100644 --- a/internal/builder/templates.go +++ b/internal/builder/templates.go @@ -16,7 +16,10 @@ var kustomizationTmpl = `--- {{- $watchAllNamespaces := .WatchAllNamespaces }} {{- $registry := .Registry }} {{- $logLevel := .LogLevel }} -{{- $clusterDomain := .ClusterDomain }} +{{- $clusterDomain := "" }} +{{- if .ClusterDomain }} +{{- $clusterDomain = .ClusterDomain }} +{{- end }} {{- $artifactStorage := .ArtifactStorage }} {{- $sync := .Sync }} {{- $namespace := .Namespace }} @@ -88,7 +91,11 @@ patches: value: --log-level={{$logLevel}} - op: replace path: /spec/template/spec/containers/0/args/6 + {{- if $clusterDomain }} value: --storage-adv-addr=source-controller.$(RUNTIME_NAMESPACE).svc.{{$clusterDomain}}. + {{- else }} + value: --storage-adv-addr=source-controller.$(RUNTIME_NAMESPACE).svc + {{- end }} {{- if $artifactStorage }} - op: add path: '/spec/template/spec/volumes/-'