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

🎨 Improve the structure of some internal packages #441

Merged
merged 3 commits into from
Feb 13, 2025

Conversation

mcncl
Copy link
Contributor

@mcncl mcncl commented Feb 13, 2025

Changes

  • We have moved scopes to our validation package
  • We have split our validation package out for clarity/easy addition of rules
  • We test the validation works
  • Because of this, we needed to adjust our build internals
  • Adds a view package to our /internal/build, which contains the individual focuses of the build package

Comment on lines +22 to +25
v.AddRule("Organization", validation.Required)
v.AddRule("Organization", validation.Slug)
v.AddRule("Pipeline", validation.Required)
v.AddRule("Pipeline", validation.Slug)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an example of how we can add validation to commands


// Add artifacts if present
if len(v.Artifacts) > 0 {
sections = append(sections, v.renderArtifacts())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Our rendering functions are now split out in to their own files, so this can be cleaner and we can just add more if needed

Comment on lines +3 to +5
type Rule interface {
Validate(value interface{}) error
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A Rule just needs to have a function, Validate which takes in a value of any type and returns an error

@mcncl mcncl marked this pull request as ready for review February 13, 2025 04:32
Copy link
Contributor

@PriyaSudip PriyaSudip left a comment

Choose a reason for hiding this comment

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

Looks good, could you fix the failing pipeline so we can go ahead

@mcncl mcncl requested a review from PriyaSudip February 13, 2025 04:55
@mcncl mcncl merged commit dfc5722 into main Feb 13, 2025
1 check passed
@mcncl mcncl deleted the bm/validation_structure branch February 13, 2025 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants