(path string)
| 38 | } |
| 39 | |
| 40 | func getAllCredentialsForPath(path string) ([]credentials.Credential, error) { |
| 41 | cfg := config.ReadConfig() |
| 42 | credhubClient, err := initializeCredhubClient(cfg) |
| 43 | |
| 44 | if err != nil { |
| 45 | return nil, err |
| 46 | } |
| 47 | |
| 48 | allPaths, err := credhubClient.FindByPath(path) |
| 49 | |
| 50 | if err != nil { |
| 51 | return nil, err |
| 52 | } |
| 53 | |
| 54 | credentials := make([]credentials.Credential, len(allPaths.Credentials)) |
| 55 | for i, baseCred := range allPaths.Credentials { |
| 56 | credential, err := credhubClient.GetLatestVersion(baseCred.Name) |
| 57 | |
| 58 | if err != nil { |
| 59 | return nil, err |
| 60 | } |
| 61 | |
| 62 | if credential.Type == "certificate" { |
| 63 | certMetadata, err := credhubClient.GetCertificateMetadataByName(credential.Name) |
| 64 | |
| 65 | if err != nil { |
| 66 | return nil, err |
| 67 | } |
| 68 | signedBy := certMetadata.SignedBy |
| 69 | |
| 70 | if signedBy != "" && signedBy != credential.Name { |
| 71 | if cert, ok := credential.Value.(map[string]interface{}); ok { |
| 72 | cert["ca_name"] = signedBy |
| 73 | delete(cert, "ca") |
| 74 | credential.Value = cert |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | credentials[i] = credential |
| 79 | } |
| 80 | |
| 81 | return credentials, nil |
| 82 | } |
no test coverage detected
searching dependent graphs…