Merge pull request #1080 from sivanzcw/develop

Add comments for exported function or method
This commit is contained in:
Kubernetes Prow Robot
2019-11-10 10:31:39 -08:00
committed by GitHub
7 changed files with 12 additions and 0 deletions

View File

@@ -66,6 +66,9 @@ func ExternalLoadBalancerNode(allNodes []nodes.Node) (nodes.Node, error) {
return loadBalancerNodes[0], nil
}
// APIServerEndpointNode selects the node from allNodes which hosts the API Server endpoint
// This should be the control plane node if there is one control plane node, or a LoadBalancer otherwise.
// It returns an error if the node list is invalid (E.G. two control planes and no load balancer)
func APIServerEndpointNode(allNodes []nodes.Node) (nodes.Node, error) {
if n, err := ExternalLoadBalancerNode(allNodes); err != nil {
return nil, errors.Wrap(err, "failed to find api-server endpoint node")

View File

@@ -97,6 +97,7 @@ func CopyNodeToNode(a, b nodes.Node, file string) error {
return nil
}
// LoadImageArchive loads image onto the node, where image is a Reader over an image archive
func LoadImageArchive(n nodes.Node, image io.Reader) error {
cmd := n.Command("ctr", "--namespace=k8s.io", "images", "import", "-").SetStdin(image)
if err := cmd.Run(); err != nil {
@@ -105,6 +106,7 @@ func LoadImageArchive(n nodes.Node, image io.Reader) error {
return nil
}
// ImageID returns ID of image on the node with the given image name if present
func ImageID(n nodes.Node, image string) (string, error) {
var out bytes.Buffer
if err := n.Command("crictl", "inspecti", image).SetStdout(&out).Run(); err != nil {

View File

@@ -20,6 +20,7 @@ import (
v1alpha3 "sigs.k8s.io/kind/pkg/apis/config/v1alpha3"
)
// Convertv1alpha3 converts a v1alpha3 cluster to a cluster at the internal API version
func Convertv1alpha3(in *v1alpha3.Cluster) *Cluster {
in = in.DeepCopy() // deep copy first to avoid touching the original
out := &Cluster{

View File

@@ -20,6 +20,7 @@ import (
v1alpha4 "sigs.k8s.io/kind/pkg/apis/config/v1alpha4"
)
// Convertv1alpha4 converts a v1alpha4 cluster to a cluster at the internal API version
func Convertv1alpha4(in *v1alpha4.Cluster) *Cluster {
in = in.DeepCopy() // deep copy first to avoid touching the original
out := &Cluster{

View File

@@ -51,6 +51,7 @@ func NewContext(logger log.Logger, name string) *Context {
}
}
// NewProviderContext returns a new context with given provider and name
func NewProviderContext(p provider.Provider, name string) *Context {
return &Context{
name: name,
@@ -63,10 +64,12 @@ func (c *Context) Name() string {
return c.name
}
// Provider returns the provider of the context
func (c *Context) Provider() provider.Provider {
return c.provider
}
// GetAPIServerEndpoint returns the cluster's API Server endpoint
func (c *Context) GetAPIServerEndpoint() (string, error) {
return c.provider.GetAPIServerEndpoint(c.Name())
}

View File

@@ -133,6 +133,7 @@ func (p *Provider) DeleteNodes(n []nodes.Node) error {
return nil
}
// GetAPIServerEndpoint is part of the providers.Provider interface
func (p *Provider) GetAPIServerEndpoint(cluster string) (string, error) {
// locate the node that hosts this
allNodes, err := p.ListNodes(cluster)

View File

@@ -47,6 +47,7 @@ func NewLogger(writer io.Writer, verbosity log.Level) *Logger {
}
}
// SetWriter sets the output writer
func (l *Logger) SetWriter(w io.Writer) {
l.writerMu.Lock()
defer l.writerMu.Unlock()