MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / ParseYAMLPath

Function ParseYAMLPath

app/cli/pkg/action/apply.go:88–114  ·  view source on GitHub ↗

ParseYAMLPath collects all YAML files from a path (file or directory), reads them, and splits multi-document files into individual YAMLDoc entries.

(path string)

Source from the content-addressed store, hash-verified

86// ParseYAMLPath collects all YAML files from a path (file or directory),
87// reads them, and splits multi-document files into individual YAMLDoc entries.
88func ParseYAMLPath(path string) ([]*YAMLDoc, error) {
89 files, err := CollectYAMLFiles(path)
90 if err != nil {
91 return nil, err
92 }
93
94 if len(files) == 0 {
95 return nil, fmt.Errorf("no YAML files found in %q", path)
96 }
97
98 var allDocs []*YAMLDoc
99 for _, f := range files {
100 rawData, err := os.ReadFile(f)
101 if err != nil {
102 return nil, fmt.Errorf("reading file %s: %w", f, err)
103 }
104
105 docs, err := SplitYAMLDocuments(rawData)
106 if err != nil {
107 return nil, fmt.Errorf("parsing file %s: %w", f, err)
108 }
109
110 allDocs = append(allDocs, docs...)
111 }
112
113 return allDocs, nil
114}
115
116// ApplyContractFromRawData applies a single contract document using the gRPC client.
117func ApplyContractFromRawData(ctx context.Context, conn *grpc.ClientConn, rawData []byte) (bool, error) {

Callers 1

RunMethod · 0.85

Calls 2

CollectYAMLFilesFunction · 0.85
SplitYAMLDocumentsFunction · 0.85

Tested by

no test coverage detected