MCPcopy
hub / github.com/crowdsecurity/crowdsec / newRegisterCmd

Method newRegisterCmd

cmd/crowdsec-cli/clicapi/capi.go:128–159  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

126}
127
128func (cli *cliCapi) newRegisterCmd() *cobra.Command {
129 var (
130 capiUserPrefix string
131 outputFile string
132 )
133
134 cmd := &cobra.Command{
135 Use: "register",
136 Short: "Register to Central API (CAPI)",
137 Args: args.NoArgs,
138 DisableAutoGenTag: true,
139 RunE: func(cmd *cobra.Command, _ []string) error {
140 cfg := cli.cfg()
141 if err := require.LAPINoOnlineCreds(cfg); err != nil {
142 return err
143 }
144
145 if err := require.CAPI(cfg); err != nil {
146 return err
147 }
148
149 return cli.register(cmd.Context(), capiUserPrefix, outputFile)
150 },
151 }
152
153 cmd.Flags().StringVarP(&outputFile, "file", "f", "", "output file destination")
154 cmd.Flags().StringVar(&capiUserPrefix, "schmilblick", "", "set a schmilblick (use in tests only)")
155
156 _ = cmd.Flags().MarkHidden("schmilblick")
157
158 return cmd
159}
160
161type capiStatus struct {
162 authenticated bool

Callers 1

NewCommandMethod · 0.95

Calls 4

registerMethod · 0.95
LAPINoOnlineCredsFunction · 0.92
CAPIFunction · 0.92
cfgMethod · 0.80

Tested by

no test coverage detected