MCPcopy
hub / github.com/wavetermdev/waveterm / getLinuxStorageBackend

Function getLinuxStorageBackend

pkg/secretstore/secretstore.go:44–75  ·  view source on GitHub ↗

must hold lock

()

Source from the content-addressed store, hash-verified

42
43// must hold lock
44func getLinuxStorageBackend() error {
45 if runtime.GOOS != "linux" {
46 return nil
47 }
48
49 rpcClient := wshclient.GetBareRpcClient()
50 ctx, cancel := context.WithTimeout(context.Background(), EncryptionTimeout*time.Millisecond)
51 defer cancel()
52
53 encryptData := wshrpc.CommandElectronEncryptData{
54 PlainText: "hello",
55 }
56 rpcOpts := &wshrpc.RpcOpts{
57 Route: wshutil.ElectronRoute,
58 Timeout: EncryptionTimeout,
59 }
60
61 result, err := wshclient.ElectronEncryptCommand(rpcClient, encryptData, rpcOpts)
62 if err != nil {
63 return fmt.Errorf("failed to get storage backend: %w", err)
64 }
65
66 if ctx.Err() != nil {
67 return fmt.Errorf("encryption timeout: %w", ctx.Err())
68 }
69
70 if result.StorageBackend != "" {
71 linuxStorageBackend = result.StorageBackend
72 }
73
74 return nil
75}
76
77// must hold lock
78func readSecretsFromFile() (map[string]string, error) {

Callers 2

readSecretsFromFileFunction · 0.85
GetLinuxStorageBackendFunction · 0.85

Calls 3

GetBareRpcClientFunction · 0.92
ElectronEncryptCommandFunction · 0.92
ErrMethod · 0.80

Tested by

no test coverage detected