Better comment syntax

pull/4688/head
Kyle Bai 2019-07-05 11:17:10 +08:00
parent b1648ca2e4
commit c5f695e8a0
30 changed files with 68 additions and 67 deletions

View File

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

View File

@ -110,7 +110,7 @@ func EnableOrDisableAddon(name string, val string) error {
return errors.Wrapf(err, "parsing bool: %s", name)
}
//TODO(r2d4): config package should not reference API, pull this out
// TODO(r2d4): config package should not reference API, pull this out
api, err := machine.NewAPIClient()
if err != nil {
return errors.Wrap(err, "machine client")

View File

@ -417,7 +417,7 @@ func validateConfig() {
}
// This function validates if the --registry-mirror
//args match the format of http://localhost
// args match the format of http://localhost
func validateRegistryMirror() {
if len(registryMirror) > 0 {

View File

@ -81,6 +81,7 @@ func runStop(cmd *cobra.Command, args []string) {
exit.WithError("update config", err)
}
}
func init() {
RootCmd.AddCommand(stopCmd)
}

View File

@ -59,10 +59,10 @@ var tunnelCmd = &cobra.Command{
}
glog.Infof("Creating k8s client...")
//Tunnel uses the k8s clientset to query the API server for services in the LoadBalancerEmulator.
//We define the tunnel and minikube error free if the API server responds within a second.
//This also contributes to better UX, the tunnel status check can happen every second and
//doesn't hang on the API server call during startup and shutdown time or if there is a temporary error.
// Tunnel uses the k8s clientset to query the API server for services in the LoadBalancerEmulator.
// We define the tunnel and minikube error free if the API server responds within a second.
// This also contributes to better UX, the tunnel status check can happen every second and
// doesn't hang on the API server call during startup and shutdown time or if there is a temporary error.
clientset, err := service.K8s.GetClientset(1 * time.Second)
if err != nil {
exit.WithError("error creating clientset", err)

View File

@ -194,15 +194,15 @@ func (d *Driver) deleteNetwork() error {
func (d *Driver) checkDomains(conn *libvirt.Connect) error {
type source struct {
//XMLName xml.Name `xml:"source"`
// XMLName xml.Name `xml:"source"`
Network string `xml:"network,attr"`
}
type iface struct {
//XMLName xml.Name `xml:"interface"`
// XMLName xml.Name `xml:"interface"`
Source source `xml:"source"`
}
type result struct {
//XMLName xml.Name `xml:"domain"`
// XMLName xml.Name `xml:"domain"`
Name string `xml:"name"`
Interfaces []iface `xml:"devices>interface"`
}

View File

@ -230,7 +230,7 @@ func (k *Bootstrapper) StartCluster(k8s config.KubernetesConfig) error {
}
if version.LT(semver.MustParse("1.10.0-alpha.0")) {
//TODO(r2d4): get rid of global here
// TODO(r2d4): get rid of global here
master = k8s.NodeName
if err := util.RetryAfter(200, unmarkMaster, time.Second*1); err != nil {
return errors.Wrap(err, "timed out waiting to unmark master")

View File

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

View File

@ -153,7 +153,7 @@ const (
SHASuffix = ".sha256"
// DefaultMemorySize is the default memory which will be allocated to minikube, in megabytes
DefaultMemorySize = "2000mb"
//MinimumMemorySize is the minimum memory size, in megabytes
// MinimumMemorySize is the minimum memory size, in megabytes
MinimumMemorySize = "1024mb"
// DefaultCPUS is the default number of cpus of a host
DefaultCPUS = 2
@ -421,7 +421,7 @@ const (
// StoredContainerdConfigTomlPath is the path where the default config.toml will be stored
StoredContainerdConfigTomlPath = "/tmp/config.toml"
//GvisorConfigTomlTargetName is the go-bindata target name for the gvisor config.toml
// GvisorConfigTomlTargetName is the go-bindata target name for the gvisor config.toml
GvisorConfigTomlTargetName = "gvisor-config.toml"
// GvisorContainerdShimTargetName is the go-bindata target name for gvisor-containerd-shim
GvisorContainerdShimTargetName = "gvisor-containerd-shim.toml"

View File

@ -46,7 +46,7 @@ func createHypervHost(config cfg.MachineConfig) interface{} {
d.CPU = config.CPUs
d.DiskSize = int(config.DiskSize)
d.SSHUser = "docker"
d.DisableDynamicMemory = true //default to disable dynamic memory as minikube is unlikely to work properly with dynamic memory
d.DisableDynamicMemory = true // default to disable dynamic memory as minikube is unlikely to work properly with dynamic memory
return d
}

View File

@ -27,17 +27,17 @@ import (
"k8s.io/client-go/rest"
)
//requestSender is an interface exposed for testing what requests are sent through the k8s REST client
// requestSender is an interface exposed for testing what requests are sent through the k8s REST client
type requestSender interface {
send(request *rest.Request) ([]byte, error)
}
//patchConverter is an interface exposed for testing what patches are sent through the k8s REST client
// patchConverter is an interface exposed for testing what patches are sent through the k8s REST client
type patchConverter interface {
convert(restClient rest.Interface, patch *Patch) *rest.Request
}
//loadBalancerEmulator is the main struct for emulating the loadbalancer behavior. it sets the ingress to the cluster IP
// loadBalancerEmulator is the main struct for emulating the loadbalancer behavior. it sets the ingress to the cluster IP
type loadBalancerEmulator struct {
coreV1Client typed_core.CoreV1Interface
requestSender requestSender

View File

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

View File

@ -31,9 +31,9 @@ import (
// ID represents a registry ID
type ID struct {
//Route is the key
// Route is the key
Route *Route
//the rest is metadata
// the rest is metadata
MachineName string
Pid int
}

View File

@ -25,7 +25,7 @@ import (
"github.com/golang/glog"
)
//reporter that reports the status of a tunnel
// reporter that reports the status of a tunnel
type reporter interface {
Report(tunnelState *Status)
}

View File

@ -100,7 +100,7 @@ Got: "%s"`, tc.name, tc.expectedOutput, out.output)
})
}
//testing deduplication
// testing deduplication
out := &recordingWriter{}
reporter := newReporter(out)
reporter.Report(testCases[0].tunnelState)

View File

@ -23,19 +23,19 @@ import (
"github.com/golang/glog"
)
//router manages the routing table on the host, implementations should cater for OS specific methods
// router manages the routing table on the host, implementations should cater for OS specific methods
type router interface {
//Inspect checks if the given route exists or not in the routing table
//conflict is defined as: same destination CIDR, different Gateway
//overlaps are defined as: routes that have overlapping but not exactly matching destination CIDR
// Inspect checks if the given route exists or not in the routing table
// conflict is defined as: same destination CIDR, different Gateway
// overlaps are defined as: routes that have overlapping but not exactly matching destination CIDR
Inspect(route *Route) (exists bool, conflict string, overlaps []string, err error)
//EnsureRouteIsAdded is an idempotent way to add a route to the routing table
//it fails if there is a conflict
// EnsureRouteIsAdded is an idempotent way to add a route to the routing table
// it fails if there is a conflict
EnsureRouteIsAdded(route *Route) error
//Cleanup is an idempotent way to remove a route from the routing table
//it fails if there is a conflict
// Cleanup is an idempotent way to remove a route from the routing table
// it fails if there is a conflict
Cleanup(route *Route) error
}
@ -67,8 +67,8 @@ func isValidToAddOrDelete(router router, r *Route) (bool, error) {
return false, nil
}
//a partial representation of the routing table on the host
//tunnel only requires the destination CIDR, the gateway and the actual textual representation per line
// a partial representation of the routing table on the host
// tunnel only requires the destination CIDR, the gateway and the actual textual representation per line
type routingTable []routingTableLine
func (t *routingTable) Check(route *Route) (exists bool, conflict string, overlaps []string) {

View File

@ -77,12 +77,12 @@ func (router *osRouter) parseTable(table []byte) routingTable {
t := routingTable{}
skip := true
for _, line := range strings.Split(string(table), "\n") {
//header
// header
if strings.HasPrefix(line, "Destination") {
skip = false
continue
}
//don't care about the 0.0.0.0 routes
// don't care about the 0.0.0.0 routes
if skip || strings.HasPrefix(line, "default") {
continue
}

View File

@ -74,7 +74,7 @@ func (router *osRouter) parseTable(table []byte) routingTable {
fields := strings.Fields(line)
//don't care about the routes that 0.0.0.0
// don't care about the routes that 0.0.0.0
if len(fields) == 0 ||
len(fields) > 0 && (fields[0] == "default" || fields[0] == "0.0.0.0") {
continue
@ -82,12 +82,12 @@ func (router *osRouter) parseTable(table []byte) routingTable {
if len(fields) > 2 {
//assuming "10.96.0.0/12 via 192.168.39.47 dev virbr1"
// assuming "10.96.0.0/12 via 192.168.39.47 dev virbr1"
dstCIDRString := fields[0]
gatewayIPString := fields[2]
gatewayIP := net.ParseIP(gatewayIPString)
//if not via format, then gateway is assumed to be 0.0.0.0
// if not via format, then gateway is assumed to be 0.0.0.0
// "1.2.3.0/24 dev eno1 proto kernel scope link src 1.2.3.54 metric 100"
if fields[1] != "via" {
gatewayIP = net.ParseIP("0.0.0.0")

View File

@ -64,14 +64,14 @@ func (router *osRouter) parseTable(table []byte) routingTable {
t := routingTable{}
skip := true
for _, line := range strings.Split(string(table), "\n") {
//after first line of header we can start consuming
// after first line of header we can start consuming
if strings.HasPrefix(line, "Network Destination") {
skip = false
continue
}
fields := strings.Fields(line)
//don't care about the 0.0.0.0 routes
// don't care about the 0.0.0.0 routes
if skip || len(fields) == 0 || len(fields) > 0 && (fields[0] == "default" || fields[0] == "0.0.0.0") {
continue
}

View File

@ -32,8 +32,8 @@ func (r *recordingReporter) Report(tunnelState *Status) {
r.statesRecorded = append(r.statesRecorded, tunnelState)
}
//simulating idempotent router behavior
//without checking for conflicting routes
// simulating idempotent router behavior
// without checking for conflicting routes
type fakeRouter struct {
rt routingTable
errorResponse error

View File

@ -32,9 +32,9 @@ import (
"k8s.io/minikube/pkg/minikube/constants"
)
//tunnel represents the basic API for a tunnel: periodically the state of the tunnel
//can be updated and when the tunnel is not needed, it can be cleaned up
//It was mostly introduced for testability.
// tunnel represents the basic API for a tunnel: periodically the state of the tunnel
// can be updated and when the tunnel is not needed, it can be cleaned up
// It was mostly introduced for testability.
type controller interface {
cleanup() *Status
update() *Status
@ -85,7 +85,7 @@ func newTunnel(machineName string, machineAPI libmachine.API, configLoader confi
}
type tunnel struct {
//collaborators
// collaborators
clusterInspector *clusterInspector
router router
loadBalancerEmulator loadBalancerEmulator
@ -142,8 +142,8 @@ func setupRoute(t *tunnel, h *host.Host) {
if t.status.RouteError != nil {
return
}
//the route was added successfully, we need to make sure the registry has it too
//this might fail in race conditions, when another process created this tunnel
// the route was added successfully, we need to make sure the registry has it too
// this might fail in race conditions, when another process created this tunnel
if err := t.registry.Register(&t.status.TunnelID); err != nil {
glog.Errorf("failed to register tunnel: %s", err)
t.status.RouteError = err
@ -151,7 +151,7 @@ func setupRoute(t *tunnel, h *host.Host) {
}
if h.DriverName == constants.DriverHyperkit {
//the virtio-net interface acts up with ip tunnels :(
// the virtio-net interface acts up with ip tunnels :(
setupBridge(t)
if t.status.RouteError != nil {
return
@ -166,7 +166,7 @@ func setupRoute(t *tunnel, h *host.Host) {
return
}
//the route exists, make sure that this process owns it in the registry
// the route exists, make sure that this process owns it in the registry
existingTunnel, err := t.registry.IsAlreadyDefinedAndRunning(&t.status.TunnelID)
if err != nil {
glog.Errorf("failed to check for other tunnels: %s", err)
@ -175,7 +175,7 @@ func setupRoute(t *tunnel, h *host.Host) {
}
if existingTunnel == nil {
//the route exists, but "orphaned", this process will "own it" in the registry
// the route exists, but "orphaned", this process will "own it" in the registry
if err := t.registry.Register(&t.status.TunnelID); err != nil {
glog.Errorf("failed to register tunnel: %s", err)
t.status.RouteError = err
@ -184,7 +184,7 @@ func setupRoute(t *tunnel, h *host.Host) {
}
if existingTunnel.Pid != getPid() {
//another running process owns the tunnel
// another running process owns the tunnel
t.status.RouteError = errorTunnelAlreadyExists(existingTunnel)
return
}

View File

@ -38,7 +38,7 @@ type Manager struct {
router router
}
//stateCheckInterval defines how frequently the cluster and route states are checked
// stateCheckInterval defines how frequently the cluster and route states are checked
const stateCheckInterval = 5 * time.Second
// NewManager creates a new Manager
@ -68,7 +68,7 @@ func (mgr *Manager) startTunnel(ctx context.Context, tunnel controller) (done ch
check := make(chan bool, 1)
done = make(chan bool, 1)
//simulating Ctrl+C so that we can cancel the tunnel programmatically too
// simulating Ctrl+C so that we can cancel the tunnel programmatically too
go mgr.timerLoop(ready, check)
go mgr.run(ctx, tunnel, ready, check, done)

View File

@ -29,7 +29,7 @@ import (
func TestTunnelManagerEventHandling(t *testing.T) {
tcs := []struct {
//tunnel inputs
// tunnel inputs
name string
repeat int
test func(tunnel *tunnelStub, cancel context.CancelFunc, ready, check, done chan bool) error
@ -120,7 +120,7 @@ func TestTunnelManagerEventHandling(t *testing.T) {
},
}
//t.Parallel()
// t.Parallel()
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
var err error

View File

@ -69,7 +69,7 @@ func TestCacheMinikubeISOFromURL(t *testing.T) {
t.Fatalf("File not copied. Could not open file at path: %s", isoPath)
}
//test that the ISO is transferred properly
// test that the ISO is transferred properly
contents := []byte(testISOString)
if !bytes.Contains(transferred, contents) {
t.Fatalf("Expected transfers to contain: %s. It was: %s", contents, transferred)

View File

@ -313,7 +313,7 @@ func GetPortFromKubeConfig(filename, machineName string) (int, error) {
return port, err
}
//UnsetCurrentContext unsets the current-context from minikube to "" on minikube stop
// UnsetCurrentContext unsets the current-context from minikube to "" on minikube stop
func UnsetCurrentContext(filename, machineName string) error {
confg, err := ReadConfigOrNew(filename)
if err != nil {
@ -332,7 +332,7 @@ func UnsetCurrentContext(filename, machineName string) error {
return nil
}
//SetCurrentContext sets the kubectl's current-context
// SetCurrentContext sets the kubectl's current-context
func SetCurrentContext(kubeCfgPath, name string) error {
kcfg, err := ReadConfigOrNew(kubeCfgPath)
if err != nil {

View File

@ -266,7 +266,7 @@ func WaitForService(c kubernetes.Interface, namespace, name string, exist bool,
return nil
}
//WaitForServiceEndpointsNum waits until the amount of endpoints that implement service to expectNum.
// WaitForServiceEndpointsNum waits until the amount of endpoints that implement service to expectNum.
func WaitForServiceEndpointsNum(c kubernetes.Interface, namespace, serviceName string, expectNum int, interval, timeout time.Duration) error {
return wait.Poll(interval, timeout, func() (bool, error) {
glog.Infof("Waiting for amount of service:%s endpoints to be %d", serviceName, expectNum)

View File

@ -29,7 +29,7 @@ func testClusterLogs(t *testing.T) {
minikubeRunner.EnsureRunning()
logsCmdOutput := minikubeRunner.GetLogs()
//check for # of lines or check for strings
// check for # of lines or check for strings
logWords := []string{"minikube", ".go"}
for _, logWord := range logWords {
if !strings.Contains(logsCmdOutput, logWord) {

View File

@ -21,7 +21,7 @@ func StartServer(addrVal string, debugVal int, rootVal string) {
fmt.Print("ufs starting\n")
// determined by build tags
//extraFuncs()
// extraFuncs()
err := ufs.StartNetListener("tcp", addrVal)
if err != nil {
log.Println(err)

View File

@ -225,7 +225,7 @@ func (u *Ufs) Wstat(req *SrvReq) {
case true:
mt = st.ModTime()
default:
//at = time.Time(0)//atime(st.Sys().(*syscall.Stat_t))
// at = time.Time(0)//atime(st.Sys().(*syscall.Stat_t))
}
}
// macOS filesystem st_mtime values are only accurate to the second

View File

@ -219,7 +219,7 @@ func (u *Ufs) Wstat(req *SrvReq) {
case true:
mt = st.ModTime()
default:
//at = time.Time(0)//atime(st.Sys().(*syscall.Stat_t))
// at = time.Time(0)//atime(st.Sys().(*syscall.Stat_t))
}
}
e := os.Chtimes(fid.path, at, mt)