11package image
22
33import (
4+ "bytes"
45 "context"
56 "encoding/json"
67 "fmt"
78 "html/template"
89 "net"
9- "net/url"
1010 "path"
1111 "path/filepath"
1212 "strings"
@@ -306,7 +306,7 @@ func (a *Ignition) Generate(ctx context.Context, dependencies asset.Parents) err
306306
307307 rendezvousHostFile := ignition .FileFromString (rendezvousHostEnvPath ,
308308 "root" , 0644 ,
309- getRendezvousHostEnv (agentTemplateData . ServiceProtocol , a .RendezvousIP , authConfig . AgentAuthToken , authConfig . UserAuthToken , agentWorkflow .Workflow ))
309+ getRendezvousHostEnv (agentTemplateData , a .RendezvousIP , agentWorkflow .Workflow ))
310310 config .Storage .Files = append (config .Storage .Files , rendezvousHostFile )
311311
312312 err = addBootstrapScripts (& config , agentManifests .ClusterImageSet .Spec .ReleaseImage )
@@ -370,11 +370,13 @@ func (a *Ignition) Generate(ctx context.Context, dependencies asset.Parents) err
370370
371371func getDefaultEnabledServices () []string {
372372 return []string {
373+ "agent-extract-tui.service" ,
373374 "agent-interactive-console.service" ,
374375375376 "agent-register-cluster.service" ,
376377 "agent-import-cluster.service" ,
377378 "agent-register-infraenv.service" ,
379+ "agent-ui.service" ,
378380 "agent.service" ,
379381 "assisted-service-db.service" ,
380382 "assisted-service-pod.service" ,
@@ -446,17 +448,12 @@ func getTemplateData(name, pullSecret, releaseImageList, releaseImage, releaseIm
446448 }
447449}
448450
449- func getRendezvousHostEnv (serviceProtocol , nodeZeroIP , agentAuthtoken , userAuthToken string , workflowType workflow.AgentWorkflowType ) string {
450- serviceBaseURL := url.URL {
451- Scheme : serviceProtocol ,
452- Host : net .JoinHostPort (nodeZeroIP , "8090" ),
453- Path : "/" ,
454- }
455- imageServiceBaseURL := url.URL {
456- Scheme : serviceProtocol ,
457- Host : net .JoinHostPort (nodeZeroIP , "8888" ),
458- Path : "/" ,
459- }
451+ func getRendezvousHostEnvTemplate (data * agentTemplateData , workflowType workflow.AgentWorkflowType ) string {
452+ host := "{{ if $isIPv6 }}{{ printf \" [%s]\" .RendezvousIP }}{{ else }}{{ .RendezvousIP }}{{ end }}"
453+ serviceBaseURL := fmt .Sprintf ("%s://%s:8090/" , data .ServiceProtocol , host )
454+ imageServiceBaseURL := fmt .Sprintf ("%s://%s:8888/" , data .ServiceProtocol , host )
455+ uiBaseURL := fmt .Sprintf ("%s://%s:3001/" , data .ServiceProtocol , host )
456+
460457 // USER_AUTH_TOKEN is required to authenticate API requests against agent-installer-local auth type
461458 // and for the endpoints marked with userAuth security definition in assisted-service swagger.yaml.
462459 // PULL_SECRET_TOKEN contains the AGENT_AUTH_TOKEN and is required for the endpoints marked with agentAuth security definition in assisted-service swagger.yaml.
@@ -469,27 +466,40 @@ func getRendezvousHostEnv(serviceProtocol, nodeZeroIP, agentAuthtoken, userAuthT
469466 // and ensure successful authentication.
470467 // In the absence of PULL_SECRET_TOKEN, the cluster installation will wait forever.
471468
472- rendezvousHostEnv := fmt .Sprintf (`NODE_ZERO_IP=%s
469+ rendezvousHostEnvTemplate := fmt .Sprintf (`#{{ $isIPv6 := false }}{{ $host := .RendezvousIP }}{{ range ( len .RendezvousIP ) }}{{if eq ( index ( slice $host . ) 0 ) ':'}}{{ $isIPv6 = true }}{{ end }}{{ end }}
470+ NODE_ZERO_IP={{.RendezvousIP}}
473471SERVICE_BASE_URL=%s
474472IMAGE_SERVICE_BASE_URL=%s
475473PULL_SECRET_TOKEN=%s
476474USER_AUTH_TOKEN=%s
477475WORKFLOW_TYPE=%s
478- ` , nodeZeroIP , serviceBaseURL .String (), imageServiceBaseURL .String (), agentAuthtoken , userAuthToken , workflowType )
479-
480- if workflowType == workflow .AgentWorkflowTypeInstallInteractiveDisconnected {
481- uiBaseURL := url.URL {
482- Scheme : serviceProtocol ,
483- Host : net .JoinHostPort (nodeZeroIP , "3001" ),
484- Path : "/" ,
485- }
486- uiEnv := fmt .Sprintf (`AIUI_APP_API_URL=%s
476+ AIUI_APP_API_URL=%s
487477AIUI_URL=%s
488- ` , serviceBaseURL .String (), uiBaseURL .String ())
489- rendezvousHostEnv = fmt .Sprintf ("%s%s" , rendezvousHostEnv , uiEnv )
478+ ` , serviceBaseURL , imageServiceBaseURL , data .AgentAuthToken , data .UserAuthToken , workflowType , serviceBaseURL , uiBaseURL )
479+
480+ return rendezvousHostEnvTemplate
481+ }
482+
483+ func getRendezvousHostEnvFromTemplate (hostEnvTemplate , nodeZeroIP string ) (string , error ) {
484+ tmpl , err := template .New ("rendezvous-host.env" ).Parse (hostEnvTemplate )
485+ if err != nil {
486+ return "" , err
487+ }
488+ buf := & bytes.Buffer {}
489+ if err := tmpl .Execute (buf , struct { RendezvousIP string }{nodeZeroIP }); err != nil {
490+ return "" , err
490491 }
492+ return buf .String (), nil
493+ }
491494
492- return rendezvousHostEnv
495+ func getRendezvousHostEnv (data * agentTemplateData , nodeZeroIP string , workflowType workflow.AgentWorkflowType ) string {
496+ env , err := getRendezvousHostEnvFromTemplate (
497+ getRendezvousHostEnvTemplate (data , workflowType ),
498+ nodeZeroIP )
499+ if err != nil {
500+ panic (err )
501+ }
502+ return env
493503}
494504
495505func getAddNodesEnv (clusterInfo joiner.ClusterInfo , authTokenExpiry string ) string {
0 commit comments