Skip to content

Commit

Permalink
fix: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
msvticket committed Oct 23, 2024
1 parent 16aa0af commit e42c60a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
12 changes: 2 additions & 10 deletions internal/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"path"
Expand Down Expand Up @@ -41,13 +40,6 @@ type FileController struct {
operationChannel chan string
}

var (
// defaultChartIndex an empty chart index
defaultChartIndex = `apiVersion: v1
generated: "2019-11-01T17:04:16Z"
entries:`
)

// NewFileController creates a new file controller
func NewFileController(cache Storage, storage Storage, repositories []Repository, config Config) (*FileController, error) {
chartsPath := config.HTTP.ChartPath
Expand Down Expand Up @@ -141,7 +133,7 @@ func (ctrl *FileController) PostChart(w http.ResponseWriter, r *http.Request, ps
repo := ps.ByName("repo")
log.Debugf("PostChart, repo: %s\n", repo)

content, err := ioutil.ReadAll(r.Body)
content, err := io.ReadAll(r.Body)
if err != nil {
msg := fmt.Sprintf("Failed to load payload: %s", err)
w.WriteHeader(500)
Expand Down Expand Up @@ -175,7 +167,7 @@ func (ctrl *FileController) PostChart(w http.ResponseWriter, r *http.Request, ps
filename = filepath.Join(folder, ChartFolder, filename)
log.Debugf("PostChart, filename: %s\n", filename)

err = ctrl.writeFileToCache(filename, ioutil.NopCloser(bytes.NewReader(content)))
err = ctrl.writeFileToCache(filename, io.NopCloser(bytes.NewReader(content)))
if err != nil {
msg := fmt.Sprintf("Error when saving the file into cache: %s", err)
w.WriteHeader(500)
Expand Down
7 changes: 2 additions & 5 deletions internal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,8 @@ func main() {
ticker := time.NewTicker(config.Cache.CleanInterval)
go func(ticker *time.Ticker) {
cache.RemoveUnusedArtifacts(controller)
for {
select {
case <-ticker.C:
cache.RemoveUnusedArtifacts(controller)
}
for range ticker.C {
cache.RemoveUnusedArtifacts(controller)
}
}(ticker)
}
Expand Down
3 changes: 3 additions & 0 deletions internal/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ func (r *HTTPRepository) DownloadFile(filePath string) (io.ReadCloser, error) {
u.Path = path.Join(u.Path, filePath)

request, err := http.NewRequest(http.MethodGet, u.String(), nil)
if err != nil {
return nil, err
}
for key, values := range r.header {
for _, value := range values {
request.Header.Add(key, value)
Expand Down

0 comments on commit e42c60a

Please sign in to comment.