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

cmd/bpf2go: read more flags from environment #1284

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

Conversation

Puqns67
Copy link

@Puqns67 Puqns67 commented Dec 31, 2023

No description provided.

@Puqns67 Puqns67 requested a review from a team as a code owner December 31, 2023 12:55
Copy link
Collaborator

@ti-mo ti-mo left a comment

Choose a reason for hiding this comment

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

Thanks for the patch! Left a small nit, and would like @lmb's sign-off on this as well.

cmd/bpf2go/main.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@lmb lmb left a comment

Choose a reason for hiding this comment

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

Left some questions. Could you extend the unit tests in main_test.go to cover the new variables?

cmd/bpf2go/main.go Outdated Show resolved Hide resolved
cmd/bpf2go/main.go Outdated Show resolved Hide resolved
cmd/bpf2go/main.go Outdated Show resolved Hide resolved
cmd/bpf2go/main.go Outdated Show resolved Hide resolved
Signed-off-by: Puqns67 <me@puqns67.icu>
if !ok {
return defaultVal
}
result, _ := strconv.ParseBool(val)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This error should be surfaced to the user, otherwise incorrect settings like NO_STRIP=gobbledigook will silently disable stripping.

Copy link
Author

Choose a reason for hiding this comment

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

This error should be surfaced to the user, otherwise incorrect settings like NO_STRIP=gobbledigook will silently disable stripping.

I made some of these changes, what do you think?

Suggested change
result, _ := strconv.ParseBool(val)
result, err := strconv.ParseBool(val)
if err != nil {
fmt.Fprintf(os.Stderr, "Warning: The value '%s' passed from environment variable '%s' is undefined in strconv.ParseBool, using default value (%t).\n", val, key, defaultVal)
return defaultVal
}

What else should I change?
Do I need to use b2g.stdout instead of os.Stderr? (Need to add a parameter to pass writer)

Copy link
Collaborator

Choose a reason for hiding this comment

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

A warning is nice, what about just returning the error from the function instead? That means you need to add a separate block to add it to run() but that isn't so bad in my opinion.

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.

None yet

3 participants