MCPcopy Create free account
hub / github.com/wavetermdev/waveterm / BuildAppSecretEnv

Function BuildAppSecretEnv

pkg/waveappstore/waveappstore.go:804–842  ·  view source on GitHub ↗
(appId string, manifest *wshrpc.AppManifest, bindings map[string]string)

Source from the content-addressed store, hash-verified

802}
803
804func BuildAppSecretEnv(appId string, manifest *wshrpc.AppManifest, bindings map[string]string) (map[string]string, error) {
805 if manifest == nil {
806 return make(map[string]string), nil
807 }
808
809 if bindings == nil {
810 bindings = make(map[string]string)
811 }
812
813 secretEnv := make(map[string]string)
814
815 for secretName, secretMeta := range manifest.Secrets {
816 boundSecretName, hasBinding := bindings[secretName]
817
818 if !secretMeta.Optional && !hasBinding {
819 return nil, fmt.Errorf("required secret %q is not bound", secretName)
820 }
821
822 if !hasBinding {
823 continue
824 }
825
826 secretValue, exists, err := secretstore.GetSecret(boundSecretName)
827 if err != nil {
828 return nil, fmt.Errorf("failed to get secret %q: %w", boundSecretName, err)
829 }
830
831 if !exists {
832 if !secretMeta.Optional {
833 return nil, fmt.Errorf("required secret %q is bound to %q which does not exist in secret store", secretName, boundSecretName)
834 }
835 continue
836 }
837
838 secretEnv[secretName] = secretValue
839 }
840
841 return secretEnv, nil
842}

Callers 2

runBuilderAppMethod · 0.92
GetStatusMethod · 0.92

Calls 1

GetSecretFunction · 0.92

Tested by

no test coverage detected