Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/cli/cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ Supports multi-document YAML files. Each document must have a 'kind' field.`,
}

for _, r := range results {
status := "applied"
if r.Unchanged {
status = "unchanged"
status := "unchanged"
if r.Changed {
status = "applied"
}
logger.Info().Msgf("%s/%s %s", r.Kind, r.Name, status)
}
Expand Down
10 changes: 5 additions & 5 deletions app/cli/cmd/workflow_contract_apply.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2025 The Chainloop Authors.
// Copyright 2025-2026 The Chainloop Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -48,14 +48,14 @@ or update it if it already exists.`,
desc = &description
}

res, unchanged, err := action.NewWorkflowContractApply(ActionOpts).Run(cmd.Context(), contractName, contractPath, desc, projectName)
res, changed, err := action.NewWorkflowContractApply(ActionOpts).Run(cmd.Context(), contractName, contractPath, desc, projectName)
if err != nil {
return err
}

status := "applied"
if unchanged {
status = "unchanged"
status := "unchanged"
if changed {
status = "applied"
}
logger.Info().Msgf("Contract/%s %s", contractName, status)
return output.EncodeOutput(flagOutputFormat, res, contractItemTableOutput)
Expand Down
12 changes: 6 additions & 6 deletions app/cli/pkg/action/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ const (

// ApplyResult holds the outcome of a successfully applied resource document
type ApplyResult struct {
Kind string
Name string
Unchanged bool
Kind string
Name string
Changed bool
}

// YAMLDoc holds a parsed YAML document with its kind and raw bytes
Expand Down Expand Up @@ -70,11 +70,11 @@ func (a *Apply) Run(ctx context.Context, path string) ([]*ApplyResult, error) {
for _, doc := range docs {
switch doc.Kind {
case KindContract:
unchanged, err := ApplyContractFromRawData(ctx, a.cfg.CPConnection, doc.RawData)
changed, err := ApplyContractFromRawData(ctx, a.cfg.CPConnection, doc.RawData)
if err != nil {
return results, fmt.Errorf("%s/%s: %w", doc.Kind, doc.Name, err)
}
results = append(results, &ApplyResult{Kind: doc.Kind, Name: doc.Name, Unchanged: unchanged})
results = append(results, &ApplyResult{Kind: doc.Kind, Name: doc.Name, Changed: changed})
default:
return results, fmt.Errorf("unsupported kind %q", doc.Kind)
}
Expand Down Expand Up @@ -124,7 +124,7 @@ func ApplyContractFromRawData(ctx context.Context, conn *grpc.ClientConn, rawDat
return false, fmt.Errorf("failed to apply contract: %w", err)
}

return resp.GetUnchanged(), nil
return resp.GetChanged(), nil
}

// CollectYAMLFiles returns YAML file paths from the given path.
Expand Down
8 changes: 4 additions & 4 deletions app/cli/pkg/action/workflow_contract_apply.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2025 The Chainloop Authors.
// Copyright 2025-2026 The Chainloop Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -64,9 +64,9 @@ func (action *WorkflowContractApply) Run(ctx context.Context, contractName strin
return nil, false, fmt.Errorf("failed to update existing contract '%s': %w", contractName, err)
}

unchanged := prevRevision == res.Result.GetRevision().GetRevision()
changed := prevRevision != res.Result.GetRevision().GetRevision()

return pbWorkflowContractItemToAction(res.Result.Contract), unchanged, nil
return pbWorkflowContractItemToAction(res.Result.Contract), changed, nil
Comment thread
Piskoo marked this conversation as resolved.
}

// Contract doesn't exist, perform create
Expand All @@ -87,5 +87,5 @@ func (action *WorkflowContractApply) Run(ctx context.Context, contractName strin
return nil, false, fmt.Errorf("failed to create new contract '%s': %w", contractName, err)
}

return pbWorkflowContractItemToAction(res.Result), false, nil
return pbWorkflowContractItemToAction(res.Result), true, nil
}
23 changes: 18 additions & 5 deletions app/controlplane/api/controlplane/v1/workflow_contract.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions app/controlplane/api/controlplane/v1/workflow_contract.proto
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ message WorkflowContractServiceApplyRequest {

message WorkflowContractServiceApplyResponse {
WorkflowContractItem result = 1;
// Whether the resource was unchanged
bool unchanged = 2;
// Deprecated: use changed instead
bool unchanged = 2 [deprecated = true];
// Whether the resource was changed
bool changed = 3;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions app/controlplane/internal/service/workflowcontract.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2024-2025 The Chainloop Authors.
// Copyright 2024-2026 The Chainloop Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -276,8 +276,8 @@ func (s *WorkflowContractService) Apply(ctx context.Context, req *pb.WorkflowCon
}

return &pb.WorkflowContractServiceApplyResponse{
Result: bizWorkFlowContractToPb(schemaWithVersion.Contract),
Unchanged: schemaWithVersion.Unchanged,
Result: bizWorkFlowContractToPb(schemaWithVersion.Contract),
Changed: schemaWithVersion.Changed,
Comment thread
Piskoo marked this conversation as resolved.
}, nil
}

Expand All @@ -304,7 +304,7 @@ func (s *WorkflowContractService) Apply(ctx context.Context, req *pb.WorkflowCon
return nil, handleUseCaseErr(err, s.log)
}

return &pb.WorkflowContractServiceApplyResponse{Result: bizWorkFlowContractToPb(schema)}, nil
return &pb.WorkflowContractServiceApplyResponse{Result: bizWorkFlowContractToPb(schema), Changed: true}, nil
}

func (s *WorkflowContractService) Delete(ctx context.Context, req *pb.WorkflowContractServiceDeleteRequest) (*pb.WorkflowContractServiceDeleteResponse, error) {
Expand Down
12 changes: 6 additions & 6 deletions app/controlplane/pkg/biz/workflowcontract.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ func (c *Contract) isV1Schema() bool {
}

type WorkflowContractWithVersion struct {
Contract *WorkflowContract
Version *WorkflowContractVersion
Unchanged bool
Contract *WorkflowContract
Version *WorkflowContractVersion
Changed bool
}

type WorkflowContractRepo interface {
Expand Down Expand Up @@ -426,15 +426,15 @@ func (uc *WorkflowContractUseCase) Update(ctx context.Context, orgID, name strin
}

// Check if the revisions have changed
unchanged := wfContractPreUpdate.LatestRevision == c.Version.Revision
if !unchanged {
changed := wfContractPreUpdate.LatestRevision != c.Version.Revision
if changed {
eventPayload.NewRevision = &c.Version.Revision
eventPayload.NewRevisionID = &c.Version.ID
}

uc.auditorUC.Dispatch(ctx, eventPayload, &orgUUID)

c.Unchanged = unchanged
c.Changed = changed

return c, nil
}
Expand Down
Loading