Skip to content

Commit eac7c86

Browse files
authored
fix: remote state with no version (#1485)
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
1 parent 74da100 commit eac7c86

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

app/cli/cmd/attestation_status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ func hBool(b bool) string {
210210
// Version information to be shown during the attestation process
211211
// both during the process and at the end
212212
func versionStringAttestation(p *action.ProjectVersion, isPushed bool) string {
213-
if p.Version == "" {
213+
if p == nil || p.Version == "" {
214214
return ""
215215
}
216216

app/cli/internal/action/attestation_init.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,13 @@ func (action *AttestationInit) Run(ctx context.Context, opts *AttestationInitRun
125125
Project: workflow.GetProject(),
126126
Team: workflow.GetTeam(),
127127
SchemaRevision: strconv.Itoa(int(contractVersion.GetRevision())),
128-
Version: &clientAPI.ProjectVersion{
128+
}
129+
130+
if opts.ProjectVersion != "" {
131+
workflowMeta.Version = &clientAPI.ProjectVersion{
129132
Version: opts.ProjectVersion,
130133
MarkAsReleased: opts.ProjectVersionMarkAsReleased,
131-
},
134+
}
132135
}
133136

134137
action.Logger.Debug().Msg("workflow contract and metadata retrieved from the control plane")
@@ -169,7 +172,11 @@ func (action *AttestationInit) Run(ctx context.Context, opts *AttestationInitRun
169172
workflowRun := runResp.GetResult().GetWorkflowRun()
170173
workflowMeta.WorkflowRunId = workflowRun.GetId()
171174
workflowMeta.Organization = runResp.GetResult().GetOrganization()
172-
workflowMeta.Version.Prerelease = runResp.GetResult().GetWorkflowRun().Version.GetPrerelease()
175+
176+
if v := workflowMeta.Version; v != nil {
177+
workflowMeta.Version.Prerelease = runResp.GetResult().GetWorkflowRun().Version.GetPrerelease()
178+
}
179+
173180
action.Logger.Debug().Str("workflow-run-id", workflowRun.GetId()).Msg("attestation initialized in the control plane")
174181
attestationID = workflowRun.GetId()
175182
}

app/cli/internal/action/attestation_status.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,21 @@ func (action *AttestationStatus) Run(ctx context.Context, attestationID string)
104104
Project: workflowMeta.GetProject(),
105105
Team: workflowMeta.GetTeam(),
106106
ContractRevision: workflowMeta.GetSchemaRevision(),
107-
ProjectVersion: &ProjectVersion{
108-
Version: workflowMeta.GetVersion().GetVersion(),
109-
Prerelease: workflowMeta.Version.Prerelease,
110-
MarkAsReleased: workflowMeta.Version.MarkAsReleased,
111-
},
112107
},
113108
InitializedAt: toTimePtr(att.InitializedAt.AsTime()),
114109
DryRun: c.CraftingState.DryRun,
115110
Annotations: pbAnnotationsToAction(c.CraftingState.InputSchema.GetAnnotations()),
116111
IsPushed: action.isPushed,
117112
}
118113

114+
if v := workflowMeta.GetVersion(); v != nil {
115+
res.WorkflowMeta.ProjectVersion = &ProjectVersion{
116+
Version: v.GetVersion(),
117+
Prerelease: v.GetPrerelease(),
118+
MarkAsReleased: v.GetMarkAsReleased(),
119+
}
120+
}
121+
119122
// Let's perform the following steps in order to show all possible materials:
120123
// 1. Populate the materials that are defined in the contract schema
121124
// 2. Populate the materials that are not defined in the contract schema, added inline in the attestation

0 commit comments

Comments
 (0)