-
Notifications
You must be signed in to change notification settings - Fork 224
/
show.go
54 lines (40 loc) · 1.07 KB
/
show.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package builder
import (
"context"
"fmt"
"github.com/spf13/cobra"
"github.com/superfly/flyctl/iostreams"
"github.com/superfly/flyctl/client"
"github.com/superfly/flyctl/internal/command"
"github.com/superfly/flyctl/internal/flag"
)
func newShow() *cobra.Command {
const (
long = "Show details about an organization's remote builder image"
short = long
usage = "show <org-name>"
)
cmd := command.New(usage, short, long, runShow,
command.RequireSession,
)
cmd.Args = cobra.MinimumNArgs(1)
return cmd
}
func runShow(ctx context.Context) error {
var (
io = iostreams.FromContext(ctx)
client = client.FromContext(ctx).API()
)
orgName := flag.FirstArg(ctx)
org, err := client.GetOrganizationBySlug(ctx, orgName)
if err != nil {
return fmt.Errorf("failed getting org: %w", err)
}
if org.RemoteBuilderApp != nil {
fmt.Fprintf(io.Out, "App name: %s\n", org.RemoteBuilderApp.Name)
} else {
fmt.Fprintln(io.Out, "This org has not deployed apps yet.")
}
fmt.Fprintf(io.Out, "Desired remote builder image: %s \n", org.RemoteBuilderImage)
return nil
}