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

Method Run

app/cli/pkg/action/attestation_status.go:96–180  ·  view source on GitHub ↗
(ctx context.Context, attestationID string)

Source from the content-addressed store, hash-verified

94}
95
96func (action *AttestationStatus) Run(ctx context.Context, attestationID string) (*AttestationStatusResult, error) {
97 c := action.c
98
99 if initialized, err := c.AlreadyInitialized(ctx, attestationID); err != nil {
100 return nil, fmt.Errorf("checking if attestation is already initialized: %w", err)
101 } else if !initialized {
102 return nil, ErrAttestationNotInitialized
103 }
104
105 if err := c.LoadCraftingState(ctx, attestationID); err != nil {
106 action.Logger.Err(err).Msg("loading existing attestation")
107 return nil, err
108 }
109
110 att := c.CraftingState.Attestation
111 workflowMeta := att.GetWorkflow()
112
113 res := &AttestationStatusResult{
114 AttestationID: workflowMeta.GetWorkflowRunId(),
115 WorkflowMeta: &AttestationStatusWorkflowMeta{
116 WorkflowID: workflowMeta.GetWorkflowId(),
117 Name: workflowMeta.GetName(),
118 Organization: workflowMeta.GetOrganization(),
119 Project: workflowMeta.GetProject(),
120 Team: workflowMeta.GetTeam(),
121 ContractRevision: workflowMeta.GetSchemaRevision(),
122 ContractName: workflowMeta.GetContractName(),
123 },
124 InitializedAt: toTimePtr(att.InitializedAt.AsTime()),
125 DryRun: c.CraftingState.DryRun,
126 Annotations: pbAnnotationsToAction(c.CraftingState.GetAnnotations()),
127 IsPushed: action.isPushed,
128 MustBlockOnPolicyViolations: att.GetBlockOnPolicyViolation(),
129 TimestampAuthority: att.GetSigningOptions().GetTimestampAuthorityUrl(),
130 }
131
132 // Read policy evaluations from crafting state (evaluation happens in init/push, not here)
133 res.PolicyEvaluations, res.HasPolicyViolations = getPolicyEvaluations(c)
134
135 if v := workflowMeta.GetVersion(); v != nil {
136 res.WorkflowMeta.ProjectVersion = &ProjectVersion{
137 Version: v.GetVersion(),
138 Prerelease: v.GetPrerelease(),
139 MarkAsReleased: v.GetMarkAsReleased(),
140 }
141 }
142
143 // Let's perform the following steps in order to show all possible materials:
144 // 1. Populate the materials that are defined in the contract schema
145 // 2. Populate the materials that are not defined in the contract schema, added inline in the attestation
146 // In order to avoid duplicates, we keep track of the visited materials
147 if err := populateMaterials(c.CraftingState.CraftingState, res); err != nil {
148 return nil, fmt.Errorf("populating materials: %w", err)
149 }
150
151 // User defined env variables
152 envVars := make(map[string]string)
153 for _, e := range c.CraftingState.GetEnvAllowList() {

Callers 3

RunMethod · 0.95
newAttestationStatusCmdFunction · 0.95
newAttestationInitCmdFunction · 0.95

Calls 15

pbAnnotationsToActionFunction · 0.85
getPolicyEvaluationsFunction · 0.85
populateMaterialsFunction · 0.85
AlreadyInitializedMethod · 0.80
LoadCraftingStateMethod · 0.80
GetSchemaRevisionMethod · 0.80
GetMarkAsReleasedMethod · 0.80
toTimePtrFunction · 0.70
GetNameMethod · 0.65
GetAnnotationsMethod · 0.65
ResolveEnvVarsMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected