Added documentation for alpha cli command (#4412)

Added comments to document several methods and strucs on cmd package. Based on GoDoc guidelines. Focus on alpha cli command

Signed-off-by: arthursens <arthursens2005@gmail.com>
This commit is contained in:
Arthur Silva Sens 2020-05-26 17:59:56 -03:00 committed by GitHub
parent a8158dbeac
commit bfedcd5485
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import (
"github.com/spf13/cobra"
)
// newCmdAlpha creates a new cobra command `alpha` which contains experimental subcommands for linkerd
func newCmdAlpha() *cobra.Command {
alphaCmd := &cobra.Command{
Use: "alpha",

View File

@ -12,10 +12,15 @@ import (
corev1 "k8s.io/api/core/v1"
)
// alphaClientsOptions holds values for command line flags that apply to the alpha
// clients command. All fields in this struct should have corresponding flags added in
// the newCmdAlphaClients func later in this file.
type alphaClientsOptions struct {
namespace string
}
// newCmdAlphaClients creates a new cobra command for the `alpha clients` subcommand which
// display client-side traffic stats to a resource. [Experimental]
func newCmdAlphaClients() *cobra.Command {
options := alphaClientsOptions{
namespace: corev1.NamespaceDefault,

View File

@ -30,12 +30,17 @@ var allowedKinds = map[string]struct{}{
k8s.StatefulSet: struct{}{},
}
// alphaStatOptions holds values for command line flags that apply to the alpha
// stat command. All fields in this struct should have corresponding flags added in
// the newCmdAlphaStat func later in this file.
type alphaStatOptions struct {
namespace string
toResource string
allNamespaces bool
}
// newCmdAlphaStat creates a new cobra command for the `alpha stat` subcommand which
// display traffic stats about one or many resources. [Experimental]
func newCmdAlphaStat() *cobra.Command {
options := alphaStatOptions{
namespace: "default",
@ -45,7 +50,7 @@ func newCmdAlphaStat() *cobra.Command {
Use: "stat [flags] (RESOURCE)",
Short: "Display traffic stats about one or many resources",
Long: `Display traffic stats about one or many resources
(RESOURCE) can be a resource kind; one of:
* cronjobs
* daemonsets
@ -176,6 +181,8 @@ func renderTrafficMetricsList(metrics *v1alpha1.TrafficMetricsList, allNamespace
t.Render(w)
}
// renderTrafficMetricsEdgesList will render a table to the given Writer.
// Rows will be filtered to make sure that only traffic directed to the resource requested by the `--to` flag is shown
func renderTrafficMetricsEdgesList(metrics *v1alpha1.TrafficMetricsList, w io.Writer, toResource *public.Resource, direction string) {
t := buildTable(true, false)
t.Data = []table.Row{}

View File

@ -80,7 +80,7 @@ func newCmdProfile() *cobra.Command {
Short: "Output service profile config for Kubernetes",
Long: "Output service profile config for Kubernetes.",
Example: ` # Output a basic template to apply after modification.
linkerd profile -n emoijvoto --template web-svc
linkerd profile -n emojivoto --template web-svc
# Generate a profile from an OpenAPI specification.
linkerd profile -n emojivoto --open-api web-svc.swagger web-svc