Skip to content

Commit 282c7ae

Browse files
committed
add skip_upload capability to contract
1 parent 6e08b89 commit 282c7ae

File tree

14 files changed

+387
-317
lines changed

14 files changed

+387
-317
lines changed

app/cli/cmd/attestation_add.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ func displayMaterialInfo(status *action.AttestationStatusMaterial, policyEvaluat
171171

172172
mt := output.NewTableWriter()
173173

174-
mt.AppendRow(table.Row{"Name", status.Material.Name})
175-
mt.AppendRow(table.Row{"Type", status.Material.Type})
174+
mt.AppendRow(table.Row{"Name", status.Name})
175+
mt.AppendRow(table.Row{"Type", status.Type})
176176
mt.AppendRow(table.Row{"Required", hBool(status.Required)})
177177

178178
if status.IsOutput {
@@ -191,9 +191,9 @@ func displayMaterialInfo(status *action.AttestationStatusMaterial, policyEvaluat
191191
mt.AppendRow(table.Row{"Digest", status.Hash})
192192
}
193193

194-
if len(status.Material.Annotations) > 0 {
194+
if len(status.Annotations) > 0 {
195195
mt.AppendRow(table.Row{"Annotations", "------"})
196-
for _, a := range status.Material.Annotations {
196+
for _, a := range status.Annotations {
197197
value := a.Value
198198
if value == "" {
199199
value = NotSet

app/cli/cmd/attestation_status.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ func materialsTable(status *action.AttestationStatusResult, w io.Writer, full bo
202202
if m.IsOutput {
203203
mt.AppendRow(table.Row{"Is output", "Yes"})
204204
}
205+
if m.SkipUpload {
206+
mt.AppendRow(table.Row{"Skip upload", "Yes"})
207+
}
205208

206209
if full {
207210
if m.Value != "" {

app/cli/pkg/action/attestation_add.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ var ErrAttestationNotInitialized = errors.New("attestation not yet initialized")
7575

7676
func (action *AttestationAdd) Run(ctx context.Context, attestationID, materialName, materialValue, materialType string, annotations map[string]string) (*AttestationStatusMaterial, error) {
7777
// initialize the crafter. If attestation-id is provided we assume the attestation is performed using remote state
78-
crafter, err := newCrafter(&newCrafterStateOpts{enableRemoteState: (attestationID != ""), localStatePath: action.localStatePath}, action.CPConnection, action.newCrafterOpts.opts...)
78+
crafter, err := newCrafter(&newCrafterStateOpts{enableRemoteState: (attestationID != ""), localStatePath: action.localStatePath}, action.CPConnection, action.opts...)
7979
if err != nil {
8080
return nil, fmt.Errorf("failed to load crafter: %w", err)
8181
}
@@ -183,7 +183,7 @@ func (action *AttestationAdd) Run(ctx context.Context, attestationID, materialNa
183183

184184
// GetPolicyEvaluations is a Wrapper around the getPolicyEvaluations
185185
func (action *AttestationAdd) GetPolicyEvaluations(ctx context.Context, attestationID string) (map[string][]*PolicyEvaluation, error) {
186-
crafter, err := newCrafter(&newCrafterStateOpts{enableRemoteState: (attestationID != ""), localStatePath: action.localStatePath}, action.CPConnection, action.newCrafterOpts.opts...)
186+
crafter, err := newCrafter(&newCrafterStateOpts{enableRemoteState: (attestationID != ""), localStatePath: action.localStatePath}, action.CPConnection, action.opts...)
187187
if err != nil {
188188
return nil, fmt.Errorf("failed to load crafter: %w", err)
189189
}

app/cli/pkg/action/attestation_init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (action *AttestationInit) Run(ctx context.Context, opts *AttestationInitRun
9999
}
100100

101101
action.Logger.Debug().Msg("Retrieving attestation definition")
102-
client := pb.NewAttestationServiceClient(action.ActionsOpts.CPConnection)
102+
client := pb.NewAttestationServiceClient(action.CPConnection)
103103

104104
req := &pb.FindOrCreateWorkflowRequest{
105105
ProjectName: opts.ProjectName,

app/cli/pkg/action/attestation_push.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func NewAttestationPush(cfg *AttestationPushOpts) (*AttestationPush, error) {
8181
func (action *AttestationPush) Run(ctx context.Context, attestationID string, runtimeAnnotations map[string]string, bypassPolicyCheck bool) (*AttestationResult, error) {
8282
useRemoteState := attestationID != ""
8383
// initialize the crafter. If attestation-id is provided we assume the attestation is performed using remote state
84-
crafter, err := newCrafter(&newCrafterStateOpts{enableRemoteState: useRemoteState, localStatePath: action.localStatePath}, action.CPConnection, action.newCrafterOpts.opts...)
84+
crafter, err := newCrafter(&newCrafterStateOpts{enableRemoteState: useRemoteState, localStatePath: action.localStatePath}, action.CPConnection, action.opts...)
8585
if err != nil {
8686
return nil, fmt.Errorf("failed to load crafter: %w", err)
8787
}

app/cli/pkg/action/attestation_reset.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func NewAttestationReset(cfg *AttestationResetOpts) (*AttestationReset, error) {
4646

4747
func (action *AttestationReset) Run(ctx context.Context, attestationID, trigger, reason string) error {
4848
// initialize the crafter. If attestation-id is provided we assume the attestation is performed using remote state
49-
crafter, err := newCrafter(&newCrafterStateOpts{enableRemoteState: attestationID != "", localStatePath: action.localStatePath}, action.CPConnection, action.newCrafterOpts.opts...)
49+
crafter, err := newCrafter(&newCrafterStateOpts{enableRemoteState: attestationID != "", localStatePath: action.localStatePath}, action.CPConnection, action.opts...)
5050
if err != nil {
5151
return fmt.Errorf("failed to load crafter: %w", err)
5252
}
@@ -81,9 +81,10 @@ func (action *AttestationReset) Run(ctx context.Context, attestationID, trigger,
8181
}
8282

8383
func parseTrigger(in string) pb.AttestationServiceCancelRequest_TriggerType {
84-
if in == AttestationResetTriggerFailed {
84+
switch in {
85+
case AttestationResetTriggerFailed:
8586
return pb.AttestationServiceCancelRequest_TRIGGER_TYPE_FAILURE
86-
} else if in == AttestationResetTriggerCancelled {
87+
case AttestationResetTriggerCancelled:
8788
return pb.AttestationServiceCancelRequest_TRIGGER_TYPE_CANCELLATION
8889
}
8990

app/cli/pkg/action/attestation_status.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ type AttestationStatusWorkflowMeta struct {
7575

7676
type AttestationStatusMaterial struct {
7777
*Material
78-
Set, IsOutput, Required bool
78+
Set, IsOutput, Required, SkipUpload bool
7979
}
8080

8181
func NewAttestationStatus(cfg *AttestationStatusOpts) (*AttestationStatus, error) {
@@ -264,7 +264,7 @@ func populateContractMaterials(inputSchemaMaterials []*pbc.CraftingSchema_Materi
264264
Name: m.Name, Type: m.Type.String(),
265265
Annotations: pbAnnotationsToAction(m.Annotations),
266266
},
267-
IsOutput: m.Output, Required: !m.Optional,
267+
IsOutput: m.Output, Required: !m.Optional, SkipUpload: m.SkipUpload,
268268
}
269269

270270
if cm, found := attsMaterial[m.Name]; found {

app/controlplane/api/gen/frontend/workflowcontract/v1/crafting_schema.ts

Lines changed: 21 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/api/gen/jsonschema/workflowcontract.v1.CraftingSchema.Material.jsonschema.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/api/gen/jsonschema/workflowcontract.v1.CraftingSchema.Material.schema.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)