Skip to content

fix(deps): update module github.com/google/go-github/v59 to v60 #12884

fix(deps): update module github.com/google/go-github/v59 to v60

fix(deps): update module github.com/google/go-github/v59 to v60 #12884

GitHub Actions / golangci failed Apr 1, 2024 in 1s

reviewdog [golangci] report

reported by reviewdog 🐶

Findings (51)

router/middleware/scm_test.go|12 col 2| could not import github.com/go-vela/server/scm/github (-: # github.com/go-vela/server/scm/github
scm/github/repo.go|126 col 25| invalid operation: cannot index hook.Config (variable of type *"github.com/google/go-github/v60/github".HookConfig)
scm/github/repo.go|195 col 11| cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal
scm/github/repo.go|269 col 11| cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal) (typecheck)
router/middleware/perm/perm_test.go|22 col 2| could not import github.com/go-vela/server/scm/github (-: # github.com/go-vela/server/scm/github
scm/github/repo.go|126 col 25| invalid operation: cannot index hook.Config (variable of type *"github.com/google/go-github/v60/github".HookConfig)
scm/github/repo.go|195 col 11| cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal
scm/github/repo.go|269 col 11| cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal) (typecheck)
router/middleware/pipeline/pipeline_test.go|25 col 2| could not import github.com/go-vela/server/scm/github (-: # github.com/go-vela/server/scm/github
scm/github/repo.go|126 col 25| invalid operation: cannot index hook.Config (variable of type *"github.com/google/go-github/v60/github".HookConfig)
scm/github/repo.go|195 col 11| cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal
scm/github/repo.go|269 col 11| cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal) (typecheck)
scm/github/access.go|1| : # github.com/go-vela/server/scm/github [github.com/go-vela/server/scm/github.test]
scm/github/repo.go|126 col 25| invalid operation: cannot index hook.Config (variable of type *"github.com/google/go-github/v60/github".HookConfig)
scm/github/repo.go|195 col 11| cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal
scm/github/repo.go|269 col 11| cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal (typecheck)
mock/server/schedule.go|3| 3-142 lines are duplicate of mock/server/secret.go:4-180 (dupl)
database/deployment/create.go|3| 3-33 lines are duplicate of database/deployment/update.go:3-32 (dupl)
database/deployment/update.go|3| 3-32 lines are duplicate of database/deployment/create.go:3-33 (dupl)
database/pipeline/create.go|3| 3-53 lines are duplicate of database/pipeline/update.go:3-54 (dupl)
database/pipeline/update.go|3| 3-54 lines are duplicate of database/pipeline/create.go:3-53 (dupl)
database/worker/create.go|3| 3-36 lines are duplicate of database/worker/update.go:3-36 (dupl)
database/worker/update.go|3| 3-36 lines are duplicate of database/worker/create.go:3-36 (dupl)
compiler/native/expand.go|48| Function 'ExpandSteps' has too many statements (74 > 70) (funlen)
mock/server/authentication.go|41 col 9| string error has 4 occurrences, make it a constant (goconst)
queue/redis/ping_test.go|8| File is not goimports-ed (goimports)
database/deployment/delete.go|6| File is not goimports-ed (goimports)
database/deployment/update.go|6| File is not goimports-ed (goimports)
queue/redis/route_test.go|62 col 28| G601: Implicit memory aliasing in for loop. (gosec)
compiler/native/compile_test.go|1818 col 50| G601: Implicit memory aliasing in for loop. (gosec)
compiler/native/compile_test.go|3129 col 51| G601: Implicit memory aliasing in for loop. (gosec)
database/build/update.go|16 col 30| unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
database/build/count_repo.go|14 col 37| unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
database/build/get_repo.go|15 col 34| unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
compiler/native/parse_test.go|861 col 24| unused-parameter: parameter 'p' seems to be unused, consider removing or renaming it as _ (revive)
secret/vault/refresh_test.go|45 col 74| unused-parameter: parameter 'r' seems to be unused, consider removing or renaming it as _ (revive)
secret/vault/refresh_test.go|71 col 40| unused-parameter: parameter 'in' seems to be unused, consider removing or renaming it as _ (revive)
secret/vault/refresh_test.go|108 col 40| unused-parameter: parameter 'in' seems to be unused, consider removing or renaming it as _ (revive)
secret/vault/refresh_test.go|128 col 40| unused-parameter: parameter 'in' seems to be unused, consider removing or renaming it as _ (revive)
secret/vault/refresh_test.go|201 col 74| unused-parameter: parameter 'r' seems to be unused, consider removing or renaming it as _ (revive)
queue/redis/redis_test.go|91 col 2| var _steps is unused (unused)
database/resource.go|29 col 20| Non-inherited new context, use function like context.WithXXX instead (contextcheck)
database/resource.go|40 col 25| Non-inherited new context, use function like context.WithXXX instead (contextcheck)
database/resource.go|53 col 25| Non-inherited new context, use function like context.WithXXX instead (contextcheck)
compiler/template/starlark/starlark.go|131 col 4| only one cuddle assignment allowed before if statement (wsl)
database/schedule/create.go|3 col 1| directive //nolint:dupl // ignore similar code with update.go is unused for linter "dupl" (nolintlint)
compiler/native/compile.go|267 col 1| directive //nolint:dupl,lll // linter thinks the steps and stages workflows are identical is unused for linter "dupl" (nolintlint)
compiler/native/compile.go|364 col 1| directive //nolint:dupl,lll // linter thinks the steps and stages workflows are identical is unused for linter "dupl" (nolintlint)
secret/vault/count.go|37 col 2| directive //nolint:staticcheck // ignore false positive is unused for linter "staticcheck" (nolintlint)
secret/vault/get.go|40 col 2| directive //nolint:ineffassign,staticcheck // ignore false positive is unused for linter "staticcheck" (nolintlint)
secret/vault/list.go|45 col 2| directive //nolint:staticcheck // ignore false positive is unused for linter "staticcheck" (nolintlint)

Filtered Findings (0)

Annotations

Check failure on line 12 in router/middleware/scm_test.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] router/middleware/scm_test.go#L12

could not import github.com/go-vela/server/scm/github (-: # github.com/go-vela/server/scm/github
Raw output
router/middleware/scm_test.go:12:2: could not import github.com/go-vela/server/scm/github (-: # github.com/go-vela/server/scm/github

Check failure on line 126 in scm/github/repo.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] scm/github/repo.go#L126

invalid operation: cannot index hook.Config (variable of type *"github.com/google/go-github/v60/github".HookConfig)
Raw output
scm/github/repo.go:126:25: invalid operation: cannot index hook.Config (variable of type *"github.com/google/go-github/v60/github".HookConfig)

Check failure on line 195 in scm/github/repo.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] scm/github/repo.go#L195

cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal
Raw output
scm/github/repo.go:195:11: cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal

Check failure on line 269 in scm/github/repo.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] scm/github/repo.go#L269

cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal) (typecheck)
Raw output
scm/github/repo.go:269:11: cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal) (typecheck)
	"github.com/go-vela/server/scm/github"
	^

Check failure on line 22 in router/middleware/perm/perm_test.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] router/middleware/perm/perm_test.go#L22

could not import github.com/go-vela/server/scm/github (-: # github.com/go-vela/server/scm/github
Raw output
router/middleware/perm/perm_test.go:22:2: could not import github.com/go-vela/server/scm/github (-: # github.com/go-vela/server/scm/github

Check failure on line 126 in scm/github/repo.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] scm/github/repo.go#L126

invalid operation: cannot index hook.Config (variable of type *"github.com/google/go-github/v60/github".HookConfig)
Raw output
scm/github/repo.go:126:25: invalid operation: cannot index hook.Config (variable of type *"github.com/google/go-github/v60/github".HookConfig)

Check failure on line 195 in scm/github/repo.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] scm/github/repo.go#L195

cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal
Raw output
scm/github/repo.go:195:11: cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal

Check failure on line 269 in scm/github/repo.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] scm/github/repo.go#L269

cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal) (typecheck)
Raw output
scm/github/repo.go:269:11: cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal) (typecheck)
	"github.com/go-vela/server/scm/github"
	^

Check failure on line 25 in router/middleware/pipeline/pipeline_test.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] router/middleware/pipeline/pipeline_test.go#L25

could not import github.com/go-vela/server/scm/github (-: # github.com/go-vela/server/scm/github
Raw output
router/middleware/pipeline/pipeline_test.go:25:2: could not import github.com/go-vela/server/scm/github (-: # github.com/go-vela/server/scm/github

Check failure on line 126 in scm/github/repo.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] scm/github/repo.go#L126

invalid operation: cannot index hook.Config (variable of type *"github.com/google/go-github/v60/github".HookConfig)
Raw output
scm/github/repo.go:126:25: invalid operation: cannot index hook.Config (variable of type *"github.com/google/go-github/v60/github".HookConfig)

Check failure on line 195 in scm/github/repo.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] scm/github/repo.go#L195

cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal
Raw output
scm/github/repo.go:195:11: cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal

Check failure on line 269 in scm/github/repo.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] scm/github/repo.go#L269

cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal) (typecheck)
Raw output
scm/github/repo.go:269:11: cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal) (typecheck)
	"github.com/go-vela/server/scm/github"
	^

Check failure on line 1 in scm/github/access.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] scm/github/access.go#L1

: # github.com/go-vela/server/scm/github [github.com/go-vela/server/scm/github.test]
Raw output
scm/github/access.go:1: : # github.com/go-vela/server/scm/github [github.com/go-vela/server/scm/github.test]

Check failure on line 126 in scm/github/repo.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] scm/github/repo.go#L126

invalid operation: cannot index hook.Config (variable of type *"github.com/google/go-github/v60/github".HookConfig)
Raw output
scm/github/repo.go:126:25: invalid operation: cannot index hook.Config (variable of type *"github.com/google/go-github/v60/github".HookConfig)

Check failure on line 195 in scm/github/repo.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] scm/github/repo.go#L195

cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal
Raw output
scm/github/repo.go:195:11: cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal

Check failure on line 269 in scm/github/repo.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] scm/github/repo.go#L269

cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal (typecheck)
Raw output
scm/github/repo.go:269:11: cannot use map[string]interface{}{…} (value of type map[string]interface{}) as *"github.com/google/go-github/v60/github".HookConfig value in struct literal (typecheck)
// SPDX-License-Identifier: Apache-2.0

Check failure on line 3 in mock/server/schedule.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] mock/server/schedule.go#L3

3-142 lines are duplicate of `mock/server/secret.go:4-180` (dupl)
Raw output
mock/server/schedule.go:3: 3-142 lines are duplicate of `mock/server/secret.go:4-180` (dupl)
package server

import (
	"encoding/json"
	"fmt"
	"net/http"
	"strings"

	"github.com/gin-gonic/gin"
	"github.com/go-vela/types"
	"github.com/go-vela/types/library"
)

const (
	// ScheduleResp represents a JSON return for a single schedule.
	ScheduleResp = `{
	"id": 2,
	"repo_id": 1,
	"active": true,
	"name": "foo",
	"entry": "@weekly",
	"created_at": 1683154980,
	"created_by": "octocat",
	"updated_at": 1683154980,
	"updated_by": "octocat",
	"scheduled_at": 0,
	"branch": "main"
}`
	SchedulesResp = `[
	{
		"id": 2,
		"active": true,
		"name": "foo",
		"entry": "@weekly",
		"created_at": 1683154980,
		"created_by": "octocat",
		"updated_at": 1683154980,
		"updated_by": "octocat",
		"scheduled_at": 0,
		"repo_id": 1,
		"branch": "main"
	},
	{
		"id": 1,
		"active": true,
		"name": "bar",
		"entry": "@weekly",
		"created_at": 1683154974,
		"created_by": "octocat",
		"updated_at": 1683154974,
		"updated_by": "octocat",
		"scheduled_at": 0,
		"repo_id": 1,
		"branch": "main
	}
]`
)

// getSchedules returns mock JSON for a http GET.
func getSchedules(c *gin.Context) {
	data := []byte(SchedulesResp)

	var body []library.Schedule
	_ = json.Unmarshal(data, &body)

	c.JSON(http.StatusOK, body)
}

// getSchedule has a param :schedule returns mock JSON for a http GET.
//
// Pass "not-found" to :schedule to test receiving a http 404 response.
func getSchedule(c *gin.Context) {
	s := c.Param("schedule")

	if strings.Contains(s, "not-found") {
		msg := fmt.Sprintf("Schedule %s does not exist", s)

		c.AbortWithStatusJSON(http.StatusNotFound, types.Error{Message: &msg})

		return
	}

	data := []byte(ScheduleResp)

	var body library.Schedule
	_ = json.Unmarshal(data, &body)

	c.JSON(http.StatusOK, body)
}

// addSchedule returns mock JSON for a http POST.
func addSchedule(c *gin.Context) {
	data := []byte(ScheduleResp)

	var body library.Schedule
	_ = json.Unmarshal(data, &body)

	c.JSON(http.StatusCreated, body)
}

// updateSchedule has a param :schedule returns mock JSON for a http PUT.
//
// Pass "not-found" to :schedule to test receiving a http 404 response.
func updateSchedule(c *gin.Context) {
	if !strings.Contains(c.FullPath(), "admin") {
		s := c.Param("schedule")

		if strings.Contains(s, "not-found") {
			msg := fmt.Sprintf("Schedule %s does not exist", s)

			c.AbortWithStatusJSON(http.StatusNotFound, types.Error{Message: &msg})

			return
		}
	}

	data := []byte(ScheduleResp)

	var body library.Schedule
	_ = json.Unmarshal(data, &body)

	c.JSON(http.StatusOK, body)
}

// removeSchedule has a param :schedule returns mock JSON for a http DELETE.
//
// Pass "not-found" to :schedule to test receiving a http 404 response.
func removeSchedule(c *gin.Context) {
	s := c.Param("schedule")

	if strings.Contains(s, "not-found") {
		msg := fmt.Sprintf("Schedule %s does not exist", s)

		c.AbortWithStatusJSON(http.StatusNotFound, types.Error{Message: &msg})

		return
	}

	c.JSON(http.StatusOK, fmt.Sprintf("schedule %s deleted", s))
}

Check failure on line 3 in database/deployment/create.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] database/deployment/create.go#L3

3-33 lines are duplicate of `database/deployment/update.go:3-32` (dupl)
Raw output
database/deployment/create.go:3: 3-33 lines are duplicate of `database/deployment/update.go:3-32` (dupl)
package deployment

import (
	"context"

	"github.com/go-vela/types/constants"
	"github.com/go-vela/types/database"
	"github.com/go-vela/types/library"
	"github.com/sirupsen/logrus"
)

// CreateDeployment creates a new deployment in the database.
func (e *engine) CreateDeployment(ctx context.Context, d *library.Deployment) (*library.Deployment, error) {
	e.logger.WithFields(logrus.Fields{
		"deployment": d.GetID(),
	}).Tracef("creating deployment %d in the database", d.GetID())

	// cast the library type to database type
	deployment := database.DeploymentFromLibrary(d)

	// validate the necessary fields are populated
	err := deployment.Validate()
	if err != nil {
		return nil, err
	}

	result := e.client.Table(constants.TableDeployment).Create(deployment)

	// send query to the database
	return deployment.ToLibrary(d.Builds), result.Error
}

Check failure on line 3 in database/deployment/update.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] database/deployment/update.go#L3

3-32 lines are duplicate of `database/deployment/create.go:3-33` (dupl)
Raw output
database/deployment/update.go:3: 3-32 lines are duplicate of `database/deployment/create.go:3-33` (dupl)
package deployment

import (
	"context"
	"github.com/go-vela/types/constants"
	"github.com/go-vela/types/database"
	"github.com/go-vela/types/library"
	"github.com/sirupsen/logrus"
)

// UpdateDeployment updates an existing deployment in the database.
func (e *engine) UpdateDeployment(ctx context.Context, d *library.Deployment) (*library.Deployment, error) {
	e.logger.WithFields(logrus.Fields{
		"deployment": d.GetID(),
	}).Tracef("updating deployment %d in the database", d.GetID())

	// cast the library type to database type
	deployment := database.DeploymentFromLibrary(d)

	// validate the necessary fields are populated
	err := deployment.Validate()
	if err != nil {
		return nil, err
	}

	result := e.client.Table(constants.TableDeployment).Save(deployment)

	// send query to the database
	return deployment.ToLibrary(d.Builds), result.Error
}

Check failure on line 3 in database/pipeline/create.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] database/pipeline/create.go#L3

3-53 lines are duplicate of `database/pipeline/update.go:3-54` (dupl)
Raw output
database/pipeline/create.go:3: 3-53 lines are duplicate of `database/pipeline/update.go:3-54` (dupl)
package pipeline

import (
	"context"

	"github.com/go-vela/types/constants"
	"github.com/go-vela/types/database"
	"github.com/go-vela/types/library"
	"github.com/sirupsen/logrus"
)

// CreatePipeline creates a new pipeline in the database.
func (e *engine) CreatePipeline(ctx context.Context, p *library.Pipeline) (*library.Pipeline, error) {
	e.logger.WithFields(logrus.Fields{
		"pipeline": p.GetCommit(),
	}).Tracef("creating pipeline %s in the database", p.GetCommit())

	// cast the library type to database type
	//
	// https://pkg.go.dev/github.com/go-vela/types/database#PipelineFromLibrary
	pipeline := database.PipelineFromLibrary(p)

	// validate the necessary fields are populated
	//
	// https://pkg.go.dev/github.com/go-vela/types/database#Pipeline.Validate
	err := pipeline.Validate()
	if err != nil {
		return nil, err
	}

	// compress data for the pipeline
	//
	// https://pkg.go.dev/github.com/go-vela/types/database#Pipeline.Compress
	err = pipeline.Compress(e.config.CompressionLevel)
	if err != nil {
		return nil, err
	}

	// send query to the database
	err = e.client.Table(constants.TablePipeline).Create(pipeline).Error
	if err != nil {
		return nil, err
	}

	err = pipeline.Decompress()
	if err != nil {
		return nil, err
	}

	return pipeline.ToLibrary(), nil
}

Check failure on line 3 in database/pipeline/update.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] database/pipeline/update.go#L3

3-54 lines are duplicate of `database/pipeline/create.go:3-53` (dupl)
Raw output
database/pipeline/update.go:3: 3-54 lines are duplicate of `database/pipeline/create.go:3-53` (dupl)
package pipeline

import (
	"context"

	"github.com/go-vela/types/constants"
	"github.com/go-vela/types/database"
	"github.com/go-vela/types/library"
	"github.com/sirupsen/logrus"
)

// UpdatePipeline updates an existing pipeline in the database.
func (e *engine) UpdatePipeline(ctx context.Context, p *library.Pipeline) (*library.Pipeline, error) {
	e.logger.WithFields(logrus.Fields{
		"pipeline": p.GetCommit(),
	}).Tracef("updating pipeline %s in the database", p.GetCommit())

	// cast the library type to database type
	//
	// https://pkg.go.dev/github.com/go-vela/types/database#PipelineFromLibrary
	pipeline := database.PipelineFromLibrary(p)

	// validate the necessary fields are populated
	//
	// https://pkg.go.dev/github.com/go-vela/types/database#Pipeline.Validate
	err := pipeline.Validate()
	if err != nil {
		return nil, err
	}

	// compress data for the pipeline
	//
	// https://pkg.go.dev/github.com/go-vela/types/database#Pipeline.Compress
	err = pipeline.Compress(e.config.CompressionLevel)
	if err != nil {
		return nil, err
	}

	// send query to the database
	err = e.client.Table(constants.TablePipeline).Save(pipeline).Error
	if err != nil {
		return nil, err
	}

	// decompress pipeline to return
	err = pipeline.Decompress()
	if err != nil {
		return nil, err
	}

	return pipeline.ToLibrary(), nil
}

Check failure on line 3 in database/worker/create.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] database/worker/create.go#L3

3-36 lines are duplicate of `database/worker/update.go:3-36` (dupl)
Raw output
database/worker/create.go:3: 3-36 lines are duplicate of `database/worker/update.go:3-36` (dupl)
package worker

import (
	"context"

	api "github.com/go-vela/server/api/types"
	"github.com/go-vela/types/constants"
	"github.com/sirupsen/logrus"
)

// CreateWorker creates a new worker in the database.
func (e *engine) CreateWorker(ctx context.Context, w *api.Worker) (*api.Worker, error) {
	e.logger.WithFields(logrus.Fields{
		"worker": w.GetHostname(),
	}).Tracef("creating worker %s in the database", w.GetHostname())

	// cast the library type to database type
	//
	// https://pkg.go.dev/github.com/go-vela/types/database#WorkerFromLibrary
	worker := FromAPI(w)

	// validate the necessary fields are populated
	//
	// https://pkg.go.dev/github.com/go-vela/types/database#Worker.Validate
	err := worker.Validate()
	if err != nil {
		return nil, err
	}

	// send query to the database
	result := e.client.Table(constants.TableWorker).Create(worker)

	return worker.ToAPI(w.GetRunningBuilds()), result.Error
}

Check failure on line 3 in database/worker/update.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] database/worker/update.go#L3

3-36 lines are duplicate of `database/worker/create.go:3-36` (dupl)
Raw output
database/worker/update.go:3: 3-36 lines are duplicate of `database/worker/create.go:3-36` (dupl)
package worker

import (
	"context"

	api "github.com/go-vela/server/api/types"
	"github.com/go-vela/types/constants"
	"github.com/sirupsen/logrus"
)

// UpdateWorker updates an existing worker in the database.
func (e *engine) UpdateWorker(ctx context.Context, w *api.Worker) (*api.Worker, error) {
	e.logger.WithFields(logrus.Fields{
		"worker": w.GetHostname(),
	}).Tracef("updating worker %s in the database", w.GetHostname())

	// cast the library type to database type
	//
	// https://pkg.go.dev/github.com/go-vela/types/database#WorkerFromLibrary
	worker := FromAPI(w)

	// validate the necessary fields are populated
	//
	// https://pkg.go.dev/github.com/go-vela/types/database#Worker.Validate
	err := worker.Validate()
	if err != nil {
		return nil, err
	}

	// send query to the database
	result := e.client.Table(constants.TableWorker).Save(worker)

	return worker.ToAPI(w.GetRunningBuilds()), result.Error
}

Check failure on line 48 in compiler/native/expand.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] compiler/native/expand.go#L48

Function 'ExpandSteps' has too many statements (74 > 70) (funlen)
Raw output
compiler/native/expand.go:48: Function 'ExpandSteps' has too many statements (74 > 70) (funlen)
func (c *client) ExpandSteps(s *yaml.Build, tmpls map[string]*yaml.Template, r *pipeline.RuleData, depth int) (*yaml.Build, error) {

Check failure on line 41 in mock/server/authentication.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] mock/server/authentication.go#L41

string `error` has 4 occurrences, make it a constant (goconst)
Raw output
mock/server/authentication.go:41:9: string `error` has 4 occurrences, make it a constant (goconst)
	err := "error"
	       ^