X Tutup
Skip to content

Commit d2ada64

Browse files
author
Olivier Gambier
committed
Lint
Signed-off-by: Olivier Gambier <olivier@docker.com>
1 parent 24da8ad commit d2ada64

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+240
-240
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ sudo: required
22
dist: trusty
33
language: bash
44
services: docker
5-
script: USE_CONTAINER=true make dco fmt vet test-short test-long coverage-send
5+
script: USE_CONTAINER=true make dco fmt lint vet test-short test-long coverage-send

commands/commands.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ func runActionWithContext(actionName string, c CommandLine) error {
475475
// codegangsta/cli will not set the cert paths if the storage-path is set to
476476
// something different so we cannot use the paths in the global options. le
477477
// sigh.
478-
func getCertPathInfoFromContext(c CommandLine) cert.CertPathInfo {
478+
func getCertPathInfoFromContext(c CommandLine) cert.PathInfo {
479479
caCertPath := c.GlobalString("tls-ca-cert")
480480
caKeyPath := c.GlobalString("tls-ca-key")
481481
clientCertPath := c.GlobalString("tls-client-cert")
@@ -497,7 +497,7 @@ func getCertPathInfoFromContext(c CommandLine) cert.CertPathInfo {
497497
clientKeyPath = filepath.Join(mcndirs.GetMachineCertDir(), "key.pem")
498498
}
499499

500-
return cert.CertPathInfo{
500+
return cert.PathInfo{
501501
CaCertPath: caCertPath,
502502
CaPrivateKeyPath: caKeyPath,
503503
ClientCertPath: clientCertPath,

commands/config.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ import (
1616
// ErrCertInvalid for when the cert is computed to be invalid.
1717
type ErrCertInvalid struct {
1818
wrappedErr error
19-
hostUrl string
19+
hostURL string
2020
}
2121

2222
func (e ErrCertInvalid) Error() string {
2323
return fmt.Sprintf(`There was an error validating certificates for host %q: %s
2424
You can attempt to regenerate them using 'docker-machine regenerate-certs name'.
2525
Be advised that this will trigger a Docker daemon restart which will stop running containers.
26-
`, e.hostUrl, e.wrappedErr)
26+
`, e.hostURL, e.wrappedErr)
2727
}
2828

2929
func cmdConfig(c CommandLine) error {
@@ -53,58 +53,58 @@ func cmdConfig(c CommandLine) error {
5353
return nil
5454
}
5555

56-
func runConnectionBoilerplate(h *host.Host, c CommandLine) (string, *auth.AuthOptions, error) {
56+
func runConnectionBoilerplate(h *host.Host, c CommandLine) (string, *auth.Options, error) {
5757
hostState, err := h.Driver.GetState()
5858
if err != nil {
5959
// TODO: This is a common operation and should have a commonly
6060
// defined error.
61-
return "", &auth.AuthOptions{}, fmt.Errorf("Error trying to get host state: %s", err)
61+
return "", &auth.Options{}, fmt.Errorf("Error trying to get host state: %s", err)
6262
}
6363
if hostState != state.Running {
64-
return "", &auth.AuthOptions{}, fmt.Errorf("%s is not running. Please start it in order to use the connection settings", h.Name)
64+
return "", &auth.Options{}, fmt.Errorf("%s is not running. Please start it in order to use the connection settings", h.Name)
6565
}
6666

6767
dockerHost, err := h.Driver.GetURL()
6868
if err != nil {
69-
return "", &auth.AuthOptions{}, fmt.Errorf("Error getting driver URL: %s", err)
69+
return "", &auth.Options{}, fmt.Errorf("Error getting driver URL: %s", err)
7070
}
7171

7272
if c.Bool("swarm") {
7373
var err error
7474
dockerHost, err = parseSwarm(dockerHost, h)
7575
if err != nil {
76-
return "", &auth.AuthOptions{}, fmt.Errorf("Error parsing swarm: %s", err)
76+
return "", &auth.Options{}, fmt.Errorf("Error parsing swarm: %s", err)
7777
}
7878
}
7979

8080
u, err := url.Parse(dockerHost)
8181
if err != nil {
82-
return "", &auth.AuthOptions{}, fmt.Errorf("Error parsing URL: %s", err)
82+
return "", &auth.Options{}, fmt.Errorf("Error parsing URL: %s", err)
8383
}
8484

8585
authOptions := h.HostOptions.AuthOptions
8686

8787
if err := checkCert(u.Host, authOptions); err != nil {
88-
return "", &auth.AuthOptions{}, fmt.Errorf("Error checking and/or regenerating the certs: %s", err)
88+
return "", &auth.Options{}, fmt.Errorf("Error checking and/or regenerating the certs: %s", err)
8989
}
9090

9191
return dockerHost, authOptions, nil
9292
}
9393

94-
func checkCert(hostUrl string, authOptions *auth.AuthOptions) error {
95-
valid, err := cert.ValidateCertificate(hostUrl, authOptions)
94+
func checkCert(hostURL string, authOptions *auth.Options) error {
95+
valid, err := cert.ValidateCertificate(hostURL, authOptions)
9696
if !valid || err != nil {
9797
return ErrCertInvalid{
9898
wrappedErr: err,
99-
hostUrl: hostUrl,
99+
hostURL: hostURL,
100100
}
101101
}
102102

103103
return nil
104104
}
105105

106106
// TODO: This could use a unit test.
107-
func parseSwarm(hostUrl string, h *host.Host) (string, error) {
107+
func parseSwarm(hostURL string, h *host.Host) (string, error) {
108108
swarmOptions := h.HostOptions.SwarmOptions
109109

110110
if !swarmOptions.Master {
@@ -119,15 +119,15 @@ func parseSwarm(hostUrl string, h *host.Host) (string, error) {
119119
swarmPort := parts[1]
120120

121121
// get IP of machine to replace in case swarm host is 0.0.0.0
122-
mUrl, err := url.Parse(hostUrl)
122+
mURL, err := url.Parse(hostURL)
123123
if err != nil {
124124
return "", fmt.Errorf("There was an error parsing the url: %s", err)
125125
}
126126

127-
mParts := strings.Split(mUrl.Host, ":")
128-
machineIp := mParts[0]
127+
mParts := strings.Split(mURL.Host, ":")
128+
machineIP := mParts[0]
129129

130-
hostUrl = fmt.Sprintf("tcp://%s:%s", machineIp, swarmPort)
130+
hostURL = fmt.Sprintf("tcp://%s:%s", machineIP, swarmPort)
131131

132-
return hostUrl, nil
132+
return hostURL, nil
133133
}

commands/config_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,29 @@ func (fcg FakeCertGenerator) GenerateCert(hosts []string, certFile, keyFile, caF
2626
return nil
2727
}
2828

29-
func (fcg FakeCertGenerator) ValidateCertificate(addr string, authOptions *auth.AuthOptions) (bool, error) {
29+
func (fcg FakeCertGenerator) ValidateCertificate(addr string, authOptions *auth.Options) (bool, error) {
3030
return fcg.fakeValidateCertificate.IsValid, fcg.fakeValidateCertificate.Err
3131
}
3232

3333
func TestCheckCert(t *testing.T) {
3434
errCertsExpired := errors.New("Certs have expired")
3535

3636
cases := []struct {
37-
hostUrl string
38-
authOptions *auth.AuthOptions
37+
hostURL string
38+
authOptions *auth.Options
3939
valid bool
4040
checkErr error
4141
expectedErr error
4242
}{
43-
{"192.168.99.100:2376", &auth.AuthOptions{}, true, nil, nil},
44-
{"192.168.99.100:2376", &auth.AuthOptions{}, false, nil, ErrCertInvalid{wrappedErr: nil, hostUrl: "192.168.99.100:2376"}},
45-
{"192.168.99.100:2376", &auth.AuthOptions{}, false, errCertsExpired, ErrCertInvalid{wrappedErr: errCertsExpired, hostUrl: "192.168.99.100:2376"}},
43+
{"192.168.99.100:2376", &auth.Options{}, true, nil, nil},
44+
{"192.168.99.100:2376", &auth.Options{}, false, nil, ErrCertInvalid{wrappedErr: nil, hostURL: "192.168.99.100:2376"}},
45+
{"192.168.99.100:2376", &auth.Options{}, false, errCertsExpired, ErrCertInvalid{wrappedErr: errCertsExpired, hostURL: "192.168.99.100:2376"}},
4646
}
4747

4848
for _, c := range cases {
4949
fcg := FakeCertGenerator{fakeValidateCertificate: &FakeValidateCertificate{c.valid, c.checkErr}}
5050
cert.SetCertGenerator(fcg)
51-
err := checkCert(c.hostUrl, c.authOptions)
51+
err := checkCert(c.hostURL, c.authOptions)
5252
assert.Equal(t, c.expectedErr, err)
5353
}
5454
}

commands/create.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ func cmdCreateInner(c CommandLine) error {
168168
return fmt.Errorf("Error getting new host: %s", err)
169169
}
170170

171-
h.HostOptions = &host.HostOptions{
172-
AuthOptions: &auth.AuthOptions{
171+
h.HostOptions = &host.Options{
172+
AuthOptions: &auth.Options{
173173
CertDir: mcndirs.GetMachineCertDir(),
174174
CaCertPath: certInfo.CaCertPath,
175175
CaPrivateKeyPath: certInfo.CaPrivateKeyPath,
@@ -179,17 +179,17 @@ func cmdCreateInner(c CommandLine) error {
179179
ServerKeyPath: filepath.Join(mcndirs.GetMachineDir(), name, "server-key.pem"),
180180
StorePath: filepath.Join(mcndirs.GetMachineDir(), name),
181181
},
182-
EngineOptions: &engine.EngineOptions{
182+
EngineOptions: &engine.Options{
183183
ArbitraryFlags: c.StringSlice("engine-opt"),
184184
Env: c.StringSlice("engine-env"),
185185
InsecureRegistry: c.StringSlice("engine-insecure-registry"),
186186
Labels: c.StringSlice("engine-label"),
187187
RegistryMirror: c.StringSlice("engine-registry-mirror"),
188188
StorageDriver: c.String("engine-storage-driver"),
189-
TlsVerify: true,
189+
TLSVerify: true,
190190
InstallURL: c.String("engine-install-url"),
191191
},
192-
SwarmOptions: &swarm.SwarmOptions{
192+
SwarmOptions: &swarm.Options{
193193
IsSwarm: c.Bool("swarm"),
194194
Image: c.String("swarm-image"),
195195
Master: c.Bool("swarm-master"),

commands/ls.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type HostListItem struct {
3636
DriverName string
3737
State state.State
3838
URL string
39-
SwarmOptions *swarm.SwarmOptions
39+
SwarmOptions *swarm.Options
4040
}
4141

4242
func cmdLs(c CommandLine) error {

0 commit comments

Comments
 (0)
X Tutup