(runtime *app.Runtime)
| 271 | } |
| 272 | |
| 273 | func hydrateRuntimeLayoutFromConfig(runtime *app.Runtime) error { |
| 274 | if runtime.Config == nil { |
| 275 | return nil |
| 276 | } |
| 277 | |
| 278 | storeLayout := runtime.Config.Layout() |
| 279 | if runtime.Layout.ConfigDir != "" && |
| 280 | storeLayout.ConfigDir != "" && |
| 281 | runtime.Layout.ConfigDir != storeLayout.ConfigDir { |
| 282 | return fmt.Errorf("%w: runtime=%s config_store=%s", |
| 283 | errRuntimeLayoutMismatch, runtime.Layout.ConfigDir, storeLayout.ConfigDir) |
| 284 | } |
| 285 | |
| 286 | mergeLayoutKind(&runtime.Layout, storeLayout, config.PathKindConfig) |
| 287 | mergeLayoutKind(&runtime.Layout, storeLayout, config.PathKindData) |
| 288 | mergeLayoutKind(&runtime.Layout, storeLayout, config.PathKindState) |
| 289 | mergeLayoutKind(&runtime.Layout, storeLayout, config.PathKindCache) |
| 290 | runtime.Layout.UsesXDG = runtime.Layout.UsesXDG || storeLayout.UsesXDG |
| 291 | runtime.Layout.UsesXDGState = runtime.Layout.UsesXDGState || storeLayout.UsesXDGState |
| 292 | return nil |
| 293 | } |
| 294 | |
| 295 | func mergeLayoutKind(target *config.Layout, source config.Layout, kind config.PathKind) { |
| 296 | targetDir, _ := target.Dir(kind) |
no test coverage detected