MCPcopy
hub / github.com/getsops/sops / LoadEncryptedFileEx

Function LoadEncryptedFileEx

cmd/sops/common/common.go:135–156  ·  view source on GitHub ↗

LoadEncryptedFileEx loads an encrypted SOPS file from a file or stdin, returning a SOPS tree

(loader sops.EncryptedFileLoader, inputPath string, readFromStdin bool)

Source from the content-addressed store, hash-verified

133
134// LoadEncryptedFileEx loads an encrypted SOPS file from a file or stdin, returning a SOPS tree
135func LoadEncryptedFileEx(loader sops.EncryptedFileLoader, inputPath string, readFromStdin bool) (*sops.Tree, error) {
136 var fileBytes []byte
137 var err error
138 if readFromStdin {
139 fileBytes, err = io.ReadAll(os.Stdin)
140 if err != nil {
141 return nil, NewExitError(fmt.Sprintf("Error reading from stdin: %s", err), codes.CouldNotReadInputFile)
142 }
143 } else {
144 fileBytes, err = os.ReadFile(inputPath)
145 if err != nil {
146 return nil, NewExitError(fmt.Sprintf("Error reading file: %s", err), codes.CouldNotReadInputFile)
147 }
148 }
149 path, err := filepath.Abs(inputPath)
150 if err != nil {
151 return nil, err
152 }
153 tree, err := loader.LoadEncryptedFile(fileBytes)
154 tree.FilePath = path
155 return &tree, err
156}
157
158// LoadEncryptedFile loads an encrypted SOPS file, returning a SOPS tree
159func LoadEncryptedFile(loader sops.EncryptedFileLoader, inputPath string) (*sops.Tree, error) {

Callers 2

LoadEncryptedFileFunction · 0.85

Calls 2

NewExitErrorFunction · 0.85
LoadEncryptedFileMethod · 0.65

Tested by

no test coverage detected