appPush does the work of push
(providerType string, app *ddevapp.DdevApp, skipConfirmation bool, skipImportArg bool, skipDBArg bool, skipFilesArg bool, env string)
| 34 | |
| 35 | // appPush does the work of push |
| 36 | func appPush(providerType string, app *ddevapp.DdevApp, skipConfirmation bool, skipImportArg bool, skipDBArg bool, skipFilesArg bool, env string) { |
| 37 | provider, err := app.GetProvider(providerType) |
| 38 | if err != nil { |
| 39 | util.Failed("Failed to get provider: %v", err) |
| 40 | } |
| 41 | |
| 42 | if env != "" { |
| 43 | // Add or override the command-line provided environment variables |
| 44 | envVars := strings.SplitSeq(env, ",") |
| 45 | for v := range envVars { |
| 46 | split := strings.Split(v, "=") |
| 47 | if len(split) != 2 { |
| 48 | util.Failed("Unable to parse environment variable setting: %v", v) |
| 49 | } |
| 50 | provider.EnvironmentVariables[split[0]] = split[1] |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | // If we're not performing the import step, we won't be deleting the existing db or files. |
| 55 | if !skipConfirmation && !skipImportArg && globalconfig.IsInteractive() { |
| 56 | // Only warn the user about relevant risks. |
| 57 | var message string |
| 58 | if skipDBArg && skipFilesArg { |
| 59 | util.Warning("Both database and files import steps skipped.") |
| 60 | return |
| 61 | } else if !skipDBArg && skipFilesArg { |
| 62 | message = "database" |
| 63 | } else if !skipFilesArg && skipDBArg { |
| 64 | message = "files" |
| 65 | } else { |
| 66 | message = "database and files" |
| 67 | } |
| 68 | |
| 69 | targetInfo := provider.GetInfo() |
| 70 | if targetInfo != "" { |
| 71 | util.Warning("You're about to push your local %s to %s\nand replace it with your local project's %s.\nThis is normally a very dangerous operation.", message, targetInfo, message) |
| 72 | } else { |
| 73 | util.Warning("You're about to push your local %s to your upstream production\nand replace it with your local project's %s.\nThis is normally a very dangerous operation.", message, message) |
| 74 | } |
| 75 | if !util.ConfirmTo("Would you like to continue (not recommended)?", false) { |
| 76 | util.Failed("Push cancelled") |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | if err := app.Push(provider, skipDBArg, skipFilesArg); err != nil { |
| 81 | util.Failed("push failed: %v", err) |
| 82 | } |
| 83 | |
| 84 | util.Success("Push succeeded.") |
| 85 | } |
| 86 | |
| 87 | func init() { |
| 88 | RootCmd.AddCommand(PushCmd) |
no test coverage detected