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

Function NewClient

utils/cautils/client.go:52–74  ·  view source on GitHub ↗

NewClient returns a client of an online or offline CA. Requires the flags `offline`, `ca-config`, `ca-url`, and `root`.

(ctx *cli.Context, opts ...ca.ClientOption)

Source from the content-addressed store, hash-verified

50// NewClient returns a client of an online or offline CA. Requires the flags
51// `offline`, `ca-config`, `ca-url`, and `root`.
52func NewClient(ctx *cli.Context, opts ...ca.ClientOption) (CaClient, error) {
53 if ctx.Bool("offline") {
54 caConfig := ctx.String("ca-config")
55 if caConfig == "" {
56 return nil, errs.InvalidFlagValue(ctx, "ca-config", "", "")
57 }
58 return NewOfflineCA(ctx, caConfig)
59 }
60
61 caURL, err := flags.ParseCaURL(ctx)
62 if err != nil {
63 return nil, err
64 }
65 root := ctx.String("root")
66 if root == "" {
67 root = pki.GetRootCAPath()
68 if _, err := os.Stat(root); err != nil {
69 return nil, errs.RequiredFlag(ctx, "root")
70 }
71 }
72 opts = append([]ca.ClientOption{ca.WithRootFile(root)}, opts...)
73 return ca.NewClient(caURL, opts...)
74}
75
76// NewUnauthenticatedAdminClient returns a unauthenticated client for the mgmt API of the online CA.
77func NewUnauthenticatedAdminClient(ctx *cli.Context, opts ...ca.ClientOption) (*ca.AdminClient, error) {

Callers 8

doLoginIfNeededFunction · 0.92
getBastionFunction · 0.92
loginOnUnauthorizedFunction · 0.92
loginActionFunction · 0.92
hostsActionFunction · 0.92
logoutActionFunction · 0.92
configActionFunction · 0.92
checkHostActionFunction · 0.92

Calls 3

ParseCaURLFunction · 0.92
NewOfflineCAFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…