(client AWSCodeCommitClientInterface, accountID string, region string)
| 21 | } |
| 22 | |
| 23 | func CachedCodeCommitListRepositories(client AWSCodeCommitClientInterface, accountID string, region string) ([]codeCommitTypes.RepositoryNameIdPair, error) { |
| 24 | var PaginationControl *string |
| 25 | var repositories []codeCommitTypes.RepositoryNameIdPair |
| 26 | cacheKey := fmt.Sprintf("%s-codecommit-ListRepositories-%s", accountID, region) |
| 27 | cached, found := internal.Cache.Get(cacheKey) |
| 28 | if found { |
| 29 | sharedLogger.WithFields(logrus.Fields{ |
| 30 | "api": "codecommit:ListRepositories", |
| 31 | "account": accountID, |
| 32 | "region": region, |
| 33 | "cache": "hit", |
| 34 | }).Info("AWS API call") |
| 35 | return cached.([]codeCommitTypes.RepositoryNameIdPair), nil |
| 36 | } |
| 37 | sharedLogger.WithFields(logrus.Fields{ |
| 38 | "api": "codecommit:ListRepositories", |
| 39 | "account": accountID, |
| 40 | "region": region, |
| 41 | "cache": "miss", |
| 42 | }).Info("AWS API call") |
| 43 | for { |
| 44 | ListRepositories, err := client.ListRepositories( |
| 45 | context.TODO(), |
| 46 | &codecommit.ListRepositoriesInput{ |
| 47 | NextToken: PaginationControl, |
| 48 | }, |
| 49 | func(o *codecommit.Options) { |
| 50 | o.Region = region |
| 51 | }, |
| 52 | ) |
| 53 | |
| 54 | if err != nil { |
| 55 | return repositories, err |
| 56 | } |
| 57 | |
| 58 | repositories = append(repositories, ListRepositories.Repositories...) |
| 59 | |
| 60 | //pagination |
| 61 | if ListRepositories.NextToken == nil { |
| 62 | break |
| 63 | } |
| 64 | PaginationControl = ListRepositories.NextToken |
| 65 | } |
| 66 | |
| 67 | internal.Cache.Set(cacheKey, repositories, cache.DefaultExpiration) |
| 68 | return repositories, nil |
| 69 | } |
no test coverage detected