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

Function init

cmd/ddev/cmd/push.go:87–150  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

85}
86
87func init() {
88 RootCmd.AddCommand(PushCmd)
89
90 appRoot, err := ddevapp.GetActiveAppRoot("")
91 if err != nil {
92 return
93 }
94
95 app := &ddevapp.DdevApp{AppRoot: appRoot}
96 pList, err := app.GetValidProviders()
97 if err != nil {
98 return
99 }
100 for _, p := range pList {
101 subCommandName := p
102 subCommand := &cobra.Command{
103 Use: subCommandName,
104 Short: fmt.Sprintf("push with %s", subCommandName),
105 Example: fmt.Sprintf(`ddev push %s
106ddev push %s -y
107ddev push %s --skip-files -y`, subCommandName, subCommandName, subCommandName),
108 Args: cobra.ExactArgs(0),
109 Run: func(cmd *cobra.Command, _ []string) {
110 app, err := ddevapp.GetActiveApp("")
111 if err != nil {
112 util.Failed("push failed: %v", err)
113 }
114 if err = app.StartAppIfNotRunning(); err != nil {
115 util.Failed("Failed to start app %s: %v", app.Name, err)
116 }
117 providerName := subCommandName
118 p, err := app.GetProvider(subCommandName)
119 if err != nil {
120 util.Failed("No provider `%s' is provisioned in %s: %v", providerName, app.GetConfigPath("providers"), err)
121 }
122 app.ProviderInstance = p
123
124 flags := map[string]bool{"skip-confirmation": false, "skip-db": false, "skip-files": false, "skip-import": false}
125 for f := range flags {
126 flags[f], err = cmd.Flags().GetBool(f)
127 if err != nil {
128 util.Failed("Failed to get flag %s: %v", f, err)
129 }
130 }
131 environment, _ := cmd.Flags().GetString("environment")
132
133 appPush(providerName, app, flags["skip-confirmation"], flags["skip-import"], flags["skip-db"], flags["skip-files"], environment)
134 },
135 }
136 // Mark custom command
137 if !ddevapp.IsBundledCustomProvider(subCommandName) {
138 if subCommand.Annotations == nil {
139 subCommand.Annotations = map[string]string{}
140 }
141 subCommand.Annotations[CustomCommand] = "true"
142 }
143 PushCmd.AddCommand(subCommand)
144 subCommand.Flags().BoolP("skip-confirmation", "y", false, "Skip confirmation step")

Callers

nothing calls this directly

Calls 11

GetValidProvidersMethod · 0.95
StartAppIfNotRunningMethod · 0.95
GetProviderMethod · 0.95
GetConfigPathMethod · 0.95
GetActiveAppRootFunction · 0.92
GetActiveAppFunction · 0.92
FailedFunction · 0.92
IsBundledCustomProviderFunction · 0.92
appPushFunction · 0.85
GetBoolMethod · 0.65
GetStringMethod · 0.65

Tested by

no test coverage detected