MCPcopy Create free account
hub / github.com/cozystack/talm / loadValueFile

Function loadValueFile

pkg/engine/engine.go:1678–1699  ·  view source on GitHub ↗

loadValueFile reads a single --values / templateOptions.valueFiles entry into a map. A file named *.encrypted.yaml is age-decrypted in memory with the project's talm.key (rootDir locates the key; no plaintext touches disk); any other file is read as plaintext YAML. Detection is name-authoritative an

(rootDir, filePath string)

Source from the content-addressed store, hash-verified

1676// carries no envelope, so a mis-named or empty file fails loudly instead of
1677// slipping through as plaintext.
1678func loadValueFile(rootDir, filePath string) (map[string]any, error) {
1679 if strings.HasSuffix(filePath, age.EncryptedFileSuffix) {
1680 decrypted, err := age.DecryptYAMLToMap(rootDir, filePath)
1681 if err != nil {
1682 return nil, errors.Wrapf(err, "failed to load encrypted values file %s", filePath)
1683 }
1684
1685 return decrypted, nil
1686 }
1687
1688 buf, err := os.ReadFile(filePath)
1689 if err != nil {
1690 return nil, errors.Wrapf(err, "failed to read values file %s", filePath)
1691 }
1692
1693 currentMap := make(map[string]any)
1694 if err := yaml.Unmarshal(buf, &currentMap); err != nil {
1695 return nil, errors.Wrapf(err, "failed to unmarshal values from file %s", filePath)
1696 }
1697
1698 return currentMap, nil
1699}
1700
1701// Imported from Helm
1702// https://github.com/helm/helm/blob/c6beb169d26751efd8131a5d65abe75c81a334fb/pkg/cli/values/options.go#L44

Callers 1

loadValuesFunction · 0.85

Calls 1

DecryptYAMLToMapFunction · 0.92

Tested by

no test coverage detected