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

govc: Add support for getting the VC proxy and no-proxy configuration #2435

Merged
merged 3 commits into from
May 14, 2021

Conversation

matonev
Copy link
Contributor

@matonev matonev commented May 11, 2021

govc: Add support for getting the VC proxy and no-proxy configuration
Introduced the vAPI bindings and the implementation for those

govc output:

HTTP proxy:          Enabled
                     Server:    http://10.186.17.218
                     Port:      80
                     Username:  user
HTTPS proxy:         Disabled
FTP proxy:           Enabled
                     Server:  http://google.com
                     Port:    21
No Proxy addresses:  localhost, 127.0.0.1

Introduced the vAPI bindings and the implementation for those

govc output:
```
HTTP proxy:          Enabled
                     Server:    http://10.186.17.218
                     Port:      80
                     Username:  user
HTTPS proxy:         Disabled
FTP proxy:           Enabled
                     Server:  http://google.com
                     Port:    21
No Proxy addresses:  localhost, 127.0.0.1
```
Copy link
Member

@dougm dougm left a comment

Choose a reason for hiding this comment

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

Looks great, thanks @matonev ! Just a few minor comments/suggestions.

limitations under the License.
*/

package logging
Copy link
Member

Choose a reason for hiding this comment

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

should be package networking or package net (see comment below)

@@ -0,0 +1,119 @@
/*
Copyright (c) 2020 VMware, Inc. All Rights Reserved.
Copy link
Member

Choose a reason for hiding this comment

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

2021

}

func init() {
cli.Register("vcsa.networking.proxy.info", &info{})
Copy link
Member

Choose a reason for hiding this comment

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

Similar to how we named vcsa.log.* instead of vcsa.logging.*, can we use vcsa.net.* as the prefix here?

var res proxyResult
res.proxy = proxyRes
res.noProxy = noProxyRes
return cmd.WriteResult(res)
Copy link
Member

Choose a reason for hiding this comment

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

You can collapse these 4 lines into:

return cmd.WriteResult(&proxyResult{proxyRes, noProxyRes})

}

// ProtocolProxyConfig represents configuration for specific proxy - ftp, http, https.
type ProtocolProxyConfig struct {
Copy link
Member

Choose a reason for hiding this comment

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

Let's name this type Proxy

}

// Proxy returns all Proxy configuration.
func (m *Manager) Proxy(ctx context.Context) (ProxyConfig, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Let's name this method ProxyConfig. Based on the API, I think a Proxy method would be for a specific protocol such as /rest/appliance/networking/proxy/https
We also normally return a pointer, *ProxyConfig in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, renamed the NoProxy to NoProxyConfig as well

}

for _, c := range rawRes {
switch {
Copy link
Member

Choose a reason for hiding this comment

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

switch c.Key {
    case "http":
       res.Http = c.Value
    ...
}

* govc package is renamed to `net`
* `ProtocolProxyConfig` struct renamed to `Proxy`
* vAPI accessor functions renamed to `ProxyConfig` and `NoProxyConfig`
Copy link
Member

@dougm dougm left a comment

Choose a reason for hiding this comment

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

Thanks @matonev , just want to fixup the naming a bit more to align with the API naming.

}

// NoProxy returns all excluded servers for proxying.
func (m *Manager) NoProxyConfig(ctx context.Context) ([]string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Let's leave this as you had it, NoProxy, since it matches the API name + return values.

}

// ProxyConfig represents configuration for vcenter proxy.
type ProxyConfig struct {
Copy link
Member

Choose a reason for hiding this comment

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

Wondering if we should name this ProxyList to match the API
While this structure isn't a list itself, it does capture the data returned by the ProxyList API.

And same with the method below. While the structure differs from what the API returns, I don't imagine new protocols being added to the list. And if they are, we can just add to this structure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. Renamed the struct and the method

Https Proxy `json:"https,omitempty"`
}

// Proxy returns all Proxy configuration.
Copy link
Member

Choose a reason for hiding this comment

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

Also make sure the doc comment matches the type/method name.

* Ranamed `ProxyConfig` to `ProxyList`
* Ranamed `NoProxyConfig` to `NoProxy`
Copy link
Member

@dougm dougm left a comment

Choose a reason for hiding this comment

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

Awesome, thanks @matonev !

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