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

Improve GetOutboundIP to work without internet access #1707

Merged
merged 2 commits into from
Mar 31, 2023

Conversation

wolfogre
Copy link
Member

If the machine cannot access the internet, it returns a preferred IP address from network interfaces.

@wolfogre wolfogre requested a review from a team as a code owner March 28, 2023 09:41
Copy link
Member

@KnisterPeter KnisterPeter left a comment

Choose a reason for hiding this comment

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

🥳
Thanks

@codecov
Copy link

codecov bot commented Mar 28, 2023

Codecov Report

Merging #1707 (c9e4062) into master (4989f44) will increase coverage by 1.29%.
The diff coverage is 70.32%.

@@            Coverage Diff             @@
##           master    #1707      +/-   ##
==========================================
+ Coverage   61.22%   62.52%   +1.29%     
==========================================
  Files          46       48       +2     
  Lines        7141     7519     +378     
==========================================
+ Hits         4372     4701     +329     
- Misses       2462     2498      +36     
- Partials      307      320      +13     
Impacted Files Coverage Δ
pkg/common/outbound_ip.go 0.00% <0.00%> (ø)
pkg/container/docker_cli.go 82.23% <ø> (ø)
pkg/container/docker_logger.go 52.08% <ø> (ø)
pkg/container/docker_pull.go 33.33% <ø> (ø)
pkg/container/docker_run.go 14.08% <0.00%> (+0.49%) ⬆️
pkg/container/docker_volume.go 0.00% <ø> (ø)
pkg/container/file_collector.go 37.30% <0.00%> (ø)
pkg/container/host_environment.go 0.00% <0.00%> (ø)
pkg/exprparser/functions.go 66.32% <0.00%> (-1.04%) ⬇️
pkg/model/workflow.go 42.11% <ø> (ø)
... and 21 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more


return localAddr.IP
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the caller will still crash the cli prog if you return nil here. The caller does an unconditional .String() in the help text..

The cli could use 127.0.0.1 or [::1] as bind address in this case, but may better fit on the caller side.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's safe to call (net.IP)(nil).String().

And if the caller really don't want a nil, it can check the return.

@mergify mergify bot merged commit 8518d70 into nektos:master Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants