Skip to content

Commit afcf3dc

Browse files
committed
Use new API key in all the places
1 parent a2cd449 commit afcf3dc

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

test/octopus_container_test_framework.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,6 @@ func (o *OctopusContainerTest) setupOctopus(ctx context.Context, connString stri
195195
disableDind = "Y"
196196
}
197197

198-
apiKey := os.Getenv("OCTOTESTAPIKEY")
199-
if apiKey == "" {
200-
apiKey = ApiKey
201-
}
202-
203198
req := testcontainers.ContainerRequest{
204199
Name: "octopus-" + uuid.New().String(),
205200
Image: o.getOctopusImageUrl() + ":" + o.getOctopusVersion(),
@@ -210,7 +205,7 @@ func (o *OctopusContainerTest) setupOctopus(ctx context.Context, connString stri
210205
// CONNSTRING, LICENSE_BASE64, and CREATE_DB are used by the octopusdeploy/linux image
211206
"CONNSTRING": connString,
212207
"CREATE_DB": "Y",
213-
"ADMIN_API_KEY": ApiKey,
208+
"ADMIN_API_KEY": getApiKey(),
214209
"DISABLE_DIND": disableDind,
215210
"ADMIN_USERNAME": "admin",
216211
"ADMIN_PASSWORD": "Password01!",
@@ -258,6 +253,14 @@ func (o *OctopusContainerTest) setupOctopus(ctx context.Context, connString stri
258253
return &OctopusContainer{Container: container, URI: uri}, nil
259254
}
260255

256+
func getApiKey() string {
257+
apiKey := os.Getenv("OCTOTESTAPIKEY")
258+
if apiKey == "" {
259+
return ApiKey
260+
}
261+
return apiKey
262+
}
263+
261264
// Pass through feature flags in the current environment to the environment used
262265
// to launch the OctopusDeploy container
263266
func (o *OctopusContainerTest) AddCustomEnvironment(input map[string]string) map[string]string {
@@ -404,7 +407,7 @@ func (o *OctopusContainerTest) ArrangeContainer() (*OctopusContainer, *client.Cl
404407
return err
405408
}
406409

407-
octoClient, err = octoclient.CreateClient(octopusContainer.URI, "", ApiKey)
410+
octoClient, err = octoclient.CreateClient(octopusContainer.URI, "", getApiKey())
408411
if err != nil {
409412
return err
410413
}
@@ -546,7 +549,7 @@ func (o *OctopusContainerTest) ArrangeTest(t *testing.T, testFunc func(t *testin
546549
return err
547550
}
548551

549-
client, err := octoclient.CreateClient(octopusContainer.URI, "", ApiKey)
552+
client, err := octoclient.CreateClient(octopusContainer.URI, "", getApiKey())
550553
if err != nil {
551554
return err
552555
}
@@ -632,7 +635,7 @@ func (o *OctopusContainerTest) TerraformApply(t *testing.T, terraformProjectDir
632635
"-auto-approve",
633636
"-no-color",
634637
"-var=octopus_server=" + server,
635-
"-var=octopus_apikey=" + ApiKey,
638+
"-var=octopus_apikey=" + getApiKey(),
636639
"-var=octopus_space_id=" + spaceId,
637640
}, vars...)
638641

0 commit comments

Comments
 (0)