MCPcopy Create free account
hub / github.com/anchordotdev/cli / subcaAPID

Method subcaAPID

lcl/mkcert.go:259–284  ·  view source on GitHub ↗
(ctx context.Context, cfg *cli.Config, orgAPID, realmAPID, chainAPID, serviceAPID string)

Source from the content-addressed store, hash-verified

257}
258
259func (c *MkCert) subcaAPID(ctx context.Context, cfg *cli.Config, orgAPID, realmAPID, chainAPID, serviceAPID string) (string, error) {
260 if c.SubCaAPID != "" {
261 return c.SubCaAPID, nil
262 }
263
264 if cfg.Lcl.MkCert.SubCa != "" {
265 c.SubCaAPID = cfg.Lcl.MkCert.SubCa
266 return cfg.Lcl.MkCert.SubCa, nil
267 }
268
269 attachments, err := c.anc.GetServiceAttachments(ctx, orgAPID, serviceAPID)
270 if err != nil {
271 return "", err
272 }
273
274 for _, a := range attachments {
275 if a.Relationships.Realm.Apid == realmAPID && a.Relationships.Chain.Apid == chainAPID {
276 c.SubCaAPID = cfg.Lcl.MkCert.SubCa
277 return *a.Relationships.SubCa.Apid, nil
278 }
279 }
280
281 return "", cli.UserError{
282 Err: fmt.Errorf("invalid org, realm, and service combination"),
283 }
284}

Callers 1

performMethod · 0.95

Calls 1

GetServiceAttachmentsMethod · 0.80

Tested by

no test coverage detected