mirror of https://github.com/linkerd/linkerd2.git
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:
parent
a8158dbeac
commit
bfedcd5485
|
@ -4,6 +4,7 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// newCmdAlpha creates a new cobra command `alpha` which contains experimental subcommands for linkerd
|
||||||
func newCmdAlpha() *cobra.Command {
|
func newCmdAlpha() *cobra.Command {
|
||||||
alphaCmd := &cobra.Command{
|
alphaCmd := &cobra.Command{
|
||||||
Use: "alpha",
|
Use: "alpha",
|
||||||
|
|
|
@ -12,10 +12,15 @@ import (
|
||||||
corev1 "k8s.io/api/core/v1"
|
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 {
|
type alphaClientsOptions struct {
|
||||||
namespace string
|
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 {
|
func newCmdAlphaClients() *cobra.Command {
|
||||||
options := alphaClientsOptions{
|
options := alphaClientsOptions{
|
||||||
namespace: corev1.NamespaceDefault,
|
namespace: corev1.NamespaceDefault,
|
||||||
|
|
|
@ -30,12 +30,17 @@ var allowedKinds = map[string]struct{}{
|
||||||
k8s.StatefulSet: 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 {
|
type alphaStatOptions struct {
|
||||||
namespace string
|
namespace string
|
||||||
toResource string
|
toResource string
|
||||||
allNamespaces bool
|
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 {
|
func newCmdAlphaStat() *cobra.Command {
|
||||||
options := alphaStatOptions{
|
options := alphaStatOptions{
|
||||||
namespace: "default",
|
namespace: "default",
|
||||||
|
@ -176,6 +181,8 @@ func renderTrafficMetricsList(metrics *v1alpha1.TrafficMetricsList, allNamespace
|
||||||
t.Render(w)
|
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) {
|
func renderTrafficMetricsEdgesList(metrics *v1alpha1.TrafficMetricsList, w io.Writer, toResource *public.Resource, direction string) {
|
||||||
t := buildTable(true, false)
|
t := buildTable(true, false)
|
||||||
t.Data = []table.Row{}
|
t.Data = []table.Row{}
|
||||||
|
|
|
@ -80,7 +80,7 @@ func newCmdProfile() *cobra.Command {
|
||||||
Short: "Output service profile config for Kubernetes",
|
Short: "Output service profile config for Kubernetes",
|
||||||
Long: "Output service profile config for Kubernetes.",
|
Long: "Output service profile config for Kubernetes.",
|
||||||
Example: ` # Output a basic template to apply after modification.
|
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.
|
# Generate a profile from an OpenAPI specification.
|
||||||
linkerd profile -n emojivoto --open-api web-svc.swagger web-svc
|
linkerd profile -n emojivoto --open-api web-svc.swagger web-svc
|
||||||
|
|
Loading…
Reference in New Issue