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

Method AddFileEvidence

extras/dagger/main.go:486–557  ·  view source on GitHub ↗

Add a file type piece of evidence to the attestation

(
	ctx context.Context,
	// Evidence name. Don't pass a name if the material
	// being attested is not part of the contract
	//  Example: "my-binary"
	// +optional
	name string,
	// The file to add
	path *dagger.File,
	// the material type of the evidence https://docs.chainloop.dev/concepts/material-types#material-types
	// if not provided it will either be loaded from the contract or inferred automatically
	// +optional
	kind string,
	// List of annotations to be attached to the evidence for example:
	// "key1=value1,key2=value2"
	// +optional
	annotations []string,
	// Skip strict schema validation for structured materials (SBOM_CYCLONEDX_JSON, OPENAPI_SPEC, ASYNCAPI_SPEC, OSSF_SCORECARD_JSON)
	// +optional
	noStrictValidation bool,
	// Enable debug logging
	// +optional
	debugMode bool,
)

Source from the content-addressed store, hash-verified

484
485// Add a file type piece of evidence to the attestation
486func (att *Attestation) AddFileEvidence(
487 ctx context.Context,
488 // Evidence name. Don't pass a name if the material
489 // being attested is not part of the contract
490 // Example: "my-binary"
491 // +optional
492 name string,
493 // The file to add
494 path *dagger.File,
495 // the material type of the evidence https://docs.chainloop.dev/concepts/material-types#material-types
496 // if not provided it will either be loaded from the contract or inferred automatically
497 // +optional
498 kind string,
499 // List of annotations to be attached to the evidence for example:
500 // "key1=value1,key2=value2"
501 // +optional
502 annotations []string,
503 // Skip strict schema validation for structured materials (SBOM_CYCLONEDX_JSON, OPENAPI_SPEC, ASYNCAPI_SPEC, OSSF_SCORECARD_JSON)
504 // +optional
505 noStrictValidation bool,
506 // Enable debug logging
507 // +optional
508 debugMode bool,
509) (*Attestation, error) {
510 filename, err := path.Name(ctx)
511 if err != nil {
512 return att, err
513 }
514
515 mountPath := "/tmp/attestation/" + filename
516
517 args := []string{
518 "attestation", "add",
519 "--attestation-id", att.AttestationID,
520 "--value", mountPath,
521 }
522
523 for _, annotation := range annotations {
524 args = append(args,
525 "--annotation", annotation,
526 )
527 }
528
529 if kind != "" {
530 args = append(args,
531 "--kind", kind,
532 )
533 }
534
535 if name != "" {
536 args = append(args,
537 "--name", name,
538 )
539 }
540
541 if noStrictValidation {
542 args = append(args, "--no-strict-validation")
543 }

Callers

nothing calls this directly

Calls 3

ContainerMethod · 0.95
SyncMethod · 0.80
NameMethod · 0.45

Tested by

no test coverage detected