chore: upgrade golangci-lint and address findings (#1904)
This commit is contained in:
@@ -182,7 +182,7 @@ func runActionImpl(step actionStep, actionDir string, remoteAction *remoteAction
|
||||
}
|
||||
}
|
||||
|
||||
func setupActionEnv(ctx context.Context, step actionStep, remoteAction *remoteAction) error {
|
||||
func setupActionEnv(ctx context.Context, step actionStep, _ *remoteAction) error {
|
||||
rc := step.getRunContext()
|
||||
|
||||
// A few fields in the environment (e.g. GITHUB_ACTION_REPOSITORY)
|
||||
|
@@ -171,7 +171,7 @@ func unescapeKvPairs(kvPairs map[string]string) map[string]string {
|
||||
return kvPairs
|
||||
}
|
||||
|
||||
func (rc *RunContext) saveState(ctx context.Context, kvPairs map[string]string, arg string) {
|
||||
func (rc *RunContext) saveState(_ context.Context, kvPairs map[string]string, arg string) {
|
||||
stepID := rc.CurrentStep
|
||||
if stepID != "" {
|
||||
if rc.IntraActionState == nil {
|
||||
|
@@ -181,7 +181,7 @@ func (ee expressionEvaluator) evaluateScalarYamlNode(ctx context.Context, node *
|
||||
}
|
||||
|
||||
func (ee expressionEvaluator) evaluateMappingYamlNode(ctx context.Context, node *yaml.Node) (*yaml.Node, error) {
|
||||
var ret *yaml.Node = nil
|
||||
var ret *yaml.Node
|
||||
// GitHub has this undocumented feature to merge maps, called insert directive
|
||||
insertDirective := regexp.MustCompile(`\${{\s*insert\s*}}`)
|
||||
for i := 0; i < len(node.Content)/2; i++ {
|
||||
@@ -239,7 +239,7 @@ func (ee expressionEvaluator) evaluateMappingYamlNode(ctx context.Context, node
|
||||
}
|
||||
|
||||
func (ee expressionEvaluator) evaluateSequenceYamlNode(ctx context.Context, node *yaml.Node) (*yaml.Node, error) {
|
||||
var ret *yaml.Node = nil
|
||||
var ret *yaml.Node
|
||||
for i := 0; i < len(node.Content); i++ {
|
||||
v := node.Content[i]
|
||||
// Preserve nested sequences
|
||||
@@ -503,6 +503,6 @@ func getWorkflowSecrets(ctx context.Context, rc *RunContext) map[string]string {
|
||||
return rc.Config.Secrets
|
||||
}
|
||||
|
||||
func getWorkflowVars(ctx context.Context, rc *RunContext) map[string]string {
|
||||
func getWorkflowVars(_ context.Context, rc *RunContext) map[string]string {
|
||||
return rc.Config.Vars
|
||||
}
|
||||
|
@@ -101,7 +101,7 @@ func newJobExecutor(info jobInfo, sf stepFactory, rc *RunContext) common.Executo
|
||||
// always allow 1 min for stopping and removing the runner, even if we were cancelled
|
||||
ctx, cancel := context.WithTimeout(common.WithLogger(context.Background(), common.Logger(ctx)), time.Minute)
|
||||
defer cancel()
|
||||
err = info.stopContainer()(ctx)
|
||||
err = info.stopContainer()(ctx) //nolint:contextcheck
|
||||
}
|
||||
setJobResult(ctx, info, rc, jobError == nil)
|
||||
setJobOutputs(ctx, rc)
|
||||
@@ -114,7 +114,7 @@ func newJobExecutor(info jobInfo, sf stepFactory, rc *RunContext) common.Executo
|
||||
pipeline = append(pipeline, steps...)
|
||||
|
||||
return common.NewPipelineExecutor(info.startContainer(), common.NewPipelineExecutor(pipeline...).
|
||||
Finally(func(ctx context.Context) error {
|
||||
Finally(func(ctx context.Context) error { //nolint:contextcheck
|
||||
var cancel context.CancelFunc
|
||||
if ctx.Err() == context.Canceled {
|
||||
// in case of an aborted run, we still should execute the
|
||||
|
@@ -82,7 +82,7 @@ type jobContainerMock struct {
|
||||
container.LinuxContainerEnvironmentExtensions
|
||||
}
|
||||
|
||||
func (jcm *jobContainerMock) ReplaceLogWriter(stdout, stderr io.Writer) (io.Writer, io.Writer) {
|
||||
func (jcm *jobContainerMock) ReplaceLogWriter(_, _ io.Writer) (io.Writer, io.Writer) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
@@ -515,7 +515,7 @@ func (rc *RunContext) platformImage(ctx context.Context) string {
|
||||
return rc.runsOnImage(ctx)
|
||||
}
|
||||
|
||||
func (rc *RunContext) options(ctx context.Context) string {
|
||||
func (rc *RunContext) options(_ context.Context) string {
|
||||
job := rc.Run.Job()
|
||||
c := job.Container()
|
||||
if c == nil {
|
||||
@@ -813,35 +813,35 @@ func setActionRuntimeVars(rc *RunContext, env map[string]string) {
|
||||
env["ACTIONS_RUNTIME_TOKEN"] = actionsRuntimeToken
|
||||
}
|
||||
|
||||
func (rc *RunContext) handleCredentials(ctx context.Context) (username, password string, err error) {
|
||||
func (rc *RunContext) handleCredentials(ctx context.Context) (string, string, error) {
|
||||
// TODO: remove below 2 lines when we can release act with breaking changes
|
||||
username = rc.Config.Secrets["DOCKER_USERNAME"]
|
||||
password = rc.Config.Secrets["DOCKER_PASSWORD"]
|
||||
username := rc.Config.Secrets["DOCKER_USERNAME"]
|
||||
password := rc.Config.Secrets["DOCKER_PASSWORD"]
|
||||
|
||||
container := rc.Run.Job().Container()
|
||||
if container == nil || container.Credentials == nil {
|
||||
return
|
||||
return username, password, nil
|
||||
}
|
||||
|
||||
if container.Credentials != nil && len(container.Credentials) != 2 {
|
||||
err = fmt.Errorf("invalid property count for key 'credentials:'")
|
||||
return
|
||||
err := fmt.Errorf("invalid property count for key 'credentials:'")
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
ee := rc.NewExpressionEvaluator(ctx)
|
||||
if username = ee.Interpolate(ctx, container.Credentials["username"]); username == "" {
|
||||
err = fmt.Errorf("failed to interpolate container.credentials.username")
|
||||
return
|
||||
err := fmt.Errorf("failed to interpolate container.credentials.username")
|
||||
return "", "", err
|
||||
}
|
||||
if password = ee.Interpolate(ctx, container.Credentials["password"]); password == "" {
|
||||
err = fmt.Errorf("failed to interpolate container.credentials.password")
|
||||
return
|
||||
err := fmt.Errorf("failed to interpolate container.credentials.password")
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
if container.Credentials["username"] == "" || container.Credentials["password"] == "" {
|
||||
err = fmt.Errorf("container.credentials cannot be empty")
|
||||
return
|
||||
err := fmt.Errorf("container.credentials cannot be empty")
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
return username, password, err
|
||||
return username, password, nil
|
||||
}
|
||||
|
@@ -256,7 +256,7 @@ func isStepEnabled(ctx context.Context, expr string, step step, stage stepStage)
|
||||
return runStep, nil
|
||||
}
|
||||
|
||||
func isContinueOnError(ctx context.Context, expr string, step step, stage stepStage) (bool, error) {
|
||||
func isContinueOnError(ctx context.Context, expr string, step step, _ stepStage) (bool, error) {
|
||||
// https://github.com/github/docs/blob/3ae84420bd10997bb5f35f629ebb7160fe776eae/content/actions/reference/workflow-syntax-for-github-actions.md?plain=true#L962
|
||||
if len(strings.TrimSpace(expr)) == 0 {
|
||||
return false, nil
|
||||
|
@@ -85,7 +85,7 @@ func (sal *stepActionLocal) getEnv() *map[string]string {
|
||||
return &sal.env
|
||||
}
|
||||
|
||||
func (sal *stepActionLocal) getIfExpression(context context.Context, stage stepStage) string {
|
||||
func (sal *stepActionLocal) getIfExpression(_ context.Context, stage stepStage) string {
|
||||
switch stage {
|
||||
case stepStageMain:
|
||||
return sal.Step.If.Value
|
||||
|
@@ -24,7 +24,7 @@ func (salm *stepActionLocalMocks) runAction(step actionStep, actionDir string, r
|
||||
return args.Get(0).(func(context.Context) error)
|
||||
}
|
||||
|
||||
func (salm *stepActionLocalMocks) readAction(ctx context.Context, step *model.Step, actionDir string, actionPath string, readFile actionYamlReader, writeFile fileWriter) (*model.Action, error) {
|
||||
func (salm *stepActionLocalMocks) readAction(_ context.Context, step *model.Step, actionDir string, actionPath string, readFile actionYamlReader, writeFile fileWriter) (*model.Action, error) {
|
||||
args := salm.Called(step, actionDir, actionPath, readFile, writeFile)
|
||||
return args.Get(0).(*model.Action), args.Error(1)
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ type stepActionRemoteMocks struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
func (sarm *stepActionRemoteMocks) readAction(ctx context.Context, step *model.Step, actionDir string, actionPath string, readFile actionYamlReader, writeFile fileWriter) (*model.Action, error) {
|
||||
func (sarm *stepActionRemoteMocks) readAction(_ context.Context, step *model.Step, actionDir string, actionPath string, readFile actionYamlReader, writeFile fileWriter) (*model.Action, error) {
|
||||
args := sarm.Called(step, actionDir, actionPath, readFile, writeFile)
|
||||
return args.Get(0).(*model.Action), args.Error(1)
|
||||
}
|
||||
|
@@ -51,7 +51,7 @@ func (sd *stepDocker) getEnv() *map[string]string {
|
||||
return &sd.env
|
||||
}
|
||||
|
||||
func (sd *stepDocker) getIfExpression(context context.Context, stage stepStage) string {
|
||||
func (sd *stepDocker) getIfExpression(_ context.Context, _ stepStage) string {
|
||||
return sd.Step.If.Value
|
||||
}
|
||||
|
||||
|
@@ -59,7 +59,7 @@ func (sr *stepRun) getEnv() *map[string]string {
|
||||
return &sr.env
|
||||
}
|
||||
|
||||
func (sr *stepRun) getIfExpression(context context.Context, stage stepStage) string {
|
||||
func (sr *stepRun) getIfExpression(_ context.Context, _ stepStage) string {
|
||||
return sr.Step.If.Value
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user