Skip to content

[Stage Plugins] Avoid hard coding of Metadata Keys #5979

Closed
t-kikuc wants to merge 5 commits into
masterfrom
plugin/command/metadata-key-refine
Closed

[Stage Plugins] Avoid hard coding of Metadata Keys #5979
t-kikuc wants to merge 5 commits into
masterfrom
plugin/command/metadata-key-refine

Conversation

@t-kikuc
Copy link
Copy Markdown
Member

@t-kikuc t-kikuc commented Jun 30, 2025

What this PR does:

  • Show the stage metadata by the common key MetadataKey_StageDisplay instead of SkippedBy and ApprovedBy
    • This will be used in k8s plugin too.
  • Add AuthorizedOperators in pipelineStage model for Approvers

Why we need it:

  • To suppress hard coding of SkippedBy,ApprovedBy, and Approvers
    • It reduces tightly-coupled code of web/server/piped/plugin

TODO:

In the SDK,

  • Add pkg/plugin/sdk/constants/constants.go with MetadataKey_StageDisplay
    usage:
import (
   constants "github.com/pipe-cd/piped-plugin-sdk-go/constants"
)

func executeStage(...){
 ...
 client.PutStageMetadata(ctx, constants.MetadataKey_StageDisplay, "Skipped by: user-A")
 ...
}
  • Add AuthorizedOperators to PipelineStage struct and toModel()
    usage:
func BuildPipelineSyncStages(...){
	for _, rs := range input.Request.Stages {
		stage := sdk.PipelineStage{
			Index:              rs.Index,
			Name:               rs.Name,
			Rollback:           false,
			Metadata:           map[string]string{},
			AvailableOperation: sdk.ManualOperationApproval,
                        AuthorizedOperators: ["user-1", "user-2"] // Get from the stage config
		}
		stages = append(stages, stage)
	}

Which issue(s) this PR fixes:

Part of #5367

Does this PR introduce a user-facing change?:

  • How are users affected by this change:
  • Is this breaking change:
  • How to migrate (if breaking change):

t-kikuc added 3 commits June 30, 2025 18:30
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 30, 2025

Codecov Report

Attention: Patch coverage is 18.18182% with 9 lines in your changes missing coverage. Please review.

Project coverage is 28.16%. Comparing base (b7555ad) to head (eeadb94).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
pkg/datastore/deploymentstore.go 0.00% 8 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5979      +/-   ##
==========================================
- Coverage   28.23%   28.16%   -0.08%     
==========================================
  Files         512      516       +4     
  Lines       55326    55904     +578     
==========================================
+ Hits        15620    15743     +123     
- Misses      38461    38908     +447     
- Partials     1245     1253       +8     
Flag Coverage Δ
. 23.21% <18.18%> (-0.01%) ⬇️
.-pkg-app-pipedv1-plugin-kubernetes 66.42% <ø> (ø)
.-pkg-app-pipedv1-plugin-kubernetes_multicluster 67.51% <ø> (ø)
.-pkg-app-pipedv1-plugin-wait 35.51% <ø> (ø)
.-pkg-plugin-sdk 50.89% <ø> (ø)
.-tool-actions-gh-release 19.23% <ø> (ø)
.-tool-actions-plan-preview 25.30% <ø> (?)
.-tool-codegen-protoc-gen-auth 0.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

t-kikuc added 2 commits June 30, 2025 19:11
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
@t-kikuc
Copy link
Copy Markdown
Member Author

t-kikuc commented Jul 1, 2025

Split into #5980 and #5981 for clarity.

@t-kikuc t-kikuc closed this Jul 1, 2025
@t-kikuc t-kikuc deleted the plugin/command/metadata-key-refine branch July 10, 2025 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant