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

pathpolicy: tweak error messages and add test #853

Merged
merged 3 commits into from
Aug 12, 2024

Conversation

mvo5
Copy link
Contributor

@mvo5 mvo5 commented Aug 12, 2024

Trivial tweak for the errors returned from PathPolicies.Check() so that they are a bit more user friendly.

See also osbuild/bootc-image-builder#601

Trivial tweak for the errors returned from PathPolicies.Check()
so that they are a bit more user friendly.

See also osbuild/bootc-image-builder#601
achilleas-k
achilleas-k previously approved these changes Aug 12, 2024
@achilleas-k
Copy link
Member

These messages never reach the user. We run through them when checking the blueprint and list the ones that failed to validate without giving a specific:

// CheckMountpointsPolicy checks if the mountpoints are allowed by the policy
func CheckMountpointsPolicy(mountpoints []FilesystemCustomization, mountpointAllowList *pathpolicy.PathPolicies) error {
invalidMountpoints := []string{}
for _, m := range mountpoints {
err := mountpointAllowList.Check(m.Mountpoint)
if err != nil {
invalidMountpoints = append(invalidMountpoints, m.Mountpoint)
}
}
if len(invalidMountpoints) > 0 {
return fmt.Errorf("The following custom mountpoints are not supported %+q", invalidMountpoints)
}
return nil
}

We should also make a similar change to what you proposed on osbuild/bootc-image-builder#601 (comment)

Small tweak to the way the error from CheckMountpointsPolicy is
constructed to include the details from the pathpolicy errors.

Thanks to Achilleas
@mvo5
Copy link
Contributor Author

mvo5 commented Aug 12, 2024

These messages never reach the user. We run through them when checking the blueprint and list the ones that failed to validate without giving a specific:
[..]
We should also make a similar change to what you proposed on osbuild/bootc-image-builder#601 (comment)

Thank you! Nice catch! I updated this PR to also include the improved error.

achilleas-k
achilleas-k previously approved these changes Aug 12, 2024
Copy link
Member

@achilleas-k achilleas-k left a comment

Choose a reason for hiding this comment

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

Wonderful!

@achilleas-k achilleas-k enabled auto-merge August 12, 2024 10:57
@achilleas-k achilleas-k added this pull request to the merge queue Aug 12, 2024
Copy link
Member

@ondrejbudai ondrejbudai left a comment

Choose a reason for hiding this comment

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

Yay!

Merged via the queue into osbuild:main with commit 7964ba1 Aug 12, 2024
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants