Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
yrobla committed Feb 19, 2024
1 parent 210d13e commit eb5ba88
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
18 changes: 9 additions & 9 deletions pkg/feeds/maven/maven.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func New(feedOptions feeds.FeedOptions) (*Feed, error) {
}, nil
}

// Package represents package information
// Package represents package information.
type LatestVersionInfo struct {
Version string `json:"version"`
TimestampUnixWithMS int64 `json:"timestampUnixWithMS"`
Expand All @@ -45,12 +45,12 @@ type Package struct {
LatestVersionInfo LatestVersionInfo `json:"latestVersionInfo"`
}

// Response represents the response structure from Sonatype API
// Response represents the response structure from Sonatype API.
type Response struct {
Components []Package `json:"components"`
}

// fetchPackages fetches packages from Sonatype API for the given page
// fetchPackages fetches packages from Sonatype API for the given page.
func (feed Feed) fetchPackages(page int) ([]Package, error) {
// Define the request payload
payload := map[string]interface{}{
Expand All @@ -62,21 +62,21 @@ func (feed Feed) fetchPackages(page int) ([]Package, error) {

jsonPayload, err := json.Marshal(payload)
if err != nil {
return nil, fmt.Errorf("error encoding JSON: %v", err)
return nil, fmt.Errorf("error encoding JSON: %w", err)
}

// Send POST request to Sonatype API
// Send POST request to Sonatype API.
resp, err := http.Post(feed.baseURL+"?repository=maven-central", "application/json", bytes.NewBuffer(jsonPayload))
if err != nil {
return nil, fmt.Errorf("error sending request: %v", err)
return nil, fmt.Errorf("error sending request: %w", err)
}
defer resp.Body.Close()

// Decode response
// Decode response.
var response Response
err = json.NewDecoder(resp.Body).Decode(&response)
if err != nil {
return nil, fmt.Errorf("error decoding response: %v", err)
return nil, fmt.Errorf("error decoding response: %w", err)
}
return response.Components, nil
}
Expand All @@ -87,7 +87,7 @@ func (feed Feed) Latest(cutoff time.Time) ([]*feeds.Package, time.Time, []error)

page := 0
for {
// Fetch packages from Sonatype API for the current page
// Fetch packages from Sonatype API for the current page.
packages, err := feed.fetchPackages(page)
if err != nil {
errs = append(errs, err)
Expand Down
1 change: 0 additions & 1 deletion pkg/feeds/maven/maven_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func TestMavenLatest(t *testing.T) {
t.Errorf("Feed type not set correctly in goproxy package following Latest()")
}
}

}

func TestMavenNotFound(t *testing.T) {
Expand Down

0 comments on commit eb5ba88

Please sign in to comment.