(args []string)
| 13 | } |
| 14 | |
| 15 | func (cmd *EnableSSHCommand) Execute(args []string) error { |
| 16 | err := cmd.SharedActor.CheckTarget(true, true) |
| 17 | if err != nil { |
| 18 | return err |
| 19 | } |
| 20 | |
| 21 | user, err := cmd.Actor.GetCurrentUser() |
| 22 | if err != nil { |
| 23 | return err |
| 24 | } |
| 25 | |
| 26 | cmd.UI.DisplayTextWithFlavor("Enabling ssh support for app {{.AppName}} as {{.CurrentUserName}}...", map[string]interface{}{ |
| 27 | "AppName": cmd.RequiredArgs.AppName, |
| 28 | "CurrentUserName": user.Name, |
| 29 | }) |
| 30 | |
| 31 | app, getAppWarnings, err := cmd.Actor.GetApplicationByNameAndSpace(cmd.RequiredArgs.AppName, cmd.Config.TargetedSpace().GUID) |
| 32 | if err != nil { |
| 33 | return err |
| 34 | } |
| 35 | cmd.UI.DisplayWarnings(getAppWarnings) |
| 36 | |
| 37 | appFeature, getAppFeatureWarnings, err := cmd.Actor.GetAppFeature(app.GUID, "ssh") |
| 38 | if err != nil { |
| 39 | return err |
| 40 | } |
| 41 | |
| 42 | cmd.UI.DisplayWarnings(getAppFeatureWarnings) |
| 43 | |
| 44 | if appFeature.Enabled { |
| 45 | cmd.UI.DisplayTextWithFlavor("ssh support for app '{{.AppName}}' is already enabled.", map[string]interface{}{ |
| 46 | "AppName": cmd.RequiredArgs.AppName, |
| 47 | }) |
| 48 | } |
| 49 | |
| 50 | updateSSHWarnings, err := cmd.Actor.UpdateAppFeature(app, true, "ssh") |
| 51 | if err != nil { |
| 52 | return err |
| 53 | } |
| 54 | cmd.UI.DisplayWarnings(updateSSHWarnings) |
| 55 | |
| 56 | sshEnabled, getSSHEnabledWarnings, err := cmd.Actor.GetSSHEnabled(app.GUID) |
| 57 | if err != nil { |
| 58 | return err |
| 59 | } |
| 60 | cmd.UI.DisplayWarnings(getSSHEnabledWarnings) |
| 61 | |
| 62 | cmd.UI.DisplayOK() |
| 63 | |
| 64 | if !sshEnabled.Enabled { |
| 65 | cmd.UI.DisplayText("TIP: Ensure ssh is also enabled on the space and global level.") |
| 66 | } |
| 67 | |
| 68 | if sshEnabled.Enabled && !appFeature.Enabled { |
| 69 | cmd.UI.DisplayText("TIP: An app restart is required for the change to take effect.") |
| 70 | } |
| 71 | |
| 72 | if appFeature.Enabled { |
nothing calls this directly
no test coverage detected