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

Function configAction

command/ssh/config.go:112–304  ·  view source on GitHub ↗
(ctx *cli.Context)

Source from the content-addressed store, hash-verified

110}
111
112func configAction(ctx *cli.Context) (recoverErr error) {
113 team := ctx.String("team")
114 isHost := ctx.Bool("host")
115 isRoots := ctx.Bool("roots")
116 isFederation := ctx.Bool("federation")
117 sets := ctx.StringSlice("set")
118
119 switch {
120 case team != "" && isHost:
121 return errs.IncompatibleFlagWithFlag(ctx, "team", "host")
122 case team != "" && isRoots:
123 return errs.IncompatibleFlagWithFlag(ctx, "team", "roots")
124 case team != "" && isFederation:
125 return errs.IncompatibleFlagWithFlag(ctx, "team", "federation")
126 case team != "" && len(sets) > 0:
127 return errs.IncompatibleFlagWithFlag(ctx, "team", "set")
128 case isRoots && isFederation:
129 return errs.IncompatibleFlagWithFlag(ctx, "roots", "federation")
130 case isRoots && len(sets) > 0:
131 return errs.IncompatibleFlagWithFlag(ctx, "roots", "set")
132 case isFederation && len(sets) > 0:
133 return errs.IncompatibleFlagWithFlag(ctx, "federation", "set")
134 }
135
136 // Bootstrap Authority
137 if team != "" {
138 teamAuthority := ctx.String("team-authority")
139 // Default to the default SSH authority.
140 if teamAuthority == "" {
141 teamAuthority = "ssh"
142 }
143 if err := cautils.BootstrapTeamAuthority(ctx, team, teamAuthority); err != nil {
144 return err
145 }
146 } else {
147 if err := step.Contexts().Apply(ctx); err != nil {
148 return err
149 }
150 }
151
152 // Prepare retry function
153 retryFunc, err := loginOnUnauthorized(ctx)
154 if err != nil {
155 return err
156 }
157
158 // Initialize CA client with login if needed.
159 client, err := cautils.NewClient(ctx, ca.WithRetryFunc(retryFunc))
160 if err != nil {
161 return err
162 }
163
164 // Prints user or host keys
165 if isRoots || isFederation {
166 var roots *api.SSHRootsResponse
167 if isRoots {
168 roots, err = client.SSHRoots()
169 } else {

Callers

nothing calls this directly

Calls 11

BootstrapTeamAuthorityFunction · 0.92
NewClientFunction · 0.92
DialAgentFunction · 0.92
WithSignatureKeyFunction · 0.92
loginOnUnauthorizedFunction · 0.85
TypeMethod · 0.80
ListCertificatesMethod · 0.80
StringMethod · 0.65
SSHRootsMethod · 0.65
SSHFederationMethod · 0.65
SSHConfigMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…