Skip to content

Commit

Permalink
Allow cluster domain to be unspicified
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
  • Loading branch information
kvaps committed Jun 16, 2024
1 parent fd31364 commit 005396e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 5 additions & 1 deletion internal/builder/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion internal/builder/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func MakeDefaultOptions() Options {
NetworkPolicy: true,
LogLevel: "info",
NotificationController: "notification-controller",
ClusterDomain: "cluster.local",
ClusterDomain: "",
}
}

Expand Down
9 changes: 8 additions & 1 deletion internal/builder/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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/-'
Expand Down

0 comments on commit 005396e

Please sign in to comment.