Skip to content

daemon/config: move proxy settings to "proxies" struct within daemon.json#43448

Merged
thaJeztah merged 1 commit intomoby:masterfrom
thaJeztah:daemon_config_group_proxies
Apr 7, 2022
Merged

daemon/config: move proxy settings to "proxies" struct within daemon.json#43448
thaJeztah merged 1 commit intomoby:masterfrom
thaJeztah:daemon_config_group_proxies

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah commented Apr 2, 2022

daemon/config: move proxy settings to "proxies" struct within daemon.json

This is a follow-up to 427c7cc (#42835), which added proxy-configuration options ("http-proxy", "https-proxy", "no-proxy") to the dockerd cli and in daemon.json.

While working on documentation changes for this feature, I realised that those options won't be "next" to each-other when formatting the daemon.json JSON, for example using jq (which sorts the fields alphabetically). As it's possible that additional proxy configuration options are added in future, I considered that grouping these options in a struct within the JSON may help setting these options, as well as discovering related options.

This patch introduces a "proxies" field in the JSON, which includes the "http-proxy", "https-proxy", "no-proxy" options.

Conflict detection continues to work as before; with this patch applied:

cat /etc/docker/config.json
{
  "proxies": {
    "http-proxy": "http-config",
    "https-proxy": "https-config",
    "no-proxy": "no-proxy-config"
  }
}

dockerd --http-proxy=http-flag --https-proxy=https-flag --no-proxy=no-proxy-flag --validate

unable to configure the Docker daemon with file /etc/docker/daemon.json:
the following directives are specified both as a flag and in the configuration file:
http-proxy: (from flag: http-flag, from file: http-config),
https-proxy: (from flag: https-flag, from file: https-config),
no-proxy: (from flag: no-proxy-flag, from file: no-proxy-config)

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah thaJeztah added this to the 21.xx milestone Apr 2, 2022
@thaJeztah thaJeztah changed the title daemon/config: move proxy settings to "proxy-config" struct within daemon.jso daemon/config: move proxy settings to "proxy-config" struct within daemon.json Apr 2, 2022
Comment thread daemon/config/config.go Outdated
Comment on lines +164 to +165
// ProxyConfig holds the proxy-configuration for the daemon.
ProxyConfig `json:"proxy-config"`
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

FWIW, I was considering to have an omitempty, but that required the struct to be a pointer, and all the complexity involved with that, so I decided not to go down that road

@thaJeztah thaJeztah requested a review from tianon April 2, 2022 14:22
@thaJeztah thaJeztah force-pushed the daemon_config_group_proxies branch from 6d59234 to 5e90b9f Compare April 2, 2022 16:51
@thaJeztah

This comment was marked as resolved.

@thaJeztah thaJeztah force-pushed the daemon_config_group_proxies branch from 5e90b9f to 5e743bc Compare April 3, 2022 13:23
@thaJeztah
Copy link
Copy Markdown
Member Author

@tianon @tonistiigi @cpuguy83 PTAL this feature hasn't shipped yet, so if you agree this makes it better, we should try to get this in before the release 👍

@cpuguy83
Copy link
Copy Markdown
Member

cpuguy83 commented Apr 5, 2022

Erring on the side of not making changes, I'm not sure what's the chance this would be overshadowed by something else down the line?
I can't really decide which way is better, but I think I lean towards the non-stuttery version at the top-level.

@thaJeztah
Copy link
Copy Markdown
Member Author

I'm not sure what's the chance this would be overshadowed by something else down the line?

That's about the Go code changes, or the JSON side? I can drop the second commit if you prefer.

For the JSON side; it's not released yet, so we can still modify.

The issue was a bit that when pretty-printing the JSON, these settings won't be next to each-other (even more if we'd ever add a "all-proxy" option, e.g.); grouping them together could possibly also make things easier to patch them all together, but perhaps no big difference there.

@thaJeztah thaJeztah force-pushed the daemon_config_group_proxies branch from 5e743bc to 97bf8b3 Compare April 6, 2022 18:54
@thaJeztah
Copy link
Copy Markdown
Member Author

I dropped the second commit (I think that's what you meant) let me know if this LGTY

@thaJeztah
Copy link
Copy Markdown
Member Author

kicked CI (flaky test on Windows); @cpuguy83 @tianon PTAL 🤗

Comment thread daemon/config/config.go Outdated
ProxyConfig

// ProxyConfig holds the proxy-configuration for the daemon.
ProxyConfig `json:"proxy-config"`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about just proxies?

I know you reverted some go changes (I assume it was giving this an explicit field name).
I think it's good to give it a proper field name.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Proxies works for me (I was wondering if there would be other proxy-related options that could become relevant); can you think of any?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nope.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

👍 let me rename it to proxies

…json

This is a follow-up to 427c7cc, which added
proxy-configuration options ("http-proxy", "https-proxy", "no-proxy") to the
dockerd cli and in `daemon.json`.

While working on documentation changes for this feature, I realised that those
options won't be "next" to each-other when formatting the daemon.json JSON, for
example using `jq` (which sorts the fields alphabetically). As it's possible that
additional proxy configuration options are added in future, I considered that
grouping these options in a struct within the JSON may help setting these options,
as well as discovering related options.

This patch introduces a "proxies" field in the JSON, which includes the
"http-proxy", "https-proxy", "no-proxy" options.

Conflict detection continues to work as before; with this patch applied:

    mkdir -p /etc/docker/
    echo '{"proxies":{"http-proxy":"http-config", "https-proxy":"https-config", "no-proxy": "no-proxy-config"}}' > /etc/docker/daemon.json

    dockerd --http-proxy=http-flag --https-proxy=https-flag --no-proxy=no-proxy-flag --validate

    unable to configure the Docker daemon with file /etc/docker/daemon.json:
    the following directives are specified both as a flag and in the configuration file:
    http-proxy: (from flag: http-flag, from file: http-config),
    https-proxy: (from flag: https-flag, from file: https-config),
    no-proxy: (from flag: no-proxy-flag, from file: no-proxy-config)

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah changed the title daemon/config: move proxy settings to "proxy-config" struct within daemon.json daemon/config: move proxy settings to "proxies" struct within daemon.json Apr 7, 2022
@thaJeztah thaJeztah force-pushed the daemon_config_group_proxies branch from 97bf8b3 to 101dafd Compare April 7, 2022 17:44
@thaJeztah
Copy link
Copy Markdown
Member Author

Updated 👍

Copy link
Copy Markdown
Member

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

LGTM

@thaJeztah
Copy link
Copy Markdown
Member Author

thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants