Skip to content

Commit

Permalink
LANTERN-788: Fixing Go limtr
Browse files Browse the repository at this point in the history
  • Loading branch information
archita-ekkirala committed Nov 13, 2024
1 parent 33a55c4 commit aaadaa1
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions endpointmanager/pkg/chplendpointquerier/emdscloudwebscraper.go
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
package chplendpointquerier

import (
"io/ioutil"
"net/http"

"encoding/json"
"io"
"net/http"

log "github.com/sirupsen/logrus"
)

func EmdsCloudWebscraper(CHPLURL string, fileToWriteTo string) {

var entry LanternEntry
var lanternEntryList []LanternEntry
var endpointEntryList EndpointList

client := &http.Client{}
req, err := http.NewRequest("GET", CHPLURL, nil)
if err != nil {
log.Fatalf("Error creating HTTP request: %v", err)
return
}

req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36")

res, err := client.Do(req)

if err != nil {
log.Fatalf("Error making HTTP request: %v", err)
return
}
defer res.Body.Close()

body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
log.Fatalf("Error reading response body: %v", err)
return
}

var resources []map[string]interface{}
if err := json.Unmarshal(body, &resources); err != nil {
log.Fatalf("Error parsing JSON: %v", err)
return
}

for _, resource := range resources {
Expand All @@ -43,6 +51,6 @@ func EmdsCloudWebscraper(CHPLURL string, fileToWriteTo string) {

err = WriteCHPLFile(endpointEntryList, fileToWriteTo)
if err != nil {
log.Fatal(err)
log.Fatalf("Error writing to file: %v", err)
}
}

0 comments on commit aaadaa1

Please sign in to comment.