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

Function init

cmd/ddev/cmd/pull.go:89–152  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Tested by

no test coverage detected