Skip to content

Add spring funcs to agent and tools autoupdate URL template#51511

Closed
hugoShaka wants to merge 1 commit intomasterfrom
hugo/add-sprig-funcs-into-autoupdate-templates
Closed

Add spring funcs to agent and tools autoupdate URL template#51511
hugoShaka wants to merge 1 commit intomasterfrom
hugo/add-sprig-funcs-into-autoupdate-templates

Conversation

@hugoShaka
Copy link
Copy Markdown
Contributor

This PR adds sprig functions to the autoupdate URL template engine.

@hugoShaka hugoShaka added the no-changelog Indicates that a PR does not require a changelog entry label Jan 27, 2025
@hugoShaka hugoShaka requested review from sclevine and vapopov January 27, 2025 18:19
// We add sprig functions to have access to `semver` and be able to change the template in tests based on
// the version requested (e.g. pull pre-releases version from the dev repo, and official versions
// from the prod one).
tmpl, err := template.New("uri").Funcs(sprig.HermeticTxtFuncMap()).Parse(uriTmpl)
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.

We're removing the external template override in #51383, will that be a problem for this testing use case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This would require at least some way of passing a template and dynamically change the base-url depending on the build provenance.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need to use sprig at all?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For now we can add only semver and semverCompare to solve this use-case, but we'll have to document this somewhere. I can vendor the semver code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog Indicates that a PR does not require a changelog entry size/sm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants