This function loads releases into the memory storage if the environment variable is properly set.
(actionConfig *action.Configuration)
| 314 | // This function loads releases into the memory storage if the |
| 315 | // environment variable is properly set. |
| 316 | func loadReleasesInMemory(actionConfig *action.Configuration) { |
| 317 | filePaths := strings.Split(os.Getenv("HELM_MEMORY_DRIVER_DATA"), ":") |
| 318 | if len(filePaths) == 0 { |
| 319 | return |
| 320 | } |
| 321 | |
| 322 | store := actionConfig.Releases |
| 323 | mem, ok := store.Driver.(*driver.Memory) |
| 324 | if !ok { |
| 325 | // For an unexpected reason we are not dealing with the memory storage driver. |
| 326 | return |
| 327 | } |
| 328 | |
| 329 | actionConfig.KubeClient = &kubefake.PrintingKubeClient{Out: io.Discard} |
| 330 | |
| 331 | for _, path := range filePaths { |
| 332 | b, err := os.ReadFile(path) |
| 333 | if err != nil { |
| 334 | log.Fatal("Unable to read memory driver data", err) |
| 335 | } |
| 336 | |
| 337 | releases := []*release.Release{} |
| 338 | if err := yaml.Unmarshal(b, &releases); err != nil { |
| 339 | log.Fatal("Unable to unmarshal memory driver data: ", err) |
| 340 | } |
| 341 | |
| 342 | for _, rel := range releases { |
| 343 | if err := store.Create(rel); err != nil { |
| 344 | log.Fatal(err) |
| 345 | } |
| 346 | } |
| 347 | } |
| 348 | // Must reset namespace to the proper one |
| 349 | mem.SetNamespace(settings.Namespace()) |
| 350 | } |
| 351 | |
| 352 | // hookOutputWriter provides the writer for writing hook logs. |
| 353 | func hookOutputWriter(_, _, _ string) io.Writer { |
no test coverage detected
searching dependent graphs…