@@ -195,11 +195,6 @@ func (o *OctopusContainerTest) setupOctopus(ctx context.Context, connString stri
195
195
disableDind = "Y"
196
196
}
197
197
198
- apiKey := os .Getenv ("OCTOTESTAPIKEY" )
199
- if apiKey == "" {
200
- apiKey = ApiKey
201
- }
202
-
203
198
req := testcontainers.ContainerRequest {
204
199
Name : "octopus-" + uuid .New ().String (),
205
200
Image : o .getOctopusImageUrl () + ":" + o .getOctopusVersion (),
@@ -210,7 +205,7 @@ func (o *OctopusContainerTest) setupOctopus(ctx context.Context, connString stri
210
205
// CONNSTRING, LICENSE_BASE64, and CREATE_DB are used by the octopusdeploy/linux image
211
206
"CONNSTRING" : connString ,
212
207
"CREATE_DB" : "Y" ,
213
- "ADMIN_API_KEY" : ApiKey ,
208
+ "ADMIN_API_KEY" : getApiKey () ,
214
209
"DISABLE_DIND" : disableDind ,
215
210
"ADMIN_USERNAME" : "admin" ,
216
211
"ADMIN_PASSWORD" : "Password01!" ,
@@ -258,6 +253,14 @@ func (o *OctopusContainerTest) setupOctopus(ctx context.Context, connString stri
258
253
return & OctopusContainer {Container : container , URI : uri }, nil
259
254
}
260
255
256
+ func getApiKey () string {
257
+ apiKey := os .Getenv ("OCTOTESTAPIKEY" )
258
+ if apiKey == "" {
259
+ return ApiKey
260
+ }
261
+ return apiKey
262
+ }
263
+
261
264
// Pass through feature flags in the current environment to the environment used
262
265
// to launch the OctopusDeploy container
263
266
func (o * OctopusContainerTest ) AddCustomEnvironment (input map [string ]string ) map [string ]string {
@@ -404,7 +407,7 @@ func (o *OctopusContainerTest) ArrangeContainer() (*OctopusContainer, *client.Cl
404
407
return err
405
408
}
406
409
407
- octoClient , err = octoclient .CreateClient (octopusContainer .URI , "" , ApiKey )
410
+ octoClient , err = octoclient .CreateClient (octopusContainer .URI , "" , getApiKey () )
408
411
if err != nil {
409
412
return err
410
413
}
@@ -546,7 +549,7 @@ func (o *OctopusContainerTest) ArrangeTest(t *testing.T, testFunc func(t *testin
546
549
return err
547
550
}
548
551
549
- client , err := octoclient .CreateClient (octopusContainer .URI , "" , ApiKey )
552
+ client , err := octoclient .CreateClient (octopusContainer .URI , "" , getApiKey () )
550
553
if err != nil {
551
554
return err
552
555
}
@@ -632,7 +635,7 @@ func (o *OctopusContainerTest) TerraformApply(t *testing.T, terraformProjectDir
632
635
"-auto-approve" ,
633
636
"-no-color" ,
634
637
"-var=octopus_server=" + server ,
635
- "-var=octopus_apikey=" + ApiKey ,
638
+ "-var=octopus_apikey=" + getApiKey () ,
636
639
"-var=octopus_space_id=" + spaceId ,
637
640
}, vars ... )
638
641
0 commit comments