MCPcopy Index your code
hub / github.com/devspace-sh/devspace / Run

Method Run

cmd/init.go:107–174  ·  view source on GitHub ↗

Run executes the command logic

(f factory.Factory)

Source from the content-addressed store, hash-verified

105
106// Run executes the command logic
107func (cmd *InitCmd) Run(f factory.Factory) error {
108 // Check if config already exists
109 cmd.log = f.GetLog()
110 configLoader, err := f.NewConfigLoader("")
111 if err != nil {
112 return err
113 }
114 configExists := configLoader.Exists()
115 if configExists && !cmd.Reconfigure {
116 optionNo := "No"
117 cmd.log.WriteString(cmd.log.GetLevel(), "\n")
118 cmd.log.Warnf("%s already exists in this project", ansi.Color("devspace.yaml", "white+b"))
119 response, err := cmd.log.Question(&survey.QuestionOptions{
120 Question: "Do you want to delete devspace.yaml and recreate it from scratch?",
121 Options: []string{optionNo, "Yes"},
122 })
123 if err != nil {
124 return err
125 }
126
127 if response == optionNo {
128 return nil
129 }
130 }
131
132 // Delete config & overwrite config
133 os.RemoveAll(".devspace")
134
135 // Delete configs path
136 os.Remove(constants.DefaultConfigsPath)
137
138 // Delete config & overwrite config
139 os.Remove(constants.DefaultConfigPath)
140
141 // Delete config & overwrite config
142 os.Remove(constants.DefaultVarsPath)
143
144 // Execute plugin hook
145 err = hook.ExecuteHooks(nil, nil, "init")
146 if err != nil {
147 return err
148 }
149
150 // Print DevSpace logo
151 log.PrintLogo()
152
153 // Determine if we're initializing from scratch, or using docker-compose.yaml
154 dockerComposePath, generateFromDockerCompose, err := cmd.shouldGenerateFromDockerCompose()
155 if err != nil {
156 return err
157 }
158
159 if generateFromDockerCompose {
160 err = cmd.initDockerCompose(f, dockerComposePath)
161 } else {
162 err = cmd.initDevspace(f, configLoader)
163 }
164 if err != nil {

Callers 1

NewInitCmdFunction · 0.95

Calls 15

ExistsMethod · 0.95
initDockerComposeMethod · 0.95
initDevspaceMethod · 0.95
ExecuteHooksFunction · 0.92
PrintLogoFunction · 0.92
GetLogMethod · 0.65
NewConfigLoaderMethod · 0.65
WriteStringMethod · 0.65
QuestionMethod · 0.65
RemoveMethod · 0.65
DoneMethod · 0.65

Tested by

no test coverage detected