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

feature: cli support add --add-host #3025

Merged
merged 1 commit into from
Sep 7, 2020

Conversation

lang710
Copy link
Contributor

@lang710 lang710 commented Aug 19, 2020

Signed-off-by: Lang Chi 21860405@zju.edu.cn

Ⅰ. Describe what this PR did

feature: cli support --add-host
--add-host flag can be used to add additional lines to /etc/hosts.

This is a client flag for network setting, --add-host option can be used in host network mode. This option update /etc/hosts inside the container. No change are made to /etc/hosts on the host.

Ⅱ. Does this pull request fix one issue?

NONE.

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

Added.

Ⅳ. Describe how to verify it

root@compatibility:~# pouch run -it  busybox cat /etc/hosts
127.0.0.1	localhost
::1	localhost ip6-localhost ip6-loopback
fe00::0	ip6-localnet
ff00::0	ip6-mcastprefix
ff02::1	ip6-allnodes
ff02::2	ip6-allrouters
192.168.5.2	bee635290c2f


root@compatibility:~# pouch run -it --add-host=extra:1.2.3.4  busybox cat /etc/hosts
127.0.0.1	localhost
::1	localhost ip6-localhost ip6-loopback
fe00::0	ip6-localnet
ff00::0	ip6-mcastprefix
ff02::1	ip6-allnodes
ff02::2	ip6-allrouters
1.2.3.4	extra
192.168.5.2	1e4c791dbe8


root@compatibility:~# pouch run -it --add-host=extra:1.2.3.4  --add-host=extra2:2.3.4.5 busybox cat /etc/hosts
127.0.0.1	localhost
::1	localhost ip6-localhost ip6-loopback
fe00::0	ip6-localnet
ff00::0	ip6-mcastprefix
ff02::1	ip6-allnodes
ff02::2	ip6-allrouters
1.2.3.4	extra
2.3.4.5	extra2
192.168.5.2	1e4c791dbe8

Ⅴ. Special notes for reviews

--add-host option can be used in host network mode. Extra network config validation should be provided.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ZYecho
Copy link
Contributor

ZYecho commented Aug 19, 2020

lgtm

@ZYecho ZYecho requested a review from fuweid August 20, 2020 04:07
for _, extraHost := range endpoint.ExtraHosts {
// allow IPv6 addresses in extra hosts; only split on first ":"
parts := strings.SplitN(extraHost, ":", 2)
sandboxOptions = append(sandboxOptions, libnetwork.OptionExtraHost(parts[0], parts[1]))
Copy link
Contributor

Choose a reason for hiding this comment

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

if there is no : in extraHost?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LGTM, here should be some validation before appending the provided extra hosts, I'll fix it later, thx.

Signed-off-by: Lang Chi <21860405@zju.edu.cn>
@ZYecho
Copy link
Contributor

ZYecho commented Aug 28, 2020

@fuweid ptal

@lang710 lang710 requested a review from fuweid August 28, 2020 06:02
@ZYecho ZYecho merged commit bc5839e into AliyunContainerService:master Sep 7, 2020
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

5 participants