-
Notifications
You must be signed in to change notification settings - Fork 67
/
start_cmd.go
51 lines (43 loc) 路 1.43 KB
/
start_cmd.go
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
package cmd
import (
"context"
"github.com/kubeshop/tracetest/cli/config"
"github.com/kubeshop/tracetest/cli/pkg/starter"
"github.com/spf13/cobra"
)
var (
start = starter.NewStarter(configurator, resources)
saveParams = &saveParameters{}
)
var startCmd = &cobra.Command{
GroupID: cmdGroupConfig.ID,
Use: "start",
Short: "Start Tracetest",
Long: "Start using Tracetest",
PreRun: setupCommand(),
Run: WithResultHandler((func(_ *cobra.Command, _ []string) (string, error) {
ctx := context.Background()
flags := config.ConfigFlags{
OrganizationID: saveParams.organizationID,
EnvironmentID: saveParams.environmentID,
Endpoint: saveParams.endpoint,
AgentApiKey: saveParams.agentApiKey,
}
err := start.Run(ctx, cliConfig, flags)
return "", err
})),
PostRun: teardownCommand,
}
func init() {
startCmd.Flags().StringVarP(&saveParams.organizationID, "organization", "", "", "organization id")
startCmd.Flags().StringVarP(&saveParams.environmentID, "environment", "", "", "environment id")
startCmd.Flags().StringVarP(&saveParams.agentApiKey, "api-key", "", "", "agent api key")
startCmd.Flags().StringVarP(&saveParams.endpoint, "endpoint", "e", config.DefaultCloudEndpoint, "set the value for the endpoint, so the CLI won't ask for this value")
rootCmd.AddCommand(startCmd)
}
type saveParameters struct {
organizationID string
environmentID string
endpoint string
agentApiKey string
}