Skip to content
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

feat: Add support for uninitialized custom params #1898

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aThorp96
Copy link
Contributor

Changes

Add support for defining Custom Params in the Repository without any value, allowing the value to be supplied by the webhook. Add a new optional field required to the Custom Param, which enforces that the value is supplied via the webhook if not specified in the Repository.
If a Custom Param is defined without any value, no value is supplied in the payload, and it is not marked as required, then the param is omitted and the behaviour has no change from the current state. To this extent the feature is backwards compatible.

Documentation is not included yet in chase semantic changes are requested.

Submitter Checklist

  • 📝 Ensure your commit message is clear and informative. Refer to the How to write a git commit message guide. Include the commit message in the PR body rather than linking to an external site (e.g., Jira ticket).

  • ♽ Run make test lint before submitting a PR to avoid unnecessary CI processing. Consider installing pre-commit and running pre-commit install in the repository root for an efficient workflow.

  • ✨ We use linters to maintain clean and consistent code. Run make lint before submitting a PR. Some linters offer a --fix mode, executable with make fix-linters (ensure markdownlint and golangci-lint are installed).

  • 📖 Document any user-facing features or changes in behavior.

  • 🧪 While 100% coverage isn't required, we encourage unit tests for code changes where possible.

  • 🎁 If feasible, add an end-to-end test. See README for details.

  • 🔎 Address any CI test flakiness before merging, or provide a valid reason to bypass it (e.g., token rate limitations).

  • If adding a provider feature, fill in the following details:

Git Provider Supported
GitHub App ✅️
GitHub Webhook ❌️
Gitea ❌️
GitLab ❌️
Bitbucket Cloud ❌️
Bitbucket Server ❌️

(update the documentation accordingly)

@aThorp96 aThorp96 force-pushed the main branch 2 times, most recently from 63c9279 to 25e1f90 Compare January 30, 2025 22:56
@vdemeester vdemeester requested a review from chmouel January 31, 2025 16:11
@aThorp96 aThorp96 marked this pull request as ready for review February 5, 2025 14:59
@chmouel
Copy link
Member

chmouel commented Feb 5, 2025

You probably (is actually highly recommended since it checks for secret leaks and things like that) want to install pre-commit and do a pre-commit install to avoid those small iterations.

It would save a bit of the planet too by not having wasted CPU cycles :D

@chmouel
Copy link
Member

chmouel commented Feb 5, 2025

/assign @chmouel

@chmouel
Copy link
Member

chmouel commented Feb 5, 2025

(prow-commands failes cause it need a rebase with latest change)

@aThorp96
Copy link
Contributor Author

aThorp96 commented Feb 5, 2025

You probably want to install pre-commit

@chmouel indeed. I've been trying out jj-vcs instead of git but being unable to currently integrate jj with pre-commit may be a dealbreaker for now.

Copy link
Member

@chmouel chmouel left a comment

Choose a reason for hiding this comment

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

ret[value.Name] = value.Value
} else if value.SecretRef != nil {

_, paramIsStd := stdParams[value.Name]
Copy link
Member

Choose a reason for hiding this comment

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

should we check that the key in stdParams and parsedFromComment actually exist in there? (i am surprise golangci-lint didn't bug you about this)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what we're doing here, actually. At this point in the code we don't care about the value, just if the param exists in the stdParams and parsedFromCOmment maps, so we're checking the ok return-value instead of the map's value at that key.

When a Custom Param is defined without any value, it may still be
templated-in to the pipeline when a value is provided via a gitops comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants