Skip to content

Commit

Permalink
Add get fly-deployer method flaps client (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
rugwirobaker authored Aug 9, 2024
1 parent d7a9c24 commit ed17935
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions resource_apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package fly

import (
"context"
"fmt"
"strings"
)

func (client *Client) GetApps(ctx context.Context, role *string) ([]App, error) {
Expand Down Expand Up @@ -361,6 +363,24 @@ func (client *Client) GetAppRemoteBuilder(ctx context.Context, appName string) (
return &data.App, nil
}

func (client *Client) GetDeployerAppByOrg(ctx context.Context, orgID string) (*App, error) {
apps, err := client.GetAppsForOrganization(ctx, orgID)
if err != nil {
return nil, err
}

if len(apps) == 0 {
return nil, fmt.Errorf("no deployer found")
}

for _, app := range apps {
if strings.HasPrefix(app.Name, "fly-deployer-") {
return &app, nil
}
}
return nil, fmt.Errorf("no deployer found")
}

func (client *Client) GetAppNetwork(ctx context.Context, appName string) (*string, error) {
query := `
query ($appName: String!) {
Expand Down

0 comments on commit ed17935

Please sign in to comment.