forked from DataDog/KubeHound
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathingestor.go
38 lines (33 loc) · 1.02 KB
/
ingestor.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
package main
import (
"fmt"
"github.com/DataDog/KubeHound/pkg/cmd"
"github.com/DataDog/KubeHound/pkg/kubehound/core"
"github.com/spf13/cobra"
)
var (
ingestorCmd = &cobra.Command{
Use: "ingest",
Short: "Kubehound Ingestor Service - exposes a gRPC API to ingest data from cloud storage",
Long: `instance of Kubehound that pulls data from cloud storage`,
SilenceUsage: true,
PersistentPreRunE: func(cobraCmd *cobra.Command, args []string) error {
return cmd.InitializeKubehoundConfig(cobraCmd.Context(), cfgFile, true, false)
},
RunE: func(cobraCmd *cobra.Command, args []string) error {
// Passing the Kubehound config from viper
khCfg, err := cmd.GetConfig()
if err != nil {
return fmt.Errorf("get config: %w", err)
}
return core.CoreGrpcApi(cobraCmd.Context(), khCfg)
},
PersistentPostRunE: func(cobraCmd *cobra.Command, args []string) error {
return cmd.CloseKubehoundConfig()
},
}
)
func init() {
cmd.InitRootCmd(ingestorCmd)
rootCmd.AddCommand(ingestorCmd)
}