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

Function interpolateDescription

app/controlplane/pkg/auditor/logentry.go:157–175  ·  view source on GitHub ↗
(tmplStr string, variables *GeneratorOptions)

Source from the content-addressed store, hash-verified

155}
156
157func interpolateDescription(tmplStr string, variables *GeneratorOptions) (string, error) {
158 tmpl, err := template.New("description").Parse(tmplStr)
159 if err != nil {
160 return "", fmt.Errorf("failed to parse description template: %w", err)
161 }
162
163 description := new(bytes.Buffer)
164 if err = tmpl.Execute(description, &DescriptionVariables{
165 ActorType: variables.ActorType,
166 ActorID: variables.ActorID,
167 ActorName: variables.ActorName,
168 ActorEmail: variables.ActorEmail,
169 OrgID: variables.OrgID,
170 }); err != nil {
171 return "", fmt.Errorf("failed to execute description template: %w", err)
172 }
173
174 return description.String(), nil
175}
176
177type GeneratorOption func(*GeneratorOptions) error
178type GeneratorOptions struct {

Callers 1

GenerateAuditEventFunction · 0.85

Calls 3

ParseMethod · 0.80
ExecuteMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected