-
Notifications
You must be signed in to change notification settings - Fork 80
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
Remove github.com/packethost/pkg/env
dependency
#324
Conversation
github.com/packethost/pkg/env
dependency
Codecov Report
@@ Coverage Diff @@
## main #324 +/- ##
===================================
- Coverage 19% 18% -2%
===================================
Files 19 17 -2
Lines 1140 1073 -67
===================================
- Hits 222 197 -25
+ Misses 903 862 -41
+ Partials 15 14 -1
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Reorganize files and functionality to live with packages that have the same util. This enables isolating functionality and is a step toward completely removing global variables used in the conf package. Signed-off-by: Jacob Weinstock <[email protected]>
Signed-off-by: Jacob Weinstock <[email protected]>
Reorganize code to be able to remove the packethost/pkg/env dependency. The idea is to follow up with a refactor to clean up the cmd/boot/ package to handle cli flags and env vars in a uniform way. Signed-off-by: Jacob Weinstock <[email protected]>
Signed-off-by: Jacob Weinstock <[email protected]>
Signed-off-by: Jacob Weinstock <[email protected]>
Signed-off-by: Jacob Weinstock <[email protected]>
Some required values were not being passed into the ipxe.Handler struct. Signed-off-by: Jacob Weinstock <[email protected]>
8a111d1
to
e0d3b96
Compare
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 suspect, given the intent to refactor more holistically, the comments aren't really worth addressing.
err = errors.New("unable to auto-detect public IPv4") | ||
panic(err) |
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.
err = errors.New("unable to auto-detect public IPv4") | |
panic(err) | |
panic("unable to auto-detect public IPv4") |
err := errors.New("PUBLIC_SYSLOG_IP must be an IPv4 address") | ||
panic(err) |
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.
err := errors.New("PUBLIC_SYSLOG_IP must be an IPv4 address") | |
panic(err) | |
panic("PUBLIC_SYSLOG_IP must be an IPv4 address") |
for _, oui := range slice { | ||
_, err := net.ParseMAC(oui + ":00:00:00") | ||
if err != nil { | ||
panic(errors.Errorf("invalid oui in TINK_IGNORED_OUIS oui=%s", oui)) |
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.
Should this be panicking?
err := errors.New("PUBLIC_IP must be an IPv4 address") | ||
panic(err) |
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.
err := errors.New("PUBLIC_IP must be an IPv4 address") | |
panic(err) | |
panic("PUBLIC_IP must be an IPv4 address") |
i, err := strconv.Atoi(v) | ||
if err != nil { | ||
err = errors.Wrap(err, "failed to parse int from env var") | ||
panic(err) |
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.
Should this be panicking?
} | ||
} else { | ||
// not an IP, panic | ||
panic("invalid ip cidr in TRUSTED_PROXIES cidr=" + cidr) |
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.
Should this be panicking?
ignore := map[string]struct{}{} | ||
for _, ip := range slice { | ||
if net.ParseIP(ip) == nil { | ||
panic(errors.Errorf("invalid ip address in TINK_IGNORED_GIS ip=%s", ip)) |
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.
Should this be panicking?
Yeah, exactly. I have another PR thats in the works to clean up all of this. Thanks for the review! |
Description
Remove
github.com/packethost/pkg/env
dependency and remove unused code. While I tried to stay away from as much refactoring as possible, there is some in here that was needed in order to remove thegithub.com/packethost/pkg/env
dependency. Other than this, code was moved around to decrease the cognitive load of understanding this code base and prepare us for a more holistic refactor that will include the deprecation ofgithub.com/packethost/dhcp4-go
andgithub.com/packethost/pkg
entirely.Why is this needed
Fixes: #
How Has This Been Tested?
Will be doing some manual testing with the Helm chart. Will update here with the results, once complete.
How are existing users impacted? What migration steps/scripts do we need?
Checklist:
I have: