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

Method RunRun

cmd/run.go:93–163  ·  view source on GitHub ↗

RunRun executes the functionality "devspace run"

(f factory.Factory, args []string)

Source from the content-addressed store, hash-verified

91
92// RunRun executes the functionality "devspace run"
93func (cmd *RunCmd) RunRun(f factory.Factory, args []string) error {
94 if len(args) == 0 {
95 return fmt.Errorf("run requires at least one argument")
96 }
97
98 // check if dependency command
99 commandSplitted := strings.Split(args[0], ".")
100 if len(commandSplitted) > 1 {
101 cmd.Dependency = strings.Join(commandSplitted[:len(commandSplitted)-1], ".")
102 args[0] = commandSplitted[len(commandSplitted)-1]
103 }
104
105 // Execute plugin hook
106 err := hook.ExecuteHooks(nil, nil, "run")
107 if err != nil {
108 return err
109 }
110
111 // Set config root
112 configOptions := cmd.ToConfigOptions()
113 configLoader, err := f.NewConfigLoader(cmd.ConfigPath)
114 if err != nil {
115 return err
116 }
117 configExists, err := configLoader.SetDevSpaceRoot(f.GetLog())
118 if err != nil {
119 return err
120 } else if !configExists {
121 return errors.New(message.ConfigNotFound)
122 }
123
124 // load the config
125 ctx, err := cmd.LoadCommandsConfig(f, configLoader, configOptions, f.GetLog())
126 if err != nil {
127 return err
128 }
129
130 // check if we should execute a dependency command
131 if cmd.Dependency != "" {
132 config, err := configLoader.LoadWithCache(context.Background(), ctx.Config().LocalCache(), nil, configOptions, f.GetLog())
133 if err != nil {
134 return err
135 }
136
137 ctx = ctx.WithConfig(config)
138 dependencies, err := f.NewDependencyManager(ctx, configOptions).ResolveAll(ctx, dependency.ResolveOptions{})
139 if err != nil {
140 return err
141 }
142
143 dep := dependency.GetDependencyByPath(dependencies, cmd.Dependency)
144 if dep == nil {
145 return fmt.Errorf("couldn't find dependency %s", cmd.Dependency)
146 }
147
148 ctx = ctx.AsDependency(dep)
149 commandConfig, err := findCommand(ctx.Config(), args[0])
150 if err != nil {

Callers 2

NewRunCmdFunction · 0.95
command.goFile · 0.80

Calls 15

SetDevSpaceRootMethod · 0.95
LoadCommandsConfigMethod · 0.95
LoadWithCacheMethod · 0.95
ExecuteHooksFunction · 0.92
GetDependencyByPathFunction · 0.92
findCommandFunction · 0.85
executeCommandWithAfterFunction · 0.85
ToConfigOptionsMethod · 0.80
NewConfigLoaderMethod · 0.65
GetLogMethod · 0.65
LocalCacheMethod · 0.65
ConfigMethod · 0.65

Tested by

no test coverage detected