(client AWSCodeDeployClientInterface, accountID string, region string)
| 126 | } |
| 127 | |
| 128 | func CachedCodeDeployListDeployments(client AWSCodeDeployClientInterface, accountID string, region string) ([]string, error) { |
| 129 | var PaginationControl *string |
| 130 | var deployments []string |
| 131 | cacheKey := fmt.Sprintf("%s-codedeploy-ListDeployments-%s", accountID, region) |
| 132 | cached, found := internal.Cache.Get(cacheKey) |
| 133 | if found { |
| 134 | sharedLogger.WithFields(logrus.Fields{ |
| 135 | "api": "codedeploy:ListDeployments", |
| 136 | "account": accountID, |
| 137 | "region": region, |
| 138 | "cache": "hit", |
| 139 | }).Info("AWS API call") |
| 140 | return cached.([]string), nil |
| 141 | } |
| 142 | sharedLogger.WithFields(logrus.Fields{ |
| 143 | "api": "codedeploy:ListDeployments", |
| 144 | "account": accountID, |
| 145 | "region": region, |
| 146 | "cache": "miss", |
| 147 | }).Info("AWS API call") |
| 148 | for { |
| 149 | ListDeployments, err := client.ListDeployments( |
| 150 | context.TODO(), |
| 151 | &codedeploy.ListDeploymentsInput{ |
| 152 | NextToken: PaginationControl, |
| 153 | }, |
| 154 | func(o *codedeploy.Options) { |
| 155 | o.Region = region |
| 156 | }, |
| 157 | ) |
| 158 | |
| 159 | if err != nil { |
| 160 | return deployments, err |
| 161 | } |
| 162 | |
| 163 | deployments = append(deployments, ListDeployments.Deployments...) |
| 164 | |
| 165 | //pagination |
| 166 | if ListDeployments.NextToken == nil { |
| 167 | break |
| 168 | } |
| 169 | PaginationControl = ListDeployments.NextToken |
| 170 | } |
| 171 | |
| 172 | internal.Cache.Set(cacheKey, deployments, cache.DefaultExpiration) |
| 173 | return deployments, nil |
| 174 | } |
| 175 | |
| 176 | func CachedCodeDeployGetApplication(client AWSCodeDeployClientInterface, accountID string, region string, applicationName string) (codeDeployTypes.ApplicationInfo, error) { |
| 177 | cacheKey := fmt.Sprintf("%s-codedeploy-GetApplication-%s-%s", accountID, region, applicationName) |
no test coverage detected