Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New linter version, new errors #662

Merged
merged 2 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ fig:

.PHONY: lint
lint:
docker pull golangci/golangci-lint:latest
docker run --rm -v $(CURDIR):/app -w /app golangci/golangci-lint:latest golangci-lint run --timeout 5m -v

.PHONY: mock
Expand Down
2 changes: 1 addition & 1 deletion cmd/meroxa/root/apps/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ func (d *Deploy) getAppImage(ctx context.Context) (string, error) {
d.localDeploy.Lang = d.lang
d.localDeploy.AppName = d.appName
if d.localDeploy.Enabled {
fqImageName, err = d.localDeploy.GetDockerImageName(ctx, d.logger, d.path, d.appName, d.lang)
fqImageName, err = d.localDeploy.GetDockerImageName(ctx, d.logger, d.path, d.appName)
if err != nil {
return "", err
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/meroxa/root/apps/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestListAppsExecution(t *testing.T) {
{
desc: "With applications in a private and common environment",
apps: func() []*meroxa.Application {
aa := utils.GenerateApplicationWithEnv("", meroxa.EnvironmentTypePrivate, meroxa.EnvironmentProviderAws)
aa := utils.GenerateApplicationWithEnv("")
aa2 := utils.GenerateApplication("")
return []*meroxa.Application{&aa, &aa2}
},
Expand All @@ -66,7 +66,7 @@ func TestListAppsExecution(t *testing.T) {
{
desc: "With applications in a private environment",
apps: func() []*meroxa.Application {
aa := utils.GenerateApplicationWithEnv("", meroxa.EnvironmentTypePrivate, meroxa.EnvironmentProviderAws)
aa := utils.GenerateApplicationWithEnv("")
return []*meroxa.Application{&aa}
},
shouldErrorOnEnvInfo: func(output string) bool {
Expand All @@ -76,7 +76,7 @@ func TestListAppsExecution(t *testing.T) {
{
desc: "With applications in a self-hosted environment",
apps: func() []*meroxa.Application {
aa := utils.GenerateApplicationWithEnv("", meroxa.EnvironmentTypeSelfHosted, "")
aa := utils.GenerateApplicationWithEnv("")
return []*meroxa.Application{&aa}
},
shouldErrorOnEnvInfo: func(output string) bool {
Expand Down
2 changes: 1 addition & 1 deletion cmd/meroxa/root/nop/nop.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ func (*Nop) Usage() string {
return ""
}

func (*Nop) Execute(ctx context.Context) error {
func (*Nop) Execute(_ context.Context) error {
return nil
}
8 changes: 4 additions & 4 deletions cmd/meroxa/turbine/golang/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,21 +125,21 @@ func (t *turbineGoCLI) NeedsToBuild(ctx context.Context, appName string) (bool,
}

func (t *turbineGoCLI) GetGitSha(ctx context.Context) (string, error) {
return utils.GetGitSha(t.appPath)
return utils.GetGitSha(ctx, t.appPath)
}

func (t *turbineGoCLI) GitChecks(ctx context.Context) error {
return utils.GitChecks(ctx, t.logger, t.appPath)
}

func (t *turbineGoCLI) CreateDockerfile(ctx context.Context, appName string) (string, error) {
func (t *turbineGoCLI) CreateDockerfile(_ context.Context, appName string) (string, error) {
return t.appPath, turbineGo.CreateDockerfile(appName, t.appPath)
}

func (t *turbineGoCLI) CleanUpBuild(ctx context.Context) {
func (t *turbineGoCLI) CleanUpBuild(_ context.Context) {
utils.CleanupDockerfile(t.logger, t.appPath)
}

func (t *turbineGoCLI) SetupForDeploy(ctx context.Context, gitSha string) (func(), error) {
func (t *turbineGoCLI) SetupForDeploy(_ context.Context, _ string) (func(), error) {
return func() {}, nil
}
2 changes: 1 addition & 1 deletion cmd/meroxa/turbine/golang/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
turbinego "github.com/meroxa/turbine-go/init"
)

func (t *turbineGoCLI) Init(ctx context.Context, name string) error {
func (t *turbineGoCLI) Init(_ context.Context, name string) error {
err := turbinego.Init(name, t.appPath)
if err != nil {
t.logger.StopSpinnerWithStatus("\t", log.Failed)
Expand Down
6 changes: 3 additions & 3 deletions cmd/meroxa/turbine/javascript/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
)

// Build has nothing to do for turbine-js.
func (t *turbineJsCLI) Build(ctx context.Context, appName string, platform bool) error {
func (t *turbineJsCLI) Build(_ context.Context, _ string, _ bool) error {
return nil
}

func (t *turbineJsCLI) CleanUpTempBuildLocation(ctx context.Context) error {
func (t *turbineJsCLI) CleanUpTempBuildLocation(_ context.Context) error {
return nil
}

func (t *turbineJsCLI) CleanUpBinaries(ctx context.Context, appName string) {
func (t *turbineJsCLI) CleanUpBinaries(_ context.Context, _ string) {
}
12 changes: 6 additions & 6 deletions cmd/meroxa/turbine/javascript/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var (
TurbineJSVersion = "1.3.8"
)

func (t *turbineJsCLI) NeedsToBuild(ctx context.Context, appName string) (bool, error) {
func (t *turbineJsCLI) NeedsToBuild(ctx context.Context, _ string) (bool, error) {
output, err := RunTurbineJS(ctx, t.logger, "hasfunctions", t.appPath)
if err != nil {
err = fmt.Errorf(
Expand Down Expand Up @@ -72,7 +72,7 @@ func (t *turbineJsCLI) Deploy(ctx context.Context, imageName, appName, gitSha, s
}

// GetResources asks turbine for a list of resources used by the given app.
func (t *turbineJsCLI) GetResources(ctx context.Context, appName string) ([]utils.ApplicationResource, error) {
func (t *turbineJsCLI) GetResources(ctx context.Context, _ string) ([]utils.ApplicationResource, error) {
var resources []utils.ApplicationResource

output, err := RunTurbineJS(ctx, t.logger, "listresources", t.appPath)
Expand All @@ -94,14 +94,14 @@ func (t *turbineJsCLI) GetResources(ctx context.Context, appName string) ([]util
}

func (t *turbineJsCLI) GetGitSha(ctx context.Context) (string, error) {
return utils.GetGitSha(t.appPath)
return utils.GetGitSha(ctx, t.appPath)
}

func (t *turbineJsCLI) GitChecks(ctx context.Context) error {
return utils.GitChecks(ctx, t.logger, t.appPath)
}

func (t *turbineJsCLI) CreateDockerfile(ctx context.Context, appName string) (string, error) {
func (t *turbineJsCLI) CreateDockerfile(ctx context.Context, _ string) (string, error) {
_, err := RunTurbineJS(ctx, t.logger, "clibuild", t.appPath)
if err != nil {
return "", fmt.Errorf("unable to create Dockerfile at %s; %s", t.appPath, err)
Expand All @@ -110,10 +110,10 @@ func (t *turbineJsCLI) CreateDockerfile(ctx context.Context, appName string) (st
return t.appPath, err
}

func (t *turbineJsCLI) CleanUpBuild(ctx context.Context) {
func (t *turbineJsCLI) CleanUpBuild(_ context.Context) {
utils.CleanupDockerfile(t.logger, t.appPath)
}

func (t *turbineJsCLI) SetupForDeploy(ctx context.Context, gitSha string) (func(), error) {
func (t *turbineJsCLI) SetupForDeploy(_ context.Context, _ string) (func(), error) {
return func() {}, nil
}
2 changes: 1 addition & 1 deletion cmd/meroxa/turbine/javascript/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

// Upgrade fetches the latest Meroxa dependencies.
func (t *turbineJsCLI) Upgrade(vendor bool) error {
func (t *turbineJsCLI) Upgrade(_ bool) error {
cmd := exec.Command("grep", "turbine-js", "package.json")
cmd.Dir = t.appPath
err := cmd.Wait()
Expand Down
4 changes: 2 additions & 2 deletions cmd/meroxa/turbine/local_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func (ld *LocalDeploy) getAuthConfig() string {
return base64.URLEncoding.EncodeToString(authConfigBytes)
}

// GetDockerImageName Will create the image via DockerHub.
func (ld *LocalDeploy) GetDockerImageName(ctx context.Context, l log.Logger, appPath, appName, lang string) (string, error) {
// GetDockerImageName will create the image via DockerHub.
func (ld *LocalDeploy) GetDockerImageName(ctx context.Context, l log.Logger, appPath, appName string) (string, error) {
l.Info(ctx, "\t Using DockerHub...")
// fqImageName will be eventually taken from the build endpoint.
fqImageName := ld.DockerHubUserNameEnv + "/" + appName
Expand Down
4 changes: 2 additions & 2 deletions cmd/meroxa/turbine/python/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
)

// Build created the needed structure for a python app.
func (t *turbinePyCLI) Build(ctx context.Context, appName string, platform bool) error {
func (t *turbinePyCLI) Build(_ context.Context, _ string, _ bool) error {
return nil
}

func (t *turbinePyCLI) CleanUpBinaries(ctx context.Context, appName string) {
func (t *turbinePyCLI) CleanUpBinaries(_ context.Context, _ string) {
}
10 changes: 5 additions & 5 deletions cmd/meroxa/turbine/python/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

// NeedsToBuild determines if the app has functions or not.
func (t *turbinePyCLI) NeedsToBuild(ctx context.Context, appName string) (bool, error) {
func (t *turbinePyCLI) NeedsToBuild(_ context.Context, _ string) (bool, error) {
cmd := exec.Command("turbine-py", "hasFunctions", t.appPath)
output, err := cmd.CombinedOutput()
if err != nil {
Expand Down Expand Up @@ -83,7 +83,7 @@ func (t *turbinePyCLI) Deploy(ctx context.Context, imageName, appName, gitSha, s
}

// GetResources asks turbine for a list of resources used by the given app.
func (t *turbinePyCLI) GetResources(ctx context.Context, appName string) ([]utils.ApplicationResource, error) {
func (t *turbinePyCLI) GetResources(ctx context.Context, _ string) ([]utils.ApplicationResource, error) {
var resources []utils.ApplicationResource

cmd := exec.CommandContext(ctx, "turbine-py", "listResources", t.appPath)
Expand All @@ -106,14 +106,14 @@ func (t *turbinePyCLI) GetResources(ctx context.Context, appName string) ([]util
}

func (t *turbinePyCLI) GetGitSha(ctx context.Context) (string, error) {
return utils.GetGitSha(t.appPath)
return utils.GetGitSha(ctx, t.appPath)
}

func (t *turbinePyCLI) GitChecks(ctx context.Context) error {
return utils.GitChecks(ctx, t.logger, t.appPath)
}

func (t *turbinePyCLI) CreateDockerfile(ctx context.Context, appName string) (string, error) {
func (t *turbinePyCLI) CreateDockerfile(ctx context.Context, _ string) (string, error) {
cmd := exec.CommandContext(ctx, "turbine-py", "clibuild", t.appPath)
output, err := cmd.CombinedOutput()
if err != nil {
Expand Down Expand Up @@ -142,6 +142,6 @@ func (t *turbinePyCLI) CleanUpBuild(ctx context.Context) {
}
}

func (t *turbinePyCLI) SetupForDeploy(ctx context.Context, gitSha string) (func(), error) {
func (t *turbinePyCLI) SetupForDeploy(_ context.Context, _ string) (func(), error) {
return func() {}, nil
}
2 changes: 1 addition & 1 deletion cmd/meroxa/turbine/python/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
const turbinePYVersion = "1.5.3"

// Upgrade fetches the latest Meroxa dependencies.
func (t *turbinePyCLI) Upgrade(vendor bool) error {
func (t *turbinePyCLI) Upgrade(_ bool) error {
cmd := exec.Command("grep", "turbine-py==", "requirements.txt")
cmd.Dir = t.appPath
err := cmd.Run()
Expand Down
2 changes: 1 addition & 1 deletion cmd/meroxa/turbine/python/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

// GetVersion calls turbine-py to get its version used by the given app.
func (t *turbinePyCLI) GetVersion(ctx context.Context) (string, error) {
func (t *turbinePyCLI) GetVersion(_ context.Context) (string, error) {
cmd := exec.Command("turbine-py", "version", t.appPath)
output, err := cmd.CombinedOutput()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/meroxa/turbine/ruby/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
)

func (t *turbineRbCLI) Build(ctx context.Context, appName string, platform bool) error {
func (t *turbineRbCLI) Build(_ context.Context, _ string, _ bool) error {
return nil
}

func (t *turbineRbCLI) CleanUpBinaries(ctx context.Context, appName string) {
func (t *turbineRbCLI) CleanUpBinaries(_ context.Context, _ string) {
}
12 changes: 6 additions & 6 deletions cmd/meroxa/turbine/ruby/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
"google.golang.org/protobuf/types/known/emptypb"
)

func (t *turbineRbCLI) CleanUpBuild(ctx context.Context) {
func (t *turbineRbCLI) CleanUpBuild(_ context.Context) {
utils.CleanupDockerfile(t.logger, t.appPath)
}

func (t *turbineRbCLI) CreateDockerfile(ctx context.Context, appName string) (string, error) {
func (t *turbineRbCLI) CreateDockerfile(ctx context.Context, _ string) (string, error) {
cmd := internal.NewTurbineCmd(t.appPath,
internal.TurbineCommandBuild,
map[string]string{})
Expand Down Expand Up @@ -59,7 +59,7 @@ func (t *turbineRbCLI) SetupForDeploy(ctx context.Context, gitSha string) (func(
}, nil
}

func (t *turbineRbCLI) NeedsToBuild(ctx context.Context, appName string) (bool, error) {
func (t *turbineRbCLI) NeedsToBuild(ctx context.Context, _ string) (bool, error) {
ctx, cancel := context.WithTimeout(ctx, time.Second)
defer cancel()
resp, err := t.recordClient.HasFunctions(ctx, &emptypb.Empty{})
Expand All @@ -70,7 +70,7 @@ func (t *turbineRbCLI) NeedsToBuild(ctx context.Context, appName string) (bool,
return resp.Value, nil
}

func (t *turbineRbCLI) Deploy(ctx context.Context, imageName, appName, gitSha, specVersion, accountUUID string) (string, error) {
func (t *turbineRbCLI) Deploy(ctx context.Context, imageName, _, _, _, _ string) (string, error) {
ctx, cancel := context.WithTimeout(ctx, time.Second)
defer cancel()
resp, err := t.recordClient.GetSpec(ctx, &pb.GetSpecRequest{
Expand All @@ -83,7 +83,7 @@ func (t *turbineRbCLI) Deploy(ctx context.Context, imageName, appName, gitSha, s
return string(resp.Spec), nil
}

func (t *turbineRbCLI) GetResources(ctx context.Context, appName string) ([]utils.ApplicationResource, error) {
func (t *turbineRbCLI) GetResources(ctx context.Context, _ string) ([]utils.ApplicationResource, error) {
ctx, cancel := context.WithTimeout(ctx, time.Second)
defer cancel()
resp, err := t.recordClient.ListResources(ctx, &emptypb.Empty{})
Expand All @@ -103,7 +103,7 @@ func (t *turbineRbCLI) GetResources(ctx context.Context, appName string) ([]util
}

func (t *turbineRbCLI) GetGitSha(ctx context.Context) (string, error) {
return utils.GetGitSha(t.appPath)
return utils.GetGitSha(ctx, t.appPath)
}

func (t *turbineRbCLI) GitChecks(ctx context.Context) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/meroxa/turbine/ruby/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/meroxa/turbine-core/pkg/app"
)

func (t *turbineRbCLI) Init(ctx context.Context, appName string) error {
func (t *turbineRbCLI) Init(_ context.Context, appName string) error {
return app.NewAppInit(appName, utils.Ruby, t.appPath).Init()
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/meroxa/turbine/ruby/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package turbinerb

import "fmt"

func (t *turbineRbCLI) Upgrade(vendor bool) error {
func (t *turbineRbCLI) Upgrade(_ bool) error {
return fmt.Errorf("command unavailable")
}
2 changes: 1 addition & 1 deletion cmd/meroxa/turbine/ruby/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

// GetVersion will return the version of turbine-rb dependency of a given app.
func (t *turbineRbCLI) GetVersion(ctx context.Context) (string, error) {
func (t *turbineRbCLI) GetVersion(_ context.Context) (string, error) {
cmd := exec.Command("ruby", []string{
"-r", "rubygems",
"-r", fmt.Sprintf("%s/app", t.appPath),
Expand Down
8 changes: 4 additions & 4 deletions cmd/meroxa/turbine/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func GetPath(flag string) (string, error) {
}

// GetLangFromAppJSON returns specified language in users' app.json.
func GetLangFromAppJSON(ctx context.Context, l log.Logger, pwd string) (string, error) {
func GetLangFromAppJSON(_ context.Context, l log.Logger, pwd string) (string, error) {
l.StartSpinner("\t", "Determining application language from app.json...")
appConfig, err := ReadConfigFile(pwd)
if err != nil {
Expand All @@ -102,7 +102,7 @@ func GetLangFromAppJSON(ctx context.Context, l log.Logger, pwd string) (string,
}

// GetAppNameFromAppJSON returns specified app name in users' app.json.
func GetAppNameFromAppJSON(ctx context.Context, l log.Logger, pwd string) (string, error) {
func GetAppNameFromAppJSON(_ context.Context, l log.Logger, pwd string) (string, error) {
l.StartSpinner("\t", "Reading application name from app.json...")
appConfig, err := ReadConfigFile(pwd)
if err != nil {
Expand Down Expand Up @@ -260,9 +260,9 @@ func GitMainBranch(branch string) bool {
}

// GetGitSha will return the latest gitSha that will be used to create an application.
func GetGitSha(appPath string) (string, error) {
func GetGitSha(ctx context.Context, appPath string) (string, error) {
// Gets latest git sha
cmd := exec.Command("git", "rev-parse", "HEAD")
cmd := exec.CommandContext(ctx, "git", "rev-parse", "HEAD")
cmd.Dir = appPath
output, err := cmd.CombinedOutput()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/meroxa/turbine/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ HEAD
require.NoError(t, err)
assert.Equal(t, tc.branch, branch)

_, err = GetGitSha(path)
_, err = GetGitSha(ctx, path)
if err != nil {
if tc.shaErr == nil {
t.Fatalf("unepxected error: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion log/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type jsonLogger struct {
l *log.Logger
}

func (l *jsonLogger) JSON(ctx context.Context, data interface{}) {
func (l *jsonLogger) JSON(_ context.Context, data interface{}) {
if raw, ok := data.(string); ok {
l.l.Print(raw)
return
Expand Down
Loading