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

Method resolveRecursive

pkg/devspace/dependency/resolver.go:115–183  ·  view source on GitHub ↗
(ctx devspacecontext.Context, basePath, parentConfigName string, currentDependency *Dependency, dependencies []*latest.DependencyConfig, options ResolveOptions)

Source from the content-addressed store, hash-verified

113}
114
115func (r *resolver) resolveRecursive(ctx devspacecontext.Context, basePath, parentConfigName string, currentDependency *Dependency, dependencies []*latest.DependencyConfig, options ResolveOptions) error {
116 if currentDependency != nil {
117 currentDependency.children = []types.Dependency{}
118 }
119 for _, dependencyConfig := range dependencies {
120 if contains(options.SkipDependencies, dependencyConfig.Name) {
121 continue
122 }
123
124 if len(options.Dependencies) > 0 && !stringutil.Contains(options.Dependencies, dependencyConfig.Name) {
125 continue
126 }
127
128 if dependencyConfig.Disabled {
129 ctx.Log().Debugf("Skip dependency %s, because it is disabled", dependencyConfig.Name)
130 continue
131 }
132
133 dependencyConfigPath, err := util.DownloadDependency(ctx.Context(), basePath, dependencyConfig.Source, ctx.Log())
134 if err != nil {
135 return err
136 }
137
138 // Try to insert new edge
139 var (
140 child *Dependency
141 )
142 if n, ok := r.DependencyGraph.Nodes[dependencyConfig.Name]; ok {
143 child = n.Data.(*Dependency)
144 if child != nil && child.Config() != nil && child.Config().Path() != dependencyConfigPath && !child.Root() {
145 ctx.Log().Warnf("Seems like you have multiple dependencies with name %s, but they use different source settings (%s != %s). This can lead to unexpected results and you should make sure that the devspace.yaml name is unique across your dependencies or that you use the dependencies.overrideName option", child.name, child.Config().Path(), dependencyConfigPath)
146 }
147
148 err := r.DependencyGraph.AddEdge(parentConfigName, dependencyConfig.Name)
149 if err != nil {
150 if _, ok := err.(*graph.CyclicError); !ok {
151 return err
152 }
153
154 ctx.Log().Debugf(err.Error())
155 }
156 } else {
157 child, err = r.resolveDependency(ctx, dependencyConfigPath, dependencyConfig.Name, dependencyConfig)
158 if err != nil {
159 return err
160 }
161
162 _, err = r.DependencyGraph.InsertNodeAt(parentConfigName, dependencyConfig.Name, child)
163 if err != nil {
164 return errors.Wrap(err, "insert node")
165 }
166
167 // load dependencies from dependency
168 if !dependencyConfig.IgnoreDependencies && child.localConfig.Config().Dependencies != nil && len(child.localConfig.Config().Dependencies) > 0 {
169 err = r.resolveRecursive(ctx, child.absolutePath, dependencyConfig.Name, child, transformMap(child.localConfig.Config().Dependencies), options)
170 if err != nil {
171 return err
172 }

Callers 1

ResolveMethod · 0.95

Calls 15

resolveDependencyMethod · 0.95
ContainsFunction · 0.92
DownloadDependencyFunction · 0.92
transformMapFunction · 0.85
AddEdgeMethod · 0.80
InsertNodeAtMethod · 0.80
containsFunction · 0.70
LogMethod · 0.65
ContextMethod · 0.65
ConfigMethod · 0.65
PathMethod · 0.65
RootMethod · 0.65

Tested by

no test coverage detected