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

Method Run

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

Run applies all resources found in the given path (file or directory)

(ctx context.Context, path string)

Source from the content-addressed store, hash-verified

60
61// Run applies all resources found in the given path (file or directory)
62func (a *Apply) Run(ctx context.Context, path string) ([]*ApplyResult, error) {
63 docs, err := ParseYAMLPath(path)
64 if err != nil {
65 return nil, err
66 }
67
68 // Apply contracts
69 var results []*ApplyResult
70 for _, doc := range docs {
71 switch doc.Kind {
72 case KindContract:
73 changed, err := ApplyContractFromRawData(ctx, a.cfg.CPConnection, doc.RawData)
74 if err != nil {
75 return results, fmt.Errorf("%s/%s: %w", doc.Kind, doc.Name, err)
76 }
77 results = append(results, &ApplyResult{Kind: doc.Kind, Name: doc.Name, Changed: changed})
78 default:
79 return results, fmt.Errorf("unsupported kind %q", doc.Kind)
80 }
81 }
82
83 return results, nil
84}
85
86// ParseYAMLPath collects all YAML files from a path (file or directory),
87// reads them, and splits multi-document files into individual YAMLDoc entries.

Callers 15

ExecuteFunction · 0.45
ExecuteFunction · 0.45
ExecuteFunction · 0.45
ExecuteFunction · 0.45
ExecuteFunction · 0.45
TestExtractMCPServersFunction · 0.45
TestDiscoverAllFunction · 0.45
TestValidatePRInfoFunction · 0.45
TestValidatePRInfoV1_2Function · 0.45
TestDataUnmarshalJSONFunction · 0.45
TestValidatePRInfoV1_3Function · 0.45

Calls 2

ParseYAMLPathFunction · 0.85
ApplyContractFromRawDataFunction · 0.85

Tested by 15

TestExtractMCPServersFunction · 0.36
TestDiscoverAllFunction · 0.36
TestValidatePRInfoFunction · 0.36
TestValidatePRInfoV1_2Function · 0.36
TestDataUnmarshalJSONFunction · 0.36
TestValidatePRInfoV1_3Function · 0.36
TestCheckRoleFunction · 0.36
TestValidFunction · 0.36
TestNewBuilderFunction · 0.36
TestGenerateJWTFunction · 0.36
TestInfoFromAuthFunction · 0.36