Skip to content

feat: consolidate Promotion construction in defaulting webhook#6215

Merged
krancour merged 5 commits into
akuity:mainfrom
krancour:krancour/promo-defaults-fix
Jun 22, 2026
Merged

feat: consolidate Promotion construction in defaulting webhook#6215
krancour merged 5 commits into
akuity:mainfrom
krancour:krancour/promo-defaults-fix

Conversation

@krancour

@krancour krancour commented May 3, 2026

Copy link
Copy Markdown
Member

Fixes #5126

API server endpoints and the Stage controller now submit minimal Promotions (Stage + Freight); the defaulting webhook unconditionally populates the name, steps, and vars from the referenced Stage's PromotionTemplate. As a result, kubectl-driven Promotion creation now behaves the same as creation via the UI or CLI.

This accomplished entirely by moving around existing logic. There's pretty much nothing new here.

@krancour krancour added this to the v1.11.0 milestone May 3, 2026
@krancour krancour self-assigned this May 3, 2026
@krancour krancour requested a review from a team as a code owner May 3, 2026 02:41
@krancour krancour added kind/bug Something isn't working as intended; If unsure that something IS a bug, start a discussion instead kind/enhancement An entirely new feature kind/refactor Non-functional changes to implementation details priority/normal This is the priority for most work area/kubernetes-webhooks Affects the server that handles Kargo-specific validations on behalf of the Kubernetes API server area/controller Affects the (main) controller area/api-server Affects Kargo's API server labels May 3, 2026
@netlify

netlify Bot commented May 3, 2026

Copy link
Copy Markdown

Deploy Preview for docs-kargo-io canceled.

Name Link
🔨 Latest commit 9efb14f
🔍 Latest deploy log https://app.netlify.com/projects/docs-kargo-io/deploys/6a3957e6096209000813548a

API server endpoints and the Stage controller now submit minimal
Promotions (Stage + Freight); the defaulting webhook unconditionally
populates the name, steps, and vars from the referenced Stage's
PromotionTemplate. As a result, kubectl-driven Promotion creation
now behaves the same as creation via the UI or CLI.

Closes akuity#5126.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Kent Rancourt <kent.rancourt@gmail.com>
@krancour krancour force-pushed the krancour/promo-defaults-fix branch from 3b4600d to 6152c3a Compare May 3, 2026 02:45
@codecov

codecov Bot commented May 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.90566% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.47%. Comparing base (84212de) to head (9efb14f).

Files with missing lines Patch % Lines
pkg/server/promote_downstream_v1alpha1.go 31.25% 6 Missing and 5 partials ⚠️
pkg/webhook/kubernetes/promotion/webhook.go 77.41% 3 Missing and 4 partials ⚠️
pkg/server/promote_to_stage_v1alpha1.go 25.00% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6215      +/-   ##
==========================================
- Coverage   58.49%   58.47%   -0.03%     
==========================================
  Files         501      500       -1     
  Lines       42194    42188       -6     
==========================================
- Hits        24682    24669      -13     
- Misses      16020    16024       +4     
- Partials     1492     1495       +3     

☔ View full report in Codecov by Harness.
📢 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.

@fuskovic fuskovic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All my findings are NITs. Didn't find anything critical/blocking.

Comment thread pkg/api/promotion.go Outdated
Comment thread pkg/api/promotion.go
Comment thread pkg/api/promotion.go
Comment thread pkg/api/promotion.go
krancour added 2 commits June 17, 2026 14:50
Signed-off-by: Kent Rancourt <kent.rancourt@gmail.com>
@krancour krancour enabled auto-merge June 17, 2026 19:11
krancour and others added 2 commits June 22, 2026 10:57
The Default webhook now rejects Promotions whose referenced Stage
defines no promotion steps. The long-stage-name test case used a bare
StageSpec{}, so it tripped that guard and returned early before
reaching the label-shortening logic it exercises. Give its fixture
Stage a PromotionTemplate with one step so the test verifies what it
intends to.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Kent Rancourt <kent.rancourt@gmail.com>
@krancour krancour added this pull request to the merge queue Jun 22, 2026
Merged via the queue into akuity:main with commit a08d810 Jun 22, 2026
17 of 18 checks passed
@krancour krancour deleted the krancour/promo-defaults-fix branch June 22, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api-server Affects Kargo's API server area/controller Affects the (main) controller area/kubernetes-webhooks Affects the server that handles Kargo-specific validations on behalf of the Kubernetes API server kind/bug Something isn't working as intended; If unsure that something IS a bug, start a discussion instead kind/enhancement An entirely new feature kind/refactor Non-functional changes to implementation details priority/normal This is the priority for most work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: make promotions defaulting webhook work as well as the promotion endpoints

2 participants