(ctx context.Context, out io.Writer, hub *cwhub.Hub)
| 56 | } |
| 57 | |
| 58 | func (cli *cliLapi) Status(ctx context.Context, out io.Writer, hub *cwhub.Hub) error { |
| 59 | cfg := cli.cfg() |
| 60 | |
| 61 | cred := cfg.API.Client.Credentials |
| 62 | |
| 63 | fmt.Fprintf(out, "Loaded credentials from %s\n", cfg.API.Client.CredentialsFilePath) |
| 64 | |
| 65 | if cred.Login != "" { |
| 66 | fmt.Fprintf(out, "Trying to authenticate with username %q on %s\n", cred.Login, cred.URL) |
| 67 | } |
| 68 | |
| 69 | if cred.CertPath != "" { |
| 70 | fmt.Fprintf(out, "Trying to authenticate with certificate %q on %s\n", cred.CertPath, cred.URL) |
| 71 | } |
| 72 | |
| 73 | _, err := queryLAPIStatus(ctx, hub, cred.URL, cred.Login, cred.Password) |
| 74 | if err != nil { |
| 75 | return fmt.Errorf("failed to authenticate to Local API (LAPI): %w", err) |
| 76 | } |
| 77 | |
| 78 | fmt.Fprintln(out, "You can successfully interact with Local API (LAPI)") |
| 79 | |
| 80 | return nil |
| 81 | } |
| 82 | |
| 83 | // prepareAPIURL checks/fixes a LAPI connection url (http, https or socket) and returns an URL struct |
| 84 | func prepareAPIURL(clientCfg *csconfig.LocalApiClientCfg, apiURL string) (*url.URL, error) { |
no test coverage detected