Skip to content

Commit bad4bef

Browse files
committed
fix: endpoint script was incorrectly marshalling the shape of its response
1 parent e5d9d18 commit bad4bef

File tree

3 files changed

+92
-11
lines changed

3 files changed

+92
-11
lines changed

privatelink_test.go

Lines changed: 86 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,6 @@ func TestGetActiveActivePrivateLink(t *testing.T) {
421421
}
422422

423423
func TestGetPrivateLinkScript(t *testing.T) {
424-
t.Skipf("skipping test until privatelink script is available")
425-
426424
tc := []struct {
427425
description string
428426
mockedResponse []endpointRequest
@@ -436,10 +434,51 @@ func TestGetPrivateLinkScript(t *testing.T) {
436434
getRequest(
437435
t,
438436
"/subscriptions/114019/private-link/endpoint-script?includeTerraformAwsScript=true",
439-
`a pro privatelink aws terraform endpoint script`,
437+
`{
438+
"taskId": "4e62bd68-06ce-4207-91cd-62b9d8b60dff",
439+
"commandType": "privateLinkEndpointScriptGetRequest",
440+
"status": "received",
441+
"description": "Task request received and is being queued for processing.",
442+
"timestamp": "2025-10-30T14:13:46.539111211Z",
443+
"links": [
444+
{
445+
"type": "GET",
446+
"href": "https://api-staging.qa.redislabs.com/v1/tasks/4e62bd68-06ce-4207-91cd-62b9d8b60dff",
447+
"rel": "task"
448+
}
449+
]
450+
}`,
440451
),
452+
getRequest(
453+
t,
454+
"/tasks/4e62bd68-06ce-4207-91cd-62b9d8b60dff",
455+
`{
456+
"taskId": "4e62bd68-06ce-4207-91cd-62b9d8b60dff",
457+
"commandType": "privateLinkEndpointScriptGetRequest",
458+
"status": "processing-completed",
459+
"description": "Request processing completed successfully and its resources are now being provisioned / de-provisioned.",
460+
"timestamp": "2025-10-30T14:13:51.991415541Z",
461+
"response": {
462+
"resourceId": 114019,
463+
"resource": {
464+
"resourceEndpointScript": "python script content here",
465+
"terraformAwsScript": "terraform script content here"
466+
}
467+
},
468+
"links": [
469+
{
470+
"type": "GET",
471+
"href": "https://api-staging.qa.redislabs.com/v1/tasks/4e62bd68-06ce-4207-91cd-62b9d8b60dff",
472+
"rel": "self"
473+
}
474+
]
475+
}`,
476+
),
477+
},
478+
expectedResult: &pl.PrivateLinkEndpointScript{
479+
ResourceEndpointScript: redis.String("python script content here"),
480+
TerraformAwsScript: redis.String("terraform script content here"),
441481
},
442-
expectedResult: redis.String("a pro privatelink aws terraform endpoint script"),
443482
},
444483
}
445484
for _, testCase := range tc {
@@ -464,8 +503,6 @@ func TestGetPrivateLinkScript(t *testing.T) {
464503
}
465504

466505
func TestGetActiveActivePrivateLinkScript(t *testing.T) {
467-
t.Skipf("skipping test until privatelink script is available")
468-
469506
tc := []struct {
470507
description string
471508
mockedResponse []endpointRequest
@@ -479,10 +516,51 @@ func TestGetActiveActivePrivateLinkScript(t *testing.T) {
479516
getRequest(
480517
t,
481518
"/subscriptions/114019/regions/1/private-link/endpoint-script?includeTerraformAwsScript=true",
482-
`an active active aws terraform endpoint script`,
519+
`{
520+
"taskId": "5f73ce79-17df-5db1-a2de-18993ea71f00",
521+
"commandType": "activeActivePrivateLinkEndpointScriptGetRequest",
522+
"status": "received",
523+
"description": "Task request received and is being queued for processing.",
524+
"timestamp": "2025-10-30T14:13:46.539111211Z",
525+
"links": [
526+
{
527+
"type": "GET",
528+
"href": "https://api-staging.qa.redislabs.com/v1/tasks/5f73ce79-17df-5db1-a2de-18993ea71f00",
529+
"rel": "task"
530+
}
531+
]
532+
}`,
483533
),
534+
getRequest(
535+
t,
536+
"/tasks/5f73ce79-17df-5db1-a2de-18993ea71f00",
537+
`{
538+
"taskId": "5f73ce79-17df-5db1-a2de-18993ea71f00",
539+
"commandType": "activeActivePrivateLinkEndpointScriptGetRequest",
540+
"status": "processing-completed",
541+
"description": "Request processing completed successfully and its resources are now being provisioned / de-provisioned.",
542+
"timestamp": "2025-10-30T14:13:51.991415541Z",
543+
"response": {
544+
"resourceId": 114019,
545+
"resource": {
546+
"resourceEndpointScript": "active active python script content here",
547+
"terraformAwsScript": "active active terraform script content here"
548+
}
549+
},
550+
"links": [
551+
{
552+
"type": "GET",
553+
"href": "https://api-staging.qa.redislabs.com/v1/tasks/5f73ce79-17df-5db1-a2de-18993ea71f00",
554+
"rel": "self"
555+
}
556+
]
557+
}`,
558+
),
559+
},
560+
expectedResult: &pl.PrivateLinkEndpointScript{
561+
ResourceEndpointScript: redis.String("active active python script content here"),
562+
TerraformAwsScript: redis.String("active active terraform script content here"),
484563
},
485-
expectedResult: redis.String("an active active aws terraform endpoint script"),
486564
},
487565
}
488566
for _, testCase := range tc {

service/privatelink/model.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ func (f *NotFoundActiveActive) Error() string {
7979
return fmt.Sprintf("privatelink resource not found - subscription %d, region %d", f.subscriptionID, f.regionID)
8080
}
8181

82+
type PrivateLinkEndpointScript struct {
83+
ResourceEndpointScript *string `json:"resourceEndpointScript,omitempty"`
84+
TerraformAwsScript *string `json:"terraformAwsScript,omitempty"`
85+
}
86+
8287
const (
8388
// PrivateLinkStatusInitializing when PrivateLink is initialising
8489
PrivateLinkStatusInitializing = "initializing"

service/privatelink/service.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ func (a *API) GetPrivateLink(ctx context.Context, subscription int) (*PrivateLin
6161
return task, nil
6262
}
6363

64-
type PrivateLinkEndpointScript = string
65-
6664
// GetPrivateLinkEndpointScript will get the script for an endpoint.
6765
func (a *API) GetPrivateLinkEndpointScript(ctx context.Context, subscriptionId int) (*PrivateLinkEndpointScript, error) {
6866
message := fmt.Sprintf("get private link for subscription %d", subscriptionId)
@@ -205,7 +203,7 @@ func (a *API) getScript(ctx context.Context, message string, path string) (*Priv
205203
return nil, err
206204
}
207205

208-
a.logger.Printf("Waiting for PrivateLink script get request %d to complete", task.ID)
206+
a.logger.Printf("Waiting for PrivateLink script get request %s to complete", *task.ID)
209207

210208
var response PrivateLinkEndpointScript
211209
err = a.taskWaiter.WaitForResource(ctx, *task.ID, &response)

0 commit comments

Comments
 (0)