Skip to content

Commit

Permalink
Remove unused parameters
Browse files Browse the repository at this point in the history
- Remove *api.Repo parameter from client NewTester methods as it's unused
- Use _ instead of a named parameter in function implementations where not needed
  • Loading branch information
alemorcuq authored and juamedgod committed Feb 26, 2024
1 parent f5ae574 commit fc120a5
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 26 deletions.
2 changes: 1 addition & 1 deletion pkg/client/repo/chartmuseum/chartmuseum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func prepareTest(t *testing.T) (*chartmuseum.Repo, error) {
}

// Create tester
tester := chartmuseum.NewTester(t, cmRepo, false, dstIndex)
tester := chartmuseum.NewTester(t, false, dstIndex)
cmRepo.Url = tester.GetURL()

// Replace placeholder
Expand Down
6 changes: 2 additions & 4 deletions pkg/client/repo/chartmuseum/chartmuseumtester.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"testing"

"github.com/bitnami/charts-syncer/pkg/client/repo/helmclassic"

"github.com/bitnami/charts-syncer/api"
)

var (
Expand Down Expand Up @@ -43,12 +41,12 @@ type RepoTester struct {
}

// NewTester creates fake HTTP server to handle requests and return a RepoTester object with useful info for testing
func NewTester(t *testing.T, repo *api.Repo, emptyIndex bool, indexFile string) *RepoTester {
func NewTester(t *testing.T, emptyIndex bool, indexFile string) *RepoTester {
tester := &RepoTester{
t: t,
username: username,
password: password,
helmTester: helmclassic.NewTester(t, repo, emptyIndex, indexFile, false),
helmTester: helmclassic.NewTester(t, emptyIndex, indexFile, false),
index: make(map[string][]*helmclassic.ChartVersion),
emptyIndex: emptyIndex,
indexFile: indexFile,
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/repo/clienttester.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type ClientTester interface {
var NewClientTester = func(t *testing.T, repo *api.Repo, emptyIndex bool, indexFile string) ClientTester {
switch repo.Kind {
case api.Kind_CHARTMUSEUM:
return chartmuseum.NewTester(t, repo, emptyIndex, indexFile)
return chartmuseum.NewTester(t, emptyIndex, indexFile)
default:
t.Errorf("unsupported repo kind %q", repo.Kind)
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/repo/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func prepareHttpServer(t *testing.T, ociRepo *api.Repo) {
t.Helper()

// Create HTTP server
tester := oci.NewTester(t, ociRepo)
tester := oci.NewTester(t)
ociRepo.Url = tester.GetURL() + "/someproject/charts"
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/client/repo/harbor/harbor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func prepareTest(t *testing.T) (*harbor.Repo, error) {
}

// Create tester
tester := harbor.NewTester(t, harborRepo, false, dstIndex)
tester := harbor.NewTester(t, false, dstIndex)
harborRepo.Url = fmt.Sprintf("%s%s", tester.GetURL(), "/chartrepo/library")

// Replace placeholder
Expand Down
6 changes: 2 additions & 4 deletions pkg/client/repo/harbor/harbortester.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
"testing"

"github.com/bitnami/charts-syncer/pkg/client/repo/helmclassic"

"github.com/bitnami/charts-syncer/api"
)

var (
Expand Down Expand Up @@ -41,12 +39,12 @@ type RepoTester struct {
}

// NewTester creates fake HTTP server to handle requests and return a RepoTester object with useful info for testing
func NewTester(t *testing.T, repo *api.Repo, emptyIndex bool, indexFile string) *RepoTester {
func NewTester(t *testing.T, emptyIndex bool, indexFile string) *RepoTester {
tester := &RepoTester{
t: t,
username: username,
password: password,
helmTester: helmclassic.NewTester(t, repo, emptyIndex, indexFile, false),
helmTester: helmclassic.NewTester(t, emptyIndex, indexFile, false),
index: make(map[string][]*helmclassic.ChartVersion),
emptyIndex: emptyIndex,
indexFile: indexFile,
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/repo/helmclassic/helmclassic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func prepareTest(t *testing.T, indexFileName string) *helmclassic.Repo {
}

// Create tester
tester := helmclassic.NewTester(t, cmRepo, false, dstIndex, true)
tester := helmclassic.NewTester(t, false, dstIndex, true)
cmRepo.Url = tester.GetURL()

// Replace placeholder
Expand Down
9 changes: 4 additions & 5 deletions pkg/client/repo/helmclassic/helmclassictester.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"strings"
"testing"

"github.com/bitnami/charts-syncer/api"
"gopkg.in/yaml.v2"
)

Expand Down Expand Up @@ -65,7 +64,7 @@ type RepoTester struct {
}

// NewTester creates fake HTTP server to handle requests and return a RepoTester object with useful info for testing
func NewTester(t *testing.T, repo *api.Repo, emptyIndex bool, indexFile string, createServer bool) *RepoTester {
func NewTester(t *testing.T, emptyIndex bool, indexFile string, createServer bool) *RepoTester {
t.Helper()
tester := &RepoTester{
t: t,
Expand Down Expand Up @@ -116,7 +115,7 @@ func (rt *RepoTester) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}

// GetChart returns the chart info from the index
func (rt *RepoTester) GetChart(w http.ResponseWriter, r *http.Request, chart string) {
func (rt *RepoTester) GetChart(w http.ResponseWriter, _ *http.Request, chart string) {
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(rt.index[chart]); err != nil {
rt.t.Fatal(err)
Expand All @@ -129,7 +128,7 @@ func (rt *RepoTester) GetURL() string {
}

// GetIndex returns an index file
func (rt *RepoTester) GetIndex(w http.ResponseWriter, r *http.Request, emptyIndex bool, indexFile string) {
func (rt *RepoTester) GetIndex(w http.ResponseWriter, _ *http.Request, emptyIndex bool, indexFile string) {
w.Header().Set("Content-Type", "application/yaml")
w.WriteHeader(200)
_, filename, _, ok := runtime.Caller(1)
Expand All @@ -152,7 +151,7 @@ func (rt *RepoTester) GetIndex(w http.ResponseWriter, r *http.Request, emptyInde
}

// GetChartPackage returns a packaged helm chart
func (rt *RepoTester) GetChartPackage(w http.ResponseWriter, r *http.Request, chartPackageName string) {
func (rt *RepoTester) GetChartPackage(w http.ResponseWriter, _ *http.Request, chartPackageName string) {
w.WriteHeader(200)
_, filename, _, ok := runtime.Caller(1)
if !ok {
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/repo/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (r *Repo) Upload(filepath string, metadata *chart.Metadata) error {
}

// GetChartDetails returns the details of a chart
func (r *Repo) GetChartDetails(name string, version string) (*types.ChartDetails, error) {
func (r *Repo) GetChartDetails(_ string, _ string) (*types.ChartDetails, error) {
return &types.ChartDetails{
PublishedAt: utils.UnixEpoch,
Digest: "deadbuff",
Expand Down
10 changes: 5 additions & 5 deletions pkg/client/repo/oci/ocitester.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func PrepareHttpServer(t *testing.T, ociRepo *api.Repo) *Repo {
t.Helper()

// Create HTTP server
tester := NewTester(t, ociRepo)
tester := NewTester(t)
ociRepo.Url = tester.GetURL() + "/someproject/charts"
return PrepareTest(t, ociRepo)
}
Expand Down Expand Up @@ -133,7 +133,7 @@ func PrepareOciServer(t *testing.T, ociRepo *api.Repo) {
}

// NewTester creates fake HTTP server to handle requests and return a RepoTester object with useful info for testing
func NewTester(t *testing.T, repo *api.Repo) *RepoTester {
func NewTester(t *testing.T) *RepoTester {
t.Helper()
tester := &RepoTester{
t: t,
Expand Down Expand Up @@ -212,7 +212,7 @@ func (rt *RepoTester) GetURL() string {
}

// GetTagManifest returns the oci manifest of a specific tag
func (rt *RepoTester) GetTagManifest(w http.ResponseWriter, r *http.Request, name, version string) {
func (rt *RepoTester) GetTagManifest(w http.ResponseWriter, _ *http.Request, name, version string) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
_, filename, _, ok := runtime.Caller(1)
Expand All @@ -231,7 +231,7 @@ func (rt *RepoTester) GetTagManifest(w http.ResponseWriter, r *http.Request, nam
}

// GetTagsList returns the list of available tags for the specified asset
func (rt *RepoTester) GetTagsList(w http.ResponseWriter, r *http.Request, name string) {
func (rt *RepoTester) GetTagsList(w http.ResponseWriter, _ *http.Request, name string) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
_, filename, _, ok := runtime.Caller(1)
Expand Down Expand Up @@ -266,7 +266,7 @@ func (rt *RepoTester) ReplyPing(w http.ResponseWriter) {
}

// GetChartPackage returns a packaged helm chart
func (rt *RepoTester) GetChartPackage(w http.ResponseWriter, r *http.Request, name, digest string) {
func (rt *RepoTester) GetChartPackage(w http.ResponseWriter, _ *http.Request, name, digest string) {
w.WriteHeader(200)
_, filename, _, ok := runtime.Caller(1)
if !ok {
Expand Down
3 changes: 1 addition & 2 deletions pkg/client/target/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ func New(target *api.Target, chartWriter client.ChartsReaderWriter, insecure boo
}

// Unwrap unwraps a chart
func (t *Target) Unwrap(file string, metadata *chart.Metadata, opts ...config.Option) error {

func (t *Target) Unwrap(file string, _ *chart.Metadata, opts ...config.Option) error {
cfg := config.New(opts...)

wrapWorkdir, err := os.MkdirTemp(cfg.WorkDir, "charts-syncer")
Expand Down

0 comments on commit fc120a5

Please sign in to comment.