-
Notifications
You must be signed in to change notification settings - Fork 3
fix: update repo structure validation logic to disallow false positives #10
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
Conversation
chore: update README files and validation to reflect new requirements
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.
😎
cmd/readmevalidation/readmeFiles.go
Outdated
// separateFrontmatter attempts to separate a README file's frontmatter content | ||
// from the main README body, returning both values in that order. It does not | ||
// validate whether the structure of the frontmatter is valid (i.e., that it's | ||
// structured as YAML). |
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.
Looks good!
cmd/readmevalidation/readmeFiles.go
Outdated
const ( | ||
// validationPhaseFileStructureValidation indicates when the entire Registry | ||
// directory is being verified for having all files be placed in the file | ||
// system as expected. | ||
validationPhaseFileStructureValidation validationPhase = iota | ||
|
||
// validationPhaseFileLoad indicates when README files are being read from | ||
// the file system | ||
validationPhaseFileLoad | ||
|
||
// validationPhaseReadmeParsing indicates when a README's frontmatter is | ||
// being parsed as YAML. This phase does not include YAML validation. | ||
validationPhaseReadmeParsing | ||
|
||
// validationPhaseReadmeValidation indicates when a README's frontmatter is | ||
// being validated as proper YAML with expected keys. | ||
validationPhaseReadmeValidation | ||
|
||
// validationPhaseAssetCrossReference indicates when a README's frontmatter | ||
// is having all its relative URLs be validated for whether they point to | ||
// valid resources. | ||
validationPhaseAssetCrossReference | ||
) |
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 know this is common, but I personally prefer to use a string type for validationPhase
and forgo the iota. You then don't need to convert to string with .String()
and instead can just do string(phase)
when needed.
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.
Yeah, I think my main worry with it was that it felt like the string approach meant that the custom type couldn't have a valid/meaningful zero value. Like, if I use custom strings for the main options, it's still possible to make a zero value version of the field, even though it shouldn't exist. Iota at least makes it so that the zero value is still valid (and represents the base role)
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'm going to go ahead with the current changes, but I'll bring it up in our 1:1. If you think it's still worth switching to strings, I can make a separate PR
@@ -3,5 +3,5 @@ display_name: Nataindata | |||
bio: Data engineer | |||
github: nataindata | |||
website: https://www.nataindata.com | |||
status: community | |||
status: partner |
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.
👍
Splitting up the main validation PR I've got cooking up, so that it's easier to review.
Changes made
/modules
directory, which the new checks did catch)cmd
directory structureextractFrontmatter
intoseparateFrontmatter
– now returns out the frontmatter, as well as the README bodylog.Panic
calls