MCPcopy
hub / github.com/smallstep/cli / newCRUDClient

Function newCRUDClient

command/ca/provisioner/webhook/webhook.go:96–120  ·  view source on GitHub ↗
(cliCtx *cli.Context, cfgFile string)

Source from the content-addressed store, hash-verified

94}
95
96func 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}

Callers 3

updateActionFunction · 0.70
removeActionFunction · 0.70
addActionFunction · 0.70

Calls 1

NewAdminClientFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…