Skip to content

Commit

Permalink
Flyctl init --import unable to find internal port in config
Browse files Browse the repository at this point in the history
Fixes #286
  • Loading branch information
codepope committed Sep 7, 2020
1 parent e1e516e commit a39ac47
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ func runInit(commandContext *cmdctx.CmdContext) error {
newAppConfig.Definition = app.Config.Definition
}

if configPort != "" {
if configPort != "" { // If the config port has been set externally, set that
newAppConfig.SetInternalPort(internalPort)
} else {
} else if importfile == "" { // If we are not importing, get the default, ask for new setting
currentport, err := newAppConfig.GetInternalPort()
if err != nil {
return err
Expand Down
10 changes: 4 additions & 6 deletions flyctl/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,12 @@ func (ac *AppConfig) SetInternalPort(port int) bool {
}

func (ac *AppConfig) GetInternalPort() (int, error) {
services, ok := ac.Definition["services"].([]interface{})
services, ok := ac.Definition["services"].([]map[string]interface{})
if ok {
service0, ok := services[0].(map[string]interface{})
service0 := services[0] //.(map[string]interface{})
internalport, ok := service0["internal_port"].(int64)
if ok {
internalport, ok := service0["internal_port"].(float64)
if ok {
return int(internalport), nil
}
return int(internalport), nil
}
}

Expand Down

0 comments on commit a39ac47

Please sign in to comment.