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

Function Initialize

app/cli/internal/policydevel/init.go:61–78  ·  view source on GitHub ↗
(opts *InitOptions)

Source from the content-addressed store, hash-verified

59}
60
61func Initialize(opts *InitOptions) error {
62 content, err := loadAndProcessTemplates(opts)
63 if err != nil {
64 return fmt.Errorf("failed to process templates: %w", err)
65 }
66
67 files := make(map[string]string)
68 fileNameBase := sanitizeName(getPolicyName(opts.Name))
69
70 if opts.Embedded {
71 files[fileNameBase+".yaml"] = content.YAML
72 } else {
73 files[fileNameBase+".yaml"] = content.YAML
74 files[fileNameBase+".rego"] = content.Rego
75 }
76
77 return writeFiles(opts.Directory, files, opts.Force)
78}
79
80func getPolicyName(name string) string {
81 if name == "" {

Callers 2

RunMethod · 0.92
TestInitializeFunction · 0.85

Calls 4

loadAndProcessTemplatesFunction · 0.85
sanitizeNameFunction · 0.85
getPolicyNameFunction · 0.85
writeFilesFunction · 0.85

Tested by 1

TestInitializeFunction · 0.68