MCPcopy Create free account
hub / github.com/aws-cloudformation/rain / File

Function File

cft/parse/parse.go:28–46  ·  view source on GitHub ↗

File returns a cft.Template parsed from a file specified by fileName

(fileName string)

Source from the content-addressed store, hash-verified

26
27// File returns a cft.Template parsed from a file specified by fileName
28func File(fileName string) (*cft.Template, error) {
29 source, err := os.ReadFile(fileName)
30 if err != nil {
31 return &cft.Template{}, fmt.Errorf("unable to read file: %s", err)
32 }
33
34 t, err := String(string(source))
35 if err != nil {
36 return t, err
37 }
38 t.FileName = fileName
39 tokens := strings.Split(fileName, "/")
40 if len(tokens) > 1 {
41 t.Name = tokens[len(tokens)-1]
42 } else {
43 t.Name = fileName
44 }
45 return t, nil
46}
47
48// Map returns a cft.Template parsed from a map[string]interface{}
49func Map(input map[string]interface{}) (*cft.Template, error) {

Callers 11

TestConstantsFunction · 0.92
FileFunction · 0.92
runTestFunction · 0.92
TestReadFileFunction · 0.92
TestUnCDKFunction · 0.92
merge.goFile · 0.92
forecast.goFile · 0.92
diff.goFile · 0.92
TestUpdateFunction · 0.92
tree.goFile · 0.92
TestColouriseDiffFunction · 0.92

Calls 1

StringFunction · 0.70

Tested by 6

TestConstantsFunction · 0.74
runTestFunction · 0.74
TestReadFileFunction · 0.74
TestUnCDKFunction · 0.74
TestUpdateFunction · 0.74
TestColouriseDiffFunction · 0.74