-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy pathdatadog.go
More file actions
68 lines (54 loc) · 2.1 KB
/
datadog.go
File metadata and controls
68 lines (54 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.
package datadog
import (
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"github.com/DataDog/datadog-operator/cmd/kubectl-datadog/agent/agent"
"github.com/DataDog/datadog-operator/cmd/kubectl-datadog/autoscaling"
"github.com/DataDog/datadog-operator/cmd/kubectl-datadog/clusteragent/clusteragent"
"github.com/DataDog/datadog-operator/cmd/kubectl-datadog/flare"
"github.com/DataDog/datadog-operator/cmd/kubectl-datadog/get"
"github.com/DataDog/datadog-operator/cmd/kubectl-datadog/helm2dda"
"github.com/DataDog/datadog-operator/cmd/kubectl-datadog/mcp"
"github.com/DataDog/datadog-operator/cmd/kubectl-datadog/metrics"
"github.com/DataDog/datadog-operator/cmd/kubectl-datadog/validate/validate"
)
// options provides information required by datadog command
type options struct {
genericclioptions.IOStreams
configFlags *genericclioptions.ConfigFlags
}
// newOptions provides an instance of options with default values
func newOptions(streams genericclioptions.IOStreams) *options {
return &options{
configFlags: genericclioptions.NewConfigFlags(false),
IOStreams: streams,
}
}
// NewCmd provides a cobra command wrapping options for "datadog" command
func NewCmd(streams genericclioptions.IOStreams) *cobra.Command {
cmd := &cobra.Command{
Use: "datadog [subcommand] [flags]",
}
// Operator commands
cmd.AddCommand(get.New(streams))
cmd.AddCommand(flare.New(streams))
cmd.AddCommand(validate.New(streams))
cmd.AddCommand(mcp.New(streams))
// Agent commands
cmd.AddCommand(agent.New(streams))
// Cluster Agent commands
cmd.AddCommand(clusteragent.New(streams))
// DatadogMetric commands
cmd.AddCommand(metrics.New(streams))
// Autoscaling commands
cmd.AddCommand(autoscaling.New(streams))
// Helm mapper commands
cmd.AddCommand(helm2dda.New(streams))
o := newOptions(streams)
o.configFlags.AddFlags(cmd.Flags())
return cmd
}