(ctx devspacecontext.Context, dependencyConfigPath, dependencyName string, dependency *latest.DependencyConfig)
| 194 | } |
| 195 | |
| 196 | func (r *resolver) resolveDependency(ctx devspacecontext.Context, dependencyConfigPath, dependencyName string, dependency *latest.DependencyConfig) (*Dependency, error) { |
| 197 | // clone config options |
| 198 | cloned, err := r.ConfigOptions.Clone() |
| 199 | if err != nil { |
| 200 | return nil, errors.Wrap(err, "clone config options") |
| 201 | } |
| 202 | |
| 203 | // set dependency profile |
| 204 | cloned.OverrideName = dependency.Name |
| 205 | cloned.Profiles = []string{} |
| 206 | cloned.Profiles = append(cloned.Profiles, dependency.Profiles...) |
| 207 | cloned.DisableProfileActivation = dependency.DisableProfileActivation || r.ConfigOptions.DisableProfileActivation |
| 208 | |
| 209 | // load config |
| 210 | if cloned.Vars == nil { |
| 211 | cloned.Vars = []string{} |
| 212 | } |
| 213 | |
| 214 | if dependency.OverwriteVars { |
| 215 | for k, v := range ctx.Config().Variables() { |
| 216 | cloned.Vars = append(cloned.Vars, strings.TrimSpace(k)+"="+strings.TrimSpace(fmt.Sprintf("%v", v))) |
| 217 | } |
| 218 | } |
| 219 | for k, v := range dependency.Vars { |
| 220 | cloned.Vars = append(cloned.Vars, strings.TrimSpace(k)+"="+strings.TrimSpace(v)) |
| 221 | } |
| 222 | |
| 223 | // recreate client if necessary |
| 224 | client := ctx.KubeClient() |
| 225 | if dependency.Namespace != "" { |
| 226 | if ctx.KubeClient() == nil { |
| 227 | client, err = kubectl.NewClientFromContext("", dependency.Namespace, false, kubeconfig.NewLoader()) |
| 228 | } else { |
| 229 | client, err = kubectl.NewClientFromContext(client.CurrentContext(), dependency.Namespace, false, ctx.KubeClient().KubeConfigLoader()) |
| 230 | } |
| 231 | if err != nil { |
| 232 | return nil, errors.Wrap(err, "create new client") |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | // load the dependency config |
| 237 | var dConfigWrapper config.Config |
| 238 | err = executeInDirectory(filepath.Dir(dependencyConfigPath), func() error { |
| 239 | configLoader, err := loader.NewConfigLoader(dependencyConfigPath) |
| 240 | if err != nil { |
| 241 | return err |
| 242 | } |
| 243 | |
| 244 | if r.BaseParser == nil { |
| 245 | dConfigWrapper, err = configLoader.Load(ctx.Context(), client, cloned, ctx.Log()) |
| 246 | } else { |
| 247 | dConfigWrapper, err = configLoader.LoadWithParser(ctx.Context(), nil, client, r.BaseParser, cloned, ctx.Log()) |
| 248 | } |
| 249 | if err != nil { |
| 250 | return errors.Wrap(err, fmt.Sprintf("loading config for dependency %s", dependencyName)) |
| 251 | } |
| 252 | |
| 253 | return nil |
no test coverage detected