@@ -55,7 +55,7 @@ func (m *EmbeddedCluster) E2eRunHeadless(
5555 // Skip cleanup
5656 // +default=false
5757 skipCleanup bool ,
58- ) (* dagger.Directory , error ) {
58+ ) (resultsDir * dagger.Directory ) {
5959 mode := "headless"
6060
6161 // Initialize test result that will be built up throughout the function
@@ -66,15 +66,15 @@ func (m *EmbeddedCluster) E2eRunHeadless(
6666 }
6767
6868 // Initialize results directory
69- resultsDir : = dag .Directory ()
69+ resultsDir = dag .Directory ()
7070
7171 // Log test start
7272 fmt .Printf ("Starting E2E test: scenario=%s mode=%s app-version=%s kube-version=%s\n " ,
7373 scenario , mode , appVersion , kubeVersion )
7474
7575 // Provision a fresh CMX VM for testing
7676 fmt .Printf ("Provisioning CMX VM for %s %s test...\n " , scenario , mode )
77- vm , err := m .ProvisionCmxVm (
77+ vm , provisionErr := m .ProvisionCmxVm (
7878 ctx ,
7979 fmt .Sprintf ("ec-e2e-%s-%s" , scenario , mode ),
8080 "ubuntu" ,
@@ -86,10 +86,11 @@ func (m *EmbeddedCluster) E2eRunHeadless(
8686 cmxToken ,
8787 sshKey ,
8888 )
89- if err != nil {
90- testResult .Error = fmt .Sprintf ("failed to provision VM: %v" , err )
89+ if provisionErr != nil {
90+ testResult .Error = fmt .Sprintf ("failed to provision VM: %v" , provisionErr )
9191 resultJSON , _ := json .MarshalIndent (testResult , "" , " " )
92- return resultsDir .WithNewFile ("result.json" , string (resultJSON )), nil
92+ resultsDir = resultsDir .WithNewFile ("result.json" , string (resultJSON ))
93+ return
9394 }
9495
9596 fmt .Printf ("Provisioned VM: %s\n " , vm .VmID )
@@ -100,19 +101,19 @@ func (m *EmbeddedCluster) E2eRunHeadless(
100101 // Collect support bundle before cleanup
101102 if vm != nil {
102103 fmt .Printf ("Collecting support bundle from VM %s...\n " , vm .VmID )
103- supportBundle , err := vm .CollectClusterSupportBundle (ctx )
104- if err != nil {
105- fmt .Printf ("Warning: failed to collect support bundle: %v\n " , err )
106- resultsDir = resultsDir .WithNewFile ("support-bundle-error.txt" , fmt .Sprintf ("Failed to collect support bundle: %v" , err ))
104+ supportBundle , bundleErr := vm .CollectClusterSupportBundle (ctx )
105+ if bundleErr != nil {
106+ fmt .Printf ("Warning: failed to collect support bundle: %v\n " , bundleErr )
107+ resultsDir = resultsDir .WithNewFile ("support-bundle-error.txt" , fmt .Sprintf ("Failed to collect support bundle: %v" , bundleErr ))
107108 } else {
108109 resultsDir = resultsDir .WithFile ("support-bundle.tar.gz" , supportBundle )
109110 }
110111 }
111112
112113 // Marshal final test result to JSON
113- resultJSON , err := json .MarshalIndent (testResult , "" , " " )
114- if err != nil {
115- fmt .Printf ("Warning: failed to marshal test result: %v\n " , err )
114+ resultJSON , marshalErr := json .MarshalIndent (testResult , "" , " " )
115+ if marshalErr != nil {
116+ fmt .Printf ("Warning: failed to marshal test result: %v\n " , marshalErr )
116117 return
117118 }
118119 resultsDir = resultsDir .WithNewFile ("result.json" , string (resultJSON ))
@@ -128,37 +129,37 @@ func (m *EmbeddedCluster) E2eRunHeadless(
128129 }()
129130
130131 // Download and prepare embedded-cluster release
131- if err := vm .PrepareRelease (ctx , scenario , appVersion , licenseFile ); err != nil {
132- testResult .Error = fmt .Sprintf ("failed to prepare release: %v" , err )
133- return resultsDir , nil
132+ if prepareErr := vm .PrepareRelease (ctx , scenario , appVersion , licenseFile ); prepareErr != nil {
133+ testResult .Error = fmt .Sprintf ("failed to prepare release: %v" , prepareErr )
134+ return
134135 }
135136
136137 // For airgap scenarios, apply network policy to block internet access
137138 if scenario == "airgap" {
138139 fmt .Printf ("Applying airgap network policy on VM %s...\n " , vm .VmID )
139- if err := vm .ApplyAirgapNetworkPolicy (ctx ); err != nil {
140- testResult .Error = fmt .Sprintf ("failed to apply airgap network policy: %v" , err )
141- return resultsDir , nil
140+ if airgapErr := vm .ApplyAirgapNetworkPolicy (ctx ); airgapErr != nil {
141+ testResult .Error = fmt .Sprintf ("failed to apply airgap network policy: %v" , airgapErr )
142+ return
142143 }
143144 }
144145
145146 // Run headless installation
146147 fmt .Printf ("Running headless installation on VM %s...\n " , vm .VmID )
147- installResult , err := vm .InstallHeadless (
148+ installResult , installErr := vm .InstallHeadless (
148149 ctx ,
149150 scenario ,
150151 appVersion ,
151152 licenseFile ,
152153 dag .File ("config-values.yaml" , configValuesFileContent ),
153154 )
154- if err != nil {
155- testResult .Error = fmt .Sprintf ("installation failed: %v" , err )
156- return resultsDir , nil
155+ if installErr != nil {
156+ testResult .Error = fmt .Sprintf ("installation failed: %v" , installErr )
157+ return
157158 }
158159
159160 if ! installResult .Success {
160161 testResult .Error = "installation reported failure"
161- return resultsDir , nil
162+ return
162163 }
163164
164165 // Validate installation
@@ -181,7 +182,7 @@ func (m *EmbeddedCluster) E2eRunHeadless(
181182 fmt .Printf ("Test PASSED: %s %s test completed successfully\n " , scenario , mode )
182183 }
183184
184- return resultsDir , nil
185+ return
185186}
186187
187188func parseLicense (ctx context.Context , licenseFile * dagger.File ) (contents string , licenseID string , channelID string , err error ) {
0 commit comments