@@ -28,14 +28,37 @@ type HerokuApplicationInfo struct {
28
28
29
29
func collectHerokuApplicationInfo (ctx context.Context , client HerokuClientInterface , appName string ) (HerokuApplicationInfo , error ) {
30
30
var applicationInfo HerokuApplicationInfo
31
+
32
+ term .Info ("Identifying deployed dynos" )
31
33
dynos , err := client .ListDynos (ctx , appName )
32
34
if err != nil {
33
35
return HerokuApplicationInfo {}, fmt .Errorf ("failed to list dynos: %w" , err )
34
36
}
35
- applicationInfo .Dynos = dynos
36
37
38
+ applicationInfo .Dynos = dynos
37
39
term .Debugf ("Dynos for the selected application: %+v\n " , dynos )
38
40
41
+ dynoSizes := make (map [string ]HerokuDynoSize )
42
+ for _ , dyno := range dynos {
43
+ dynoSize , err := client .GetDynoSize (ctx , dyno .Size )
44
+ if err != nil {
45
+ return HerokuApplicationInfo {}, fmt .Errorf ("failed to get dyno size for dyno %s: %w" , dyno .Name , err )
46
+ }
47
+ dynoSizes [dyno .Name ] = dynoSize
48
+ }
49
+
50
+ applicationInfo .DynoSizes = dynoSizes
51
+ term .Debugf ("Dyno sizes for the selected application: %+v\n " , dynoSizes )
52
+
53
+ releaseTasks , err := client .GetReleaseTasks (ctx , appName )
54
+ if err != nil {
55
+ return HerokuApplicationInfo {}, fmt .Errorf ("failed to get Heroku release tasks: %w" , err )
56
+ }
57
+
58
+ applicationInfo .ReleaseTasks = releaseTasks
59
+ term .Debugf ("Release tasks for the selected application: %+v\n " , releaseTasks )
60
+
61
+ term .Info ("Identifying configured addons" )
39
62
addons , err := client .ListAddons (ctx , appName )
40
63
if err != nil {
41
64
return HerokuApplicationInfo {}, fmt .Errorf ("failed to list Heroku addons: %w" , err )
@@ -54,39 +77,21 @@ func collectHerokuApplicationInfo(ctx context.Context, client HerokuClientInterf
54
77
}
55
78
56
79
term .Debugf ("Postgres info for the selected application: %+v\n " , applicationInfo .PGInfo )
57
- dynoSizes := make (map [string ]HerokuDynoSize )
58
-
59
- // for each dyno, get the dyno size,
60
- for _ , dyno := range dynos {
61
- dynoSize , err := client .GetDynoSize (ctx , dyno .Size )
62
- if err != nil {
63
- return HerokuApplicationInfo {}, fmt .Errorf ("failed to get dyno size for dyno %s: %w" , dyno .Name , err )
64
- }
65
- dynoSizes [dyno .Name ] = dynoSize
66
- }
67
-
68
- applicationInfo .DynoSizes = dynoSizes
69
80
70
81
configVars , err := client .ListConfigVars (ctx , appName )
71
82
if err != nil {
72
83
return HerokuApplicationInfo {}, fmt .Errorf ("failed to list Heroku config vars: %w" , err )
73
84
}
74
85
applicationInfo .ConfigVars = configVars
75
86
76
- releaseTasks , err := client .GetReleaseTasks (ctx , appName )
77
- if err != nil {
78
- return HerokuApplicationInfo {}, fmt .Errorf ("failed to get Heroku release tasks: %w" , err )
79
- }
80
- applicationInfo .ReleaseTasks = releaseTasks
81
-
82
87
return applicationInfo , nil
83
88
}
84
89
85
90
func selectSourceApplication (surveyor surveyor.Surveyor , appNames []string ) (string , error ) {
86
91
var selectedApp string
87
92
for {
88
93
err := surveyor .AskOne (& survey.Select {
89
- Message : "Select the Heroku application to use as a source :" ,
94
+ Message : "Select the Heroku application you would like to migrate :" ,
90
95
Options : appNames , // This should be a list of app names, but for simplicity, we use the whole string
91
96
}, & selectedApp )
92
97
if err != nil {
@@ -383,7 +388,7 @@ func getHerokuAuthToken() (string, error) {
383
388
for {
384
389
err := survey .AskOne (& survey.Password {
385
390
Message : "Please paste a Heroku auth token, so Defang can collect information about your applications" ,
386
- Help : "Run `heroku authorizations:create --expires-in=300` or visit https://dashboard.heroku.com/account/applications/authorizations/new" ,
391
+ Help : "Visit https://dashboard.heroku.com/account/applications/authorizations/new" ,
387
392
}, & token )
388
393
if err != nil {
389
394
return "" , fmt .Errorf ("failed to prompt for Heroku token: %w" , err )
0 commit comments