Skip to content

Commit cc2bfbe

Browse files
authored
Merge 49c4b5e into 641eb1c
2 parents 641eb1c + 49c4b5e commit cc2bfbe

File tree

8 files changed

+671
-1
lines changed

8 files changed

+671
-1
lines changed

internal/command/launch/plan/postgres_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ func (m *mockUIEXClient) RestoreManagedClusterBackup(ctx context.Context, cluste
111111
return uiex.RestoreManagedClusterBackupResponse{}, nil
112112
}
113113

114+
func (m *mockUIEXClient) CreateAttachment(ctx context.Context, clusterId string, input uiex.CreateAttachmentInput) (uiex.CreateAttachmentResponse, error) {
115+
return uiex.CreateAttachmentResponse{}, nil
116+
}
117+
114118
func (m *mockUIEXClient) CreateBuild(ctx context.Context, in uiex.CreateBuildRequest) (*uiex.BuildResponse, error) {
115119
return &uiex.BuildResponse{}, nil
116120
}

internal/command/mpg/attach.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,15 @@ func runAttach(ctx context.Context) error {
281281
return err
282282
}
283283

284+
// Create attachment record to track the cluster-app relationship
285+
attachInput := uiex.CreateAttachmentInput{
286+
AppName: appName,
287+
}
288+
if _, err := uiexClient.CreateAttachment(ctx, cluster.Id, attachInput); err != nil {
289+
// Log warning but don't fail - the secret was set successfully
290+
fmt.Fprintf(io.ErrOut, "Warning: failed to create attachment record: %v\n", err)
291+
}
292+
284293
fmt.Fprintf(io.Out, "\nPostgres cluster %s is being attached to %s\n", cluster.Id, appName)
285294
fmt.Fprintf(io.Out, "The following secret was added to %s:\n %s=%s\n", appName, variableName, connectionUri)
286295

internal/command/mpg/list.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ package mpg
33
import (
44
"context"
55
"fmt"
6+
"strings"
67

78
"github.com/spf13/cobra"
89

910
"github.com/superfly/flyctl/gql"
11+
"github.com/superfly/flyctl/internal/uiex"
1012
"github.com/superfly/flyctl/iostreams"
1113

1214
"github.com/superfly/flyctl/internal/command"
@@ -95,8 +97,22 @@ func runList(ctx context.Context) error {
9597
cluster.Region,
9698
cluster.Status,
9799
cluster.Plan,
100+
formatAttachedApps(cluster.AttachedApps),
98101
})
99102
}
100103

101-
return render.Table(out, "", rows, "ID", "Name", "Org", "Region", "Status", "Plan")
104+
return render.Table(out, "", rows, "ID", "Name", "Org", "Region", "Status", "Plan", "Attached Apps")
105+
}
106+
107+
// formatAttachedApps formats the list of attached apps for display
108+
func formatAttachedApps(apps []uiex.AttachedApp) string {
109+
if len(apps) == 0 {
110+
return "<no attached apps>"
111+
}
112+
113+
names := make([]string, len(apps))
114+
for i, app := range apps {
115+
names[i] = app.Name
116+
}
117+
return strings.Join(names, ", ")
102118
}

0 commit comments

Comments
 (0)