MCPcopy Index your code
hub / github.com/BishopFox/cloudfox / CachedCodeDeployListDeployments

Function CachedCodeDeployListDeployments

aws/sdk/codedeploy.go:128–174  ·  view source on GitHub ↗
(client AWSCodeDeployClientInterface, accountID string, region string)

Source from the content-addressed store, hash-verified

126}
127
128func 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
176func CachedCodeDeployGetApplication(client AWSCodeDeployClientInterface, accountID string, region string, applicationName string) (codeDeployTypes.ApplicationInfo, error) {
177 cacheKey := fmt.Sprintf("%s-codedeploy-GetApplication-%s-%s", accountID, region, applicationName)

Callers 1

Calls 2

InfoMethod · 0.80
ListDeploymentsMethod · 0.65

Tested by

no test coverage detected