(cliCtx *cli.Context, cfgFile string)
| 94 | } |
| 95 | |
| 96 | func newCRUDClient(cliCtx *cli.Context, cfgFile string) (crudClient, error) { |
| 97 | // os.Stat("") probably returns os.ErrNotExist, but this behavior is |
| 98 | // undocumented so we'll handle this case separately. |
| 99 | if cfgFile == "" { |
| 100 | return cautils.NewAdminClient(cliCtx) |
| 101 | } |
| 102 | |
| 103 | _, err := os.Stat(cfgFile) |
| 104 | switch { |
| 105 | case errors.Is(err, os.ErrNotExist): |
| 106 | return cautils.NewAdminClient(cliCtx) |
| 107 | case err == nil: |
| 108 | ui.PrintSelected("CA Configuration", cfgFile) |
| 109 | cfg, err := config.LoadConfiguration(cfgFile) |
| 110 | if err != nil { |
| 111 | return nil, fmt.Errorf("error loading configuration: %w", err) |
| 112 | } |
| 113 | if cfg.AuthorityConfig.EnableAdmin { |
| 114 | return cautils.NewAdminClient(cliCtx) |
| 115 | } |
| 116 | return nil, errors.New("the admin API must be enabled to use webhooks") |
| 117 | default: |
| 118 | return nil, errs.FileError(err, cfgFile) |
| 119 | } |
| 120 | } |
no test coverage detected
searching dependent graphs…