(ctx context.Context, cfg *cli.Config, orgAPID, realmAPID, chainAPID, serviceAPID string)
| 257 | } |
| 258 | |
| 259 | func (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 | } |
no test coverage detected