(ctx context.Context, db *database.Client, out io.Writer, hub *cwhub.Hub)
| 214 | } |
| 215 | |
| 216 | func (cli *cliCapi) Status(ctx context.Context, db *database.Client, out io.Writer, hub *cwhub.Hub) error { |
| 217 | cfg := cli.cfg() |
| 218 | |
| 219 | if err := require.CAPIRegistered(cfg); err != nil { |
| 220 | return err |
| 221 | } |
| 222 | |
| 223 | cred := cfg.API.Server.OnlineClient.Credentials |
| 224 | |
| 225 | fmt.Fprintf(out, "Loaded credentials from %s\n", cfg.API.Server.OnlineClient.CredentialsFilePath) |
| 226 | fmt.Fprintf(out, "Trying to authenticate with username %s on %s\n", cred.Login, cred.URL) |
| 227 | |
| 228 | status, err := queryCAPIStatus(ctx, db, hub, cred.URL, cred.Login, cred.Password) |
| 229 | if err != nil { |
| 230 | return fmt.Errorf("failed to authenticate to Central API (CAPI): %w", err) |
| 231 | } |
| 232 | |
| 233 | if status.authenticated { |
| 234 | fmt.Fprint(out, "You can successfully interact with Central API (CAPI)\n") |
| 235 | } |
| 236 | |
| 237 | if status.enrolled { |
| 238 | fmt.Fprint(out, "Your instance is enrolled in the console\n") |
| 239 | fmt.Fprintf(out, "Subscription type: %s\n", status.subscriptionType) |
| 240 | } |
| 241 | |
| 242 | switch *cfg.API.Server.OnlineClient.Sharing { |
| 243 | case true: |
| 244 | fmt.Fprint(out, "Sharing signals is enabled\n") |
| 245 | case false: |
| 246 | fmt.Fprint(out, "Sharing signals is disabled\n") |
| 247 | } |
| 248 | |
| 249 | switch *cfg.API.Server.OnlineClient.PullConfig.Community { |
| 250 | case true: |
| 251 | fmt.Fprint(out, "Pulling community blocklist is enabled\n") |
| 252 | case false: |
| 253 | fmt.Fprint(out, "Pulling community blocklist is disabled\n") |
| 254 | } |
| 255 | |
| 256 | switch *cfg.API.Server.OnlineClient.PullConfig.Blocklists { |
| 257 | case true: |
| 258 | fmt.Fprint(out, "Pulling blocklists from the console is enabled\n") |
| 259 | case false: |
| 260 | fmt.Fprint(out, "Pulling blocklists from the console is disabled\n") |
| 261 | } |
| 262 | |
| 263 | return nil |
| 264 | } |
| 265 | |
| 266 | func (cli *cliCapi) newStatusCmd() *cobra.Command { |
| 267 | cmd := &cobra.Command{ |
no test coverage detected