Skip to content

Commit

Permalink
Fix golint lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Starttoaster committed Apr 15, 2024
1 parent 79f1875 commit 26b462f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
2 changes: 2 additions & 0 deletions internal/web/content/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package content

import "embed"

// Static contains an embedded filesystem
var Static embed.FS

// Init accepts an embedded filesystem for the web package content
func Init(fs embed.FS) {
Static = fs
}
18 changes: 9 additions & 9 deletions internal/web/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

scraper "github.com/starttoaster/prometheus-exporter-scraper"
log "github.com/starttoaster/trivy-operator-explorer/internal/logger"
"github.com/starttoaster/trivy-operator-explorer/internal/views/images"
"github.com/starttoaster/trivy-operator-explorer/internal/web/content"
"github.com/starttoaster/trivy-operator-explorer/internal/web/views"
)

var scrpr *scraper.WebScraper
Expand Down Expand Up @@ -43,11 +43,11 @@ func imagesHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
return
}
imageData := images.GetImagesView(data)
imageData := views.GetImagesView(data)

err = tmpl.Execute(w, imageData)
if err != nil {
log.Logger.Error("encountered error executing image html template", "error", err)
log.Logger.Error("encountered error executing images html template", "error", err)
http.Error(w, "Internal Server Error, check server logs", http.StatusInternalServerError)
return
}
Expand All @@ -66,7 +66,7 @@ func imageHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
return
}
imageData := images.GetImagesView(data)
imageData := views.GetImagesView(data)

// Parse URL query params
q := r.URL.Query()
Expand All @@ -84,7 +84,7 @@ func imageHandler(w http.ResponseWriter, r *http.Request) {
http.NotFound(w, r)
return
}
v, ok := imageData.Images[images.Image{
v, ok := imageData.Images[views.Image{
Image: imageName,
Digest: imageDigest,
}]
Expand All @@ -98,7 +98,7 @@ func imageHandler(w http.ResponseWriter, r *http.Request) {
severity := q.Get("severity")

// Get vulnerability list that matches severity, if specified
view := images.ImageVulnerabilityView{
view := views.ImageVulnerabilityView{
Image: imageName,
Digest: imageDigest,
}
Expand All @@ -109,9 +109,9 @@ func imageHandler(w http.ResponseWriter, r *http.Request) {
}

// append to data list to pass to template
view.Data = append(view.Data, images.ImageVulnerabilityData{
view.Data = append(view.Data, views.ImageVulnerabilityData{
ID: id,
Vulnerability: images.Vulnerability{
Vulnerability: views.Vulnerability{
Severity: vuln.Severity,
Score: vuln.Score,
Resource: vuln.Resource,
Expand All @@ -121,7 +121,7 @@ func imageHandler(w http.ResponseWriter, r *http.Request) {
},
})
}
view = images.SortImageVulnerabilityView(view)
view = views.SortImageVulnerabilityView(view)

err = tmpl.Execute(w, view)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package images
package views

import (
"fmt"
Expand All @@ -10,8 +10,10 @@ import (
log "github.com/starttoaster/trivy-operator-explorer/internal/logger"
)

// TrivyImageVulnerabilityMetricName the metric key for image vulnerability data
const TrivyImageVulnerabilityMetricName = "trivy_vulnerability_id"

// GetImagesView converts some scrape data to the /images view
func GetImagesView(data *scraper.ScrapeData) ImagesView {
var i ImagesView
i.Images = make(map[Image]ImageData)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package images
package views

// ImagesView contains data about images running in a kubernetes cluster with vulnerabilities
type ImagesView struct {
Expand Down

0 comments on commit 26b462f

Please sign in to comment.