Skip to content

Commit 875ca5d

Browse files
committed
INVS-1408 remove prints and comments
1 parent 5c65db0 commit 875ca5d

File tree

3 files changed

+15
-71
lines changed

3 files changed

+15
-71
lines changed

sumologic/resource_sumologic_cse_match_list.go

Lines changed: 15 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -155,20 +155,12 @@ func setItems(d *schema.ResourceData, items []CSEMatchListItemGet) {
155155
}
156156

157157
func resourceSumologicCSEMatchListDelete(d *schema.ResourceData, meta interface{}) error {
158-
println("delete: started resourceSumologicCSEMatchListDelete")
159-
160158
c := meta.(*Client)
161159
err := c.DeleteCSEMatchList(d.Id())
162-
163-
println("delete: finished resourceSumologicCSEMatchListDelete")
164-
165160
return err
166-
167161
}
168162

169163
func resourceSumologicCSEMatchListCreate(d *schema.ResourceData, meta interface{}) error {
170-
println("create: starting resourceSumologicCSEMatchListCreate")
171-
172164
c := meta.(*Client)
173165

174166
if d.Id() == "" {
@@ -185,8 +177,6 @@ func resourceSumologicCSEMatchListCreate(d *schema.ResourceData, meta interface{
185177
}
186178
d.SetId(id)
187179

188-
//Match list items
189-
//itemsData := d.Get("items").([]interface{})
190180
itemsData := d.Get("items").(*schema.Set).List()
191181
var items []CSEMatchListItemPost
192182
for _, data := range itemsData {
@@ -236,28 +226,16 @@ func resourceToCSEMatchListItem(data interface{}) CSEMatchListItemPost {
236226
item := CSEMatchListItemPost{}
237227
if len(itemsSlice) > 0 {
238228
itemObj := itemsSlice[0].(map[string]interface{})
239-
// for _, map := range itemObj {
240-
// println("itemObj id: ", )
241-
// }
242-
// b, err := json.Marshal(itemObj)
243-
// if err != nil {
244-
// log.Fatal(err)
245-
// }
246-
// fmt.Println("b: ", string(b))
247229
item.ID = itemObj["id"].(string)
248230
item.Description = itemObj["description"].(string)
249231
item.Active = true
250232
item.Expiration = itemObj["expiration"].(string)
251233
item.Value = itemObj["value"].(string)
252-
// println("resourceToCSEMatchListItem itemid1: " + itemObj["id"].(string))
253-
// println("resourceToCSEMatchListItem itemid2: " + item.ID)
254234
}
255-
//println("resourceToCSEMatchListItem returning id", item.ID)
256-
return item //, item.ID
235+
return item
257236
}
258237

259238
func resourceSumologicCSEMatchListUpdate(d *schema.ResourceData, meta interface{}) error {
260-
println("update: starting resourceSumologicCSEMatchListUpdate")
261239
CSEMatchListPost, err := resourceToCSEMatchList(d)
262240
if err != nil {
263241
return err
@@ -268,74 +246,51 @@ func resourceSumologicCSEMatchListUpdate(d *schema.ResourceData, meta interface{
268246
return err
269247
}
270248

271-
//Match list items
272-
//itemsData := d.Get("items").([]interface{})
273249
itemsData := d.Get("items").(*schema.Set).List()
274-
var items []CSEMatchListItemPost
250+
var newItems []CSEMatchListItemPost
275251
for _, data := range itemsData {
276-
//println("in itemsData, id is")
277-
item := resourceToCSEMatchListItem([]interface{}{data}) //TODO remove id return
278-
// item.ID = ""
279-
items = append(items, item)
280-
// println("appending id to itemsID: " + id)
281-
// itemIds = append(itemIds, id)
252+
item := resourceToCSEMatchListItem([]interface{}{data})
253+
newItems = append(newItems, item)
282254
}
283255

284-
// itemIdsString := ""
285-
// for i := 0; i < len(itemIds); i++ {
286-
// itemIdsString += itemIds[i] + " "
287-
// }
288-
// println("update: itemIds are " + itemIdsString)
289-
290256
CSEMatchListItems := getCSEMatchListItemsInMatchList(d.Id(), meta)
291-
var itemIds []string
257+
var oldItemIds []string
292258
for _, item := range CSEMatchListItems.CSEMatchListItemsGetObjects {
293-
//println("current id: ", item.ID)
294-
itemIds = append(itemIds, item.ID)
259+
oldItemIds = append(oldItemIds, item.ID)
295260
}
296261

297-
currentItemCount := CSEMatchListItems.Total
298-
newItemCount := len(itemsData) + currentItemCount
262+
oldItemCount := CSEMatchListItems.Total
263+
newItemCount := len(itemsData) + oldItemCount
299264

300-
println(fmt.Sprintf("current count %d, new count %d", currentItemCount, newItemCount))
301-
302-
if len(items) > 0 {
303-
err = c.CreateCSEMatchListItems(items, d.Id())
265+
//Add new items
266+
if len(newItems) > 0 {
267+
err = c.CreateCSEMatchListItems(newItems, d.Id())
304268
if err != nil {
305269
log.Printf("[WARN] An error occurred while adding match list items to match list id: %s, err: %v", d.Id(), err)
306270
}
307271

308272
}
309273

274+
// Wait until all new items have finished being indexed in ES
310275
CSEMatchListItems = getCSEMatchListItemsInMatchList(d.Id(), meta)
311-
312-
// Waits until all new items have finished being indexed in ES
313-
println(fmt.Sprintf("total %d, len %d, goal %d", CSEMatchListItems.Total, len(CSEMatchListItems.CSEMatchListItemsGetObjects), newItemCount))
314276
for CSEMatchListItems.Total < newItemCount {
315-
println(fmt.Sprintf("update: only got %d/%d items, sleeping for 3 seconds", CSEMatchListItems.Total, newItemCount))
316277
time.Sleep(3 * time.Second)
317278
CSEMatchListItems = getCSEMatchListItemsInMatchList(d.Id(), meta)
318279
}
319280

320-
println(fmt.Sprintf("update: checking %d items for deletion", len(CSEMatchListItems.CSEMatchListItemsGetObjects)))
321-
322-
// Delete all the old items
281+
// Delete old items
323282
for _, t := range CSEMatchListItems.CSEMatchListItemsGetObjects {
324-
//println("update: checking id for deletion: " + t.ID)
325-
if contains(itemIds, t.ID) {
326-
//println("update: itemIds contains " + t.ID)
283+
if contains(oldItemIds, t.ID) {
327284
err = c.DeleteCSEMatchListItem(t.ID)
328285
if err != nil {
329286
log.Printf("[WARN] An error occurred deleting match list item with id: %s, err: %v", t.ID, err)
330287
}
331288
}
332289
}
333290

334-
println("update: finished deleting, now getting items")
335-
336291
createStateConf := &resource.StateChangeConf{
337292
Target: []string{
338-
fmt.Sprint(len(items)),
293+
fmt.Sprint(len(newItems)),
339294
},
340295
Refresh: func() (interface{}, string, error) {
341296
resp, err := c.GetCSEMatchListItemsInMatchList(d.Id())
@@ -356,8 +311,6 @@ func resourceSumologicCSEMatchListUpdate(d *schema.ResourceData, meta interface{
356311
return fmt.Errorf("error waiting for match list (%s) to be updated: %s", d.Id(), err)
357312
}
358313

359-
println("update: finished resourceSumologicCSEMatchListUpdate")
360-
361314
return resourceSumologicCSEMatchListRead(d, meta)
362315
}
363316

sumologic/sumologic_client.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,6 @@ func (s *Client) Put(urlPath string, payload interface{}) ([]byte, error) {
220220

221221
body, _ := json.Marshal(payload)
222222

223-
println(string(body))
224-
225223
req, err := createNewRequest(http.MethodPut, sumoURL.String(), bytes.NewBuffer(body), s.AccessID, s.AccessKey, s.AuthJwt)
226224
if err != nil {
227225
return nil, err

sumologic/sumologic_cse_match_list_item.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,13 @@ func (s *Client) GetCSEMatchListItemsInMatchList(MatchListId string) (*CSEMatchL
5252
return nil, err
5353
}
5454

55-
println(fmt.Sprintf("get: GetCSEMatchListItemsInMatchList response total: %d", response.Total))
56-
5755
// When the match list has over 1000 items, fetch items from the remaining pages
5856
for offset = limit; offset < response.Total; offset += limit {
59-
println(fmt.Sprintf("Checking next page from %d to %d", offset, offset+1000))
60-
6157
nextPageResponse, err := s.SendGetCSEMatchListItemsRequest(MatchListId, offset)
6258
if err != nil {
6359
return nil, err
6460
}
6561

66-
println(fmt.Sprintf("Next page has %d items", len(nextPageResponse.CSEMatchListItemsGetObjects)))
67-
6862
for i := 0; i < len(nextPageResponse.CSEMatchListItemsGetObjects); i++ {
6963
response.CSEMatchListItemsGetObjects = append(response.CSEMatchListItemsGetObjects, nextPageResponse.CSEMatchListItemsGetObjects[i])
7064
}
@@ -96,7 +90,6 @@ func (s *Client) SendCreateCSEMatchListItemsRequest(CSEMatchListItemPost []CSEMa
9690
err = json.Unmarshal(responseBody, &response)
9791

9892
if err != nil {
99-
fmt.Println(err)
10093
return err
10194
}
10295

0 commit comments

Comments
 (0)