-
Notifications
You must be signed in to change notification settings - Fork 604
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
Setup proxy environment variables from system settings #266
Conversation
This change is fully functional (afaict), but I'm still thinking about it's limitations: environment settings are "baked in" to the instance at the time it is created. So how do we deal with e.g. a laptop that is moving between a company office requiring certain proxies and a public Wifi setup, using a VPN? There is no way to update proxy settings even by stopping and restarting the instance, so maybe we need a different mechanism. |
One way to deal with this would be to re-create the cidata volume on each instance start. This would also allow you to e.g. edit the provisioning scripts, or the @AkihiroSuda what do you think? |
Aren’t we already always recreating cidata.iso ? |
Looks like it. When I tested last night, I didn't see changes to proxy settings after a restart. The only explanation I can come up with is that I ran But that's good, so maybe this PR is sufficient then. |
Given that we recreate cidata on each instance start, I think the PR is good as-is. |
pkg/sysprof/network_darwin.go
Outdated
Interface string `json:"interface"` | ||
DNS DNS `json:"DNS"` | ||
Interface string `json:"interface"` | ||
Proxies Proxies `json:"proxies"` |
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.
nit: json:”Proxies”
for consistency with other json fields
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.
Interesting! I didn't know that JSON marshalling will use a case-insensitive match if it can't find an exact match, which is why this still worked despite not having the right capitalization. Fixed.
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've left interface
lowercase because that is how it comes in from system_profiler
:
$ system_profiler SPNetworkDataType -json | jq -r '.SPNetworkDataType[0]|keys[]' | sort
DNS
Ethernet
IPv4
IPv6
Proxies
_name
dhcp
hardware
interface
ip_address
sleep_proxies
spnetwork_service_order
type
env.* settings from lima.yaml will override system settings. Process environment during instance creation override all. Signed-off-by: Jan Dubois <[email protected]>
PortForwards []PortForward `yaml:"portForwards,omitempty"` | ||
Networks []Network `yaml:"networks,omitempty"` | ||
Network NetworkDeprecated `yaml:"network,omitempty"` // DEPRECATED, use `networks` instead | ||
Env map[string]string `yaml:"env,omitempty"` |
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.
Why was *string changed to string?
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.
There was some reason, but I don't remember, and it no longer applies; I can easily change it back. Please confirm if you want me to do that!
I asked back in #195 (comment) why it was a *string
to begin with because I was having issues with them in templates elsewhere, but didn't receive a response.
So I'm still curious why it should be a *string
. Theoretically we could use nil
vs ""
to "unset" an environment variable, but that doesn't make much sense in /etc/environment
, so I still have no idea...
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.
So it doesn't matter because (1) we no longer pass y.Env
directly to the template, and (2) because we don't use printf
on the values, but if we did, here is the difference (using this template):
#LIMA-START
{{- range $key, $val := .Env}}
{{$key}}={{$val}}
{{printf "%s=%q" $key $val}}
{{- end}}
#LIMA-END
produces this output:
#LIMA-START
KEY=value"value
KEY=%!q(*string=0xc0001bb2a0)
#LIMA-END
which is what prejudices me against the *string
. 😸
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.
Thanks
Implement the changes suggested in #189 (comment).
env.*
settings fromlima.yaml
will override system settings.Process environment during instance creation override all.
Fixes #189 (comment)