MCPcopy Index your code
hub / github.com/ddev/ddev / appPush

Function appPush

cmd/ddev/cmd/push.go:36–85  ·  view source on GitHub ↗

appPush does the work of push

(providerType string, app *ddevapp.DdevApp, skipConfirmation bool, skipImportArg bool, skipDBArg bool, skipFilesArg bool, env string)

Source from the content-addressed store, hash-verified

34
35// appPush does the work of push
36func 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
87func init() {
88 RootCmd.AddCommand(PushCmd)

Callers 1

initFunction · 0.85

Calls 8

FailedFunction · 0.92
IsInteractiveFunction · 0.92
WarningFunction · 0.92
ConfirmToFunction · 0.92
SuccessFunction · 0.92
GetProviderMethod · 0.80
GetInfoMethod · 0.80
PushMethod · 0.80

Tested by

no test coverage detected