Skip to content

Commit c5f695e

Browse files
committed
Better comment syntax
1 parent b1648ca commit c5f695e

30 files changed

+68
-67
lines changed

cmd/minikube/cmd/config/open.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ var addonsOpenCmd = &cobra.Command{
5757
exit.Usage("usage: minikube addons open ADDON_NAME")
5858
}
5959
addonName := args[0]
60-
//TODO(r2d4): config should not reference API, pull this out
60+
// TODO(r2d4): config should not reference API, pull this out
6161
api, err := machine.NewAPIClient()
6262
if err != nil {
6363
exit.WithError("Error getting client", err)

cmd/minikube/cmd/config/util.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func EnableOrDisableAddon(name string, val string) error {
110110
return errors.Wrapf(err, "parsing bool: %s", name)
111111
}
112112

113-
//TODO(r2d4): config package should not reference API, pull this out
113+
// TODO(r2d4): config package should not reference API, pull this out
114114
api, err := machine.NewAPIClient()
115115
if err != nil {
116116
return errors.Wrap(err, "machine client")

cmd/minikube/cmd/start.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ func validateConfig() {
417417
}
418418

419419
// This function validates if the --registry-mirror
420-
//args match the format of http://localhost
420+
// args match the format of http://localhost
421421
func validateRegistryMirror() {
422422

423423
if len(registryMirror) > 0 {

cmd/minikube/cmd/stop.go

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ func runStop(cmd *cobra.Command, args []string) {
8181
exit.WithError("update config", err)
8282
}
8383
}
84+
8485
func init() {
8586
RootCmd.AddCommand(stopCmd)
8687
}

cmd/minikube/cmd/tunnel.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ var tunnelCmd = &cobra.Command{
5959
}
6060
glog.Infof("Creating k8s client...")
6161

62-
//Tunnel uses the k8s clientset to query the API server for services in the LoadBalancerEmulator.
63-
//We define the tunnel and minikube error free if the API server responds within a second.
64-
//This also contributes to better UX, the tunnel status check can happen every second and
65-
//doesn't hang on the API server call during startup and shutdown time or if there is a temporary error.
62+
// Tunnel uses the k8s clientset to query the API server for services in the LoadBalancerEmulator.
63+
// We define the tunnel and minikube error free if the API server responds within a second.
64+
// This also contributes to better UX, the tunnel status check can happen every second and
65+
// doesn't hang on the API server call during startup and shutdown time or if there is a temporary error.
6666
clientset, err := service.K8s.GetClientset(1 * time.Second)
6767
if err != nil {
6868
exit.WithError("error creating clientset", err)

pkg/drivers/kvm/network.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,15 @@ func (d *Driver) deleteNetwork() error {
194194

195195
func (d *Driver) checkDomains(conn *libvirt.Connect) error {
196196
type source struct {
197-
//XMLName xml.Name `xml:"source"`
197+
// XMLName xml.Name `xml:"source"`
198198
Network string `xml:"network,attr"`
199199
}
200200
type iface struct {
201-
//XMLName xml.Name `xml:"interface"`
201+
// XMLName xml.Name `xml:"interface"`
202202
Source source `xml:"source"`
203203
}
204204
type result struct {
205-
//XMLName xml.Name `xml:"domain"`
205+
// XMLName xml.Name `xml:"domain"`
206206
Name string `xml:"name"`
207207
Interfaces []iface `xml:"devices>interface"`
208208
}

pkg/minikube/bootstrapper/kubeadm/kubeadm.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func (k *Bootstrapper) StartCluster(k8s config.KubernetesConfig) error {
230230
}
231231

232232
if version.LT(semver.MustParse("1.10.0-alpha.0")) {
233-
//TODO(r2d4): get rid of global here
233+
// TODO(r2d4): get rid of global here
234234
master = k8s.NodeName
235235
if err := util.RetryAfter(200, unmarkMaster, time.Second*1); err != nil {
236236
return errors.Wrap(err, "timed out waiting to unmark master")

pkg/minikube/cluster/cluster.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ var (
5858
maxClockDesyncSeconds = 2.1
5959
)
6060

61-
//This init function is used to set the logtostderr variable to false so that INFO level log info does not clutter the CLI
62-
//INFO lvl logging is displayed due to the kubernetes api calling flag.Set("logtostderr", "true") in its init()
63-
//see: https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/util/logs/logs.go#L32-L34
61+
// This init function is used to set the logtostderr variable to false so that INFO level log info does not clutter the CLI
62+
// INFO lvl logging is displayed due to the kubernetes api calling flag.Set("logtostderr", "true") in its init()
63+
// see: https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/util/logs/logs.go#L32-L34
6464
func init() {
6565
if err := flag.Set("logtostderr", "false"); err != nil {
6666
exit.WithError("unable to set logtostderr", err)

pkg/minikube/constants/constants.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ const (
153153
SHASuffix = ".sha256"
154154
// DefaultMemorySize is the default memory which will be allocated to minikube, in megabytes
155155
DefaultMemorySize = "2000mb"
156-
//MinimumMemorySize is the minimum memory size, in megabytes
156+
// MinimumMemorySize is the minimum memory size, in megabytes
157157
MinimumMemorySize = "1024mb"
158158
// DefaultCPUS is the default number of cpus of a host
159159
DefaultCPUS = 2
@@ -421,7 +421,7 @@ const (
421421
// StoredContainerdConfigTomlPath is the path where the default config.toml will be stored
422422
StoredContainerdConfigTomlPath = "/tmp/config.toml"
423423

424-
//GvisorConfigTomlTargetName is the go-bindata target name for the gvisor config.toml
424+
// GvisorConfigTomlTargetName is the go-bindata target name for the gvisor config.toml
425425
GvisorConfigTomlTargetName = "gvisor-config.toml"
426426
// GvisorContainerdShimTargetName is the go-bindata target name for gvisor-containerd-shim
427427
GvisorContainerdShimTargetName = "gvisor-containerd-shim.toml"

pkg/minikube/drivers/hyperv/driver.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func createHypervHost(config cfg.MachineConfig) interface{} {
4646
d.CPU = config.CPUs
4747
d.DiskSize = int(config.DiskSize)
4848
d.SSHUser = "docker"
49-
d.DisableDynamicMemory = true //default to disable dynamic memory as minikube is unlikely to work properly with dynamic memory
49+
d.DisableDynamicMemory = true // default to disable dynamic memory as minikube is unlikely to work properly with dynamic memory
5050

5151
return d
5252
}

pkg/minikube/tunnel/loadbalancer_patcher.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ import (
2727
"k8s.io/client-go/rest"
2828
)
2929

30-
//requestSender is an interface exposed for testing what requests are sent through the k8s REST client
30+
// requestSender is an interface exposed for testing what requests are sent through the k8s REST client
3131
type requestSender interface {
3232
send(request *rest.Request) ([]byte, error)
3333
}
3434

35-
//patchConverter is an interface exposed for testing what patches are sent through the k8s REST client
35+
// patchConverter is an interface exposed for testing what patches are sent through the k8s REST client
3636
type patchConverter interface {
3737
convert(restClient rest.Interface, patch *Patch) *rest.Request
3838
}
3939

40-
//loadBalancerEmulator is the main struct for emulating the loadbalancer behavior. it sets the ingress to the cluster IP
40+
// loadBalancerEmulator is the main struct for emulating the loadbalancer behavior. it sets the ingress to the cluster IP
4141
type loadBalancerEmulator struct {
4242
coreV1Client typed_core.CoreV1Interface
4343
requestSender requestSender

pkg/minikube/tunnel/process.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ func osGetPid() int {
3535
return os.Getpid()
3636
}
3737

38-
//TODO(balintp): this is vulnerable to pid reuse we should include process name in the check
38+
// TODO(balintp): this is vulnerable to pid reuse we should include process name in the check
3939
func osCheckIfRunning(pid int) (bool, error) {
4040
p, err := os.FindProcess(pid)
4141
if runtime.GOOS == "windows" {
4242
return err == nil, nil
4343
}
44-
//on unix systems further checking is required, as findProcess is noop
44+
// on unix systems further checking is required, as findProcess is noop
4545
if err != nil {
4646
return false, fmt.Errorf("error finding process %d: %s", pid, err)
4747
}

pkg/minikube/tunnel/registry.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ import (
3131

3232
// ID represents a registry ID
3333
type ID struct {
34-
//Route is the key
34+
// Route is the key
3535
Route *Route
36-
//the rest is metadata
36+
// the rest is metadata
3737
MachineName string
3838
Pid int
3939
}

pkg/minikube/tunnel/reporter.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"github.com/golang/glog"
2626
)
2727

28-
//reporter that reports the status of a tunnel
28+
// reporter that reports the status of a tunnel
2929
type reporter interface {
3030
Report(tunnelState *Status)
3131
}

pkg/minikube/tunnel/reporter_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Got: "%s"`, tc.name, tc.expectedOutput, out.output)
100100
})
101101
}
102102

103-
//testing deduplication
103+
// testing deduplication
104104
out := &recordingWriter{}
105105
reporter := newReporter(out)
106106
reporter.Report(testCases[0].tunnelState)

pkg/minikube/tunnel/route.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ import (
2323
"github.com/golang/glog"
2424
)
2525

26-
//router manages the routing table on the host, implementations should cater for OS specific methods
26+
// router manages the routing table on the host, implementations should cater for OS specific methods
2727
type router interface {
28-
//Inspect checks if the given route exists or not in the routing table
29-
//conflict is defined as: same destination CIDR, different Gateway
30-
//overlaps are defined as: routes that have overlapping but not exactly matching destination CIDR
28+
// Inspect checks if the given route exists or not in the routing table
29+
// conflict is defined as: same destination CIDR, different Gateway
30+
// overlaps are defined as: routes that have overlapping but not exactly matching destination CIDR
3131
Inspect(route *Route) (exists bool, conflict string, overlaps []string, err error)
3232

33-
//EnsureRouteIsAdded is an idempotent way to add a route to the routing table
34-
//it fails if there is a conflict
33+
// EnsureRouteIsAdded is an idempotent way to add a route to the routing table
34+
// it fails if there is a conflict
3535
EnsureRouteIsAdded(route *Route) error
3636

37-
//Cleanup is an idempotent way to remove a route from the routing table
38-
//it fails if there is a conflict
37+
// Cleanup is an idempotent way to remove a route from the routing table
38+
// it fails if there is a conflict
3939
Cleanup(route *Route) error
4040
}
4141

@@ -67,8 +67,8 @@ func isValidToAddOrDelete(router router, r *Route) (bool, error) {
6767
return false, nil
6868
}
6969

70-
//a partial representation of the routing table on the host
71-
//tunnel only requires the destination CIDR, the gateway and the actual textual representation per line
70+
// a partial representation of the routing table on the host
71+
// tunnel only requires the destination CIDR, the gateway and the actual textual representation per line
7272
type routingTable []routingTableLine
7373

7474
func (t *routingTable) Check(route *Route) (exists bool, conflict string, overlaps []string) {

pkg/minikube/tunnel/route_darwin.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ func (router *osRouter) parseTable(table []byte) routingTable {
7777
t := routingTable{}
7878
skip := true
7979
for _, line := range strings.Split(string(table), "\n") {
80-
//header
80+
// header
8181
if strings.HasPrefix(line, "Destination") {
8282
skip = false
8383
continue
8484
}
85-
//don't care about the 0.0.0.0 routes
85+
// don't care about the 0.0.0.0 routes
8686
if skip || strings.HasPrefix(line, "default") {
8787
continue
8888
}

pkg/minikube/tunnel/route_linux.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,20 @@ func (router *osRouter) parseTable(table []byte) routingTable {
7474

7575
fields := strings.Fields(line)
7676

77-
//don't care about the routes that 0.0.0.0
77+
// don't care about the routes that 0.0.0.0
7878
if len(fields) == 0 ||
7979
len(fields) > 0 && (fields[0] == "default" || fields[0] == "0.0.0.0") {
8080
continue
8181
}
8282

8383
if len(fields) > 2 {
8484

85-
//assuming "10.96.0.0/12 via 192.168.39.47 dev virbr1"
85+
// assuming "10.96.0.0/12 via 192.168.39.47 dev virbr1"
8686
dstCIDRString := fields[0]
8787
gatewayIPString := fields[2]
8888
gatewayIP := net.ParseIP(gatewayIPString)
8989

90-
//if not via format, then gateway is assumed to be 0.0.0.0
90+
// if not via format, then gateway is assumed to be 0.0.0.0
9191
// "1.2.3.0/24 dev eno1 proto kernel scope link src 1.2.3.54 metric 100"
9292
if fields[1] != "via" {
9393
gatewayIP = net.ParseIP("0.0.0.0")

pkg/minikube/tunnel/route_windows.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ func (router *osRouter) parseTable(table []byte) routingTable {
6464
t := routingTable{}
6565
skip := true
6666
for _, line := range strings.Split(string(table), "\n") {
67-
//after first line of header we can start consuming
67+
// after first line of header we can start consuming
6868
if strings.HasPrefix(line, "Network Destination") {
6969
skip = false
7070
continue
7171
}
7272

7373
fields := strings.Fields(line)
74-
//don't care about the 0.0.0.0 routes
74+
// don't care about the 0.0.0.0 routes
7575
if skip || len(fields) == 0 || len(fields) > 0 && (fields[0] == "default" || fields[0] == "0.0.0.0") {
7676
continue
7777
}

pkg/minikube/tunnel/test_doubles.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ func (r *recordingReporter) Report(tunnelState *Status) {
3232
r.statesRecorded = append(r.statesRecorded, tunnelState)
3333
}
3434

35-
//simulating idempotent router behavior
36-
//without checking for conflicting routes
35+
// simulating idempotent router behavior
36+
// without checking for conflicting routes
3737
type fakeRouter struct {
3838
rt routingTable
3939
errorResponse error

pkg/minikube/tunnel/tunnel.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ import (
3232
"k8s.io/minikube/pkg/minikube/constants"
3333
)
3434

35-
//tunnel represents the basic API for a tunnel: periodically the state of the tunnel
36-
//can be updated and when the tunnel is not needed, it can be cleaned up
37-
//It was mostly introduced for testability.
35+
// tunnel represents the basic API for a tunnel: periodically the state of the tunnel
36+
// can be updated and when the tunnel is not needed, it can be cleaned up
37+
// It was mostly introduced for testability.
3838
type controller interface {
3939
cleanup() *Status
4040
update() *Status
@@ -85,7 +85,7 @@ func newTunnel(machineName string, machineAPI libmachine.API, configLoader confi
8585
}
8686

8787
type tunnel struct {
88-
//collaborators
88+
// collaborators
8989
clusterInspector *clusterInspector
9090
router router
9191
loadBalancerEmulator loadBalancerEmulator
@@ -142,16 +142,16 @@ func setupRoute(t *tunnel, h *host.Host) {
142142
if t.status.RouteError != nil {
143143
return
144144
}
145-
//the route was added successfully, we need to make sure the registry has it too
146-
//this might fail in race conditions, when another process created this tunnel
145+
// the route was added successfully, we need to make sure the registry has it too
146+
// this might fail in race conditions, when another process created this tunnel
147147
if err := t.registry.Register(&t.status.TunnelID); err != nil {
148148
glog.Errorf("failed to register tunnel: %s", err)
149149
t.status.RouteError = err
150150
return
151151
}
152152

153153
if h.DriverName == constants.DriverHyperkit {
154-
//the virtio-net interface acts up with ip tunnels :(
154+
// the virtio-net interface acts up with ip tunnels :(
155155
setupBridge(t)
156156
if t.status.RouteError != nil {
157157
return
@@ -166,7 +166,7 @@ func setupRoute(t *tunnel, h *host.Host) {
166166
return
167167
}
168168

169-
//the route exists, make sure that this process owns it in the registry
169+
// the route exists, make sure that this process owns it in the registry
170170
existingTunnel, err := t.registry.IsAlreadyDefinedAndRunning(&t.status.TunnelID)
171171
if err != nil {
172172
glog.Errorf("failed to check for other tunnels: %s", err)
@@ -175,7 +175,7 @@ func setupRoute(t *tunnel, h *host.Host) {
175175
}
176176

177177
if existingTunnel == nil {
178-
//the route exists, but "orphaned", this process will "own it" in the registry
178+
// the route exists, but "orphaned", this process will "own it" in the registry
179179
if err := t.registry.Register(&t.status.TunnelID); err != nil {
180180
glog.Errorf("failed to register tunnel: %s", err)
181181
t.status.RouteError = err
@@ -184,7 +184,7 @@ func setupRoute(t *tunnel, h *host.Host) {
184184
}
185185

186186
if existingTunnel.Pid != getPid() {
187-
//another running process owns the tunnel
187+
// another running process owns the tunnel
188188
t.status.RouteError = errorTunnelAlreadyExists(existingTunnel)
189189
return
190190
}

pkg/minikube/tunnel/tunnel_manager.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type Manager struct {
3838
router router
3939
}
4040

41-
//stateCheckInterval defines how frequently the cluster and route states are checked
41+
// stateCheckInterval defines how frequently the cluster and route states are checked
4242
const stateCheckInterval = 5 * time.Second
4343

4444
// NewManager creates a new Manager
@@ -68,7 +68,7 @@ func (mgr *Manager) startTunnel(ctx context.Context, tunnel controller) (done ch
6868
check := make(chan bool, 1)
6969
done = make(chan bool, 1)
7070

71-
//simulating Ctrl+C so that we can cancel the tunnel programmatically too
71+
// simulating Ctrl+C so that we can cancel the tunnel programmatically too
7272
go mgr.timerLoop(ready, check)
7373
go mgr.run(ctx, tunnel, ready, check, done)
7474

pkg/minikube/tunnel/tunnel_manager_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929

3030
func TestTunnelManagerEventHandling(t *testing.T) {
3131
tcs := []struct {
32-
//tunnel inputs
32+
// tunnel inputs
3333
name string
3434
repeat int
3535
test func(tunnel *tunnelStub, cancel context.CancelFunc, ready, check, done chan bool) error
@@ -120,7 +120,7 @@ func TestTunnelManagerEventHandling(t *testing.T) {
120120
},
121121
}
122122

123-
//t.Parallel()
123+
// t.Parallel()
124124
for _, tc := range tcs {
125125
t.Run(tc.name, func(t *testing.T) {
126126
var err error

0 commit comments

Comments
 (0)