Skip to content

Conversation

@kradalby
Copy link
Collaborator

@kradalby kradalby commented May 2, 2025

add a cli check command that tries to read in the policy and reports errors.

@kradalby kradalby requested a review from juanfont as a code owner May 2, 2025 07:25
@ghost
Copy link

ghost commented May 2, 2025

Pull Request Revisions

RevisionDescription
r2
Added policy check CLI commandIntroduced a new headscale policy check command to validate policy configuration files
r1
Added policy file check commandImplemented a new CLI command to validate policy files with required file flag and error handling

✅ AI review completed for r2
Help React with emojis to give feedback on AI-generated reviews:
  • 👍 means the feedback was helpful and actionable
  • 👎 means the feedback was incorrect or unhelpful
💬 Replying to feedback with a comment helps us improve the system. Your input also contributes to shaping future interactions with the AI reviewer.

We'd love to hear from you—reach out anytime at [email protected].

Signed-off-by: Kristoffer Dalby <[email protected]>
@kradalby kradalby force-pushed the kradalby/pol-check-cli branch from 3116fa0 to 247e089 Compare May 2, 2025 07:27
Comment on lines +104 to +112
if err != nil {
ErrorOutput(err, fmt.Sprintf("Error opening the policy file: %s", err), output)
}
defer f.Close()

policyBytes, err := io.ReadAll(f)
if err != nil {
ErrorOutput(err, fmt.Sprintf("Error reading the policy file: %s", err), output)
}
Copy link

Choose a reason for hiding this comment

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

The checkPolicy command should return after calling ErrorOutput on line 105 and 111 to prevent execution from continuing after an error occurs. Otherwise, subsequent operations might panic when operating on invalid data.

@kradalby kradalby merged commit 93afb03 into juanfont:main May 2, 2025
141 of 144 checks passed
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