-
Notifications
You must be signed in to change notification settings - Fork 285
feat: add ui_for_url expression function for generating Kargo UI URLs (#4585) #5244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: add ui_for_url expression function for generating Kargo UI URLs (#4585) #5244
Conversation
Signed-off-by: gkemhcs <gudikotieswarmani@gmail.com>
✅ Deploy Preview for docs-kargo-io ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| // UIForURL returns an expr.Option that provides a `ui_for_url()` function for use in expressions. | ||
| func UIForURL(uiBaseURL, project, stage string) expr.Option { | ||
| return expr.Function( | ||
| "ui_for_url", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use snake case for functions anywhere in else in the expressions. This should be lower camel case.
| targetStage = stageName | ||
| } | ||
|
|
||
| return fmt.Sprintf("%s/project/%s/stage/%s", uiBaseURL, project, targetStage), nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to only work for Stages.
We'd like to be able to do the same for Projects, Promotions, and Freight.
I'd like there to be separate functions for each of those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok sure @krancour will make it work for others also , and is below conventions ok for you while calling in yaml templates ?
Stage:-
{{ui_for_stage()}}
Freight:-
{{ui_for_freight()}}
If not, how should be the function names in yaml template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if something like linkForStage and linkForFreight would be a nicer fluent API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hiddeco already suggested good names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok sure , will implement accordingly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me know how can i construct the url for promotions as it can't be inferred from ui ?
Not sure what the UI has to do with this. That's not the source of any information.
As for how to actually get the Promotion's name, make the internal function that registers the expression function receive it as a parameter (same as you do with Project, Stage, etc.) and the expression function can close over it (same as it does for Project, Stage, etc.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: gkemhcs <gudikotieswarmani@gmail.com>
🎯 Overview
This Pr Resolves #4585 , implements the
ui_for_url()expression function as requested in issue #4585 to enable dynamic URL generation for Kargo UI resources in promotion expressions.🔧 Changes Made
Core Implementation
UIForURLfunction inpkg/expressions/function/functions.goui_for_url()orui_for_url(stageName)Secretfunction for context accessContext Integration
UIBaseURLto promotion context inpkg/promotion/evaluator.goctx.UIBaseURLavailable in all expressionsFunction Organization
PromotionOperationsto group promotion-specific functionsDataOperationsandFreightOperations📝 Usage Examples
Resolves: issue #4585
Related: This implementation addresses the exact use case described in the issue for Slack deployment notifications with dynamic UI links.