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

refactor(jsonschema): relocate schema generator #1219

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

more tests

d31e911
Select commit
Loading
Failed to load commit list.
Sign in for the full log view
Open

refactor(jsonschema): relocate schema generator #1219

more tests
d31e911
Select commit
Loading
Failed to load commit list.
GitHub Actions / golangci failed Nov 1, 2024 in 1s

reviewdog [golangci] report

reported by reviewdog 🐶

Findings (46)

database/deployment/create.go|3| 3-37 lines are duplicate of database/deployment/update.go:3-37 (dupl)
database/deployment/update.go|3| 3-37 lines are duplicate of database/deployment/create.go:3-37 (dupl)
database/hook/get.go|3| 3-40 lines are duplicate of database/hook/get_webhook.go:3-40 (dupl)
database/hook/get_webhook.go|3| 3-40 lines are duplicate of database/hook/get.go:3-40 (dupl)
database/hook/create.go|3| 3-39 lines are duplicate of database/hook/update.go:3-39 (dupl)
database/hook/update.go|3| 3-39 lines are duplicate of database/hook/create.go:3-39 (dupl)
database/service/create.go|3| 3-35 lines are duplicate of database/service/update.go:3-35 (dupl)
database/service/update.go|3| 3-35 lines are duplicate of database/service/create.go:3-35 (dupl)
database/types/build.go|384 col 44| G115: integer overflow conversion int -> int32 (gosec)
database/types/build.go|385 col 44| G115: integer overflow conversion int -> int32 (gosec)
database/types/repo.go|336 col 43| G115: integer overflow conversion int -> int32 (gosec)
database/types/settings.go|134 col 35| G115: integer overflow conversion int64 -> uint64 (gosec)
database/types/settings.go|205 col 49| G115: integer overflow conversion uint64 -> int64 (gosec)
api/build/enqueue.go|42 col 18| Non-inherited new context, use function like context.WithXXX instead (contextcheck)
api/build/enqueue.go|46 col 19| Non-inherited new context, use function like context.WithXXX instead (contextcheck)
compiler/template/starlark/render.go|44 col 18| SA1019: starlark.ExecFile is deprecated: use [ExecFileOptions] with [syntax.FileOptions] instead, because this function relies on legacy global variables. (staticcheck)
compiler/template/starlark/render.go|152 col 18| SA1019: starlark.ExecFile is deprecated: use [ExecFileOptions] with [syntax.FileOptions] instead, because this function relies on legacy global variables. (staticcheck)
compiler/template/starlark/starlark.go|131 col 4| only one cuddle assignment allowed before if statement (wsl)
internal/token/generate_rsa.go|19 col 32| unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
internal/token/generate_rsa.go|45 col 21| Non-inherited new context, use function like context.WithXXX instead (contextcheck)
api/types/queue_build.go|3| 3-134 lines are duplicate of api/types/template.go:4-137 (dupl)
api/types/build.go|60 col 10| string ... has 3 occurrences, make it a constant (goconst)
database/pipeline/create.go|3| 3-51 lines are duplicate of database/pipeline/update.go:3-52 (dupl)
database/pipeline/update.go|3| 3-52 lines are duplicate of database/pipeline/create.go:3-51 (dupl)
secret/vault/delete.go|16 col 25| unused-parameter: parameter 'ctx' 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/get.go|18 col 22| unused-parameter: parameter 'ctx' 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)
api/pipeline/validate.go|78| 78-110 lines are duplicate of api/pipeline/compile.go:80-112 (dupl)
api/pipeline/validate.go|3| 3-110 lines are duplicate of api/pipeline/expand.go:4-112 (dupl)
compiler/types/yaml/stage.go|92 col 5| return statements should not be cuddled if block has more than two lines (wsl)
compiler/types/yaml/stage.go|98 col 2| return statements should not be cuddled if block has more than two lines (wsl)
router/middleware/logger.go|48 col 36| unused-parameter: parameter 'timeFormat' seems to be unused, consider removing or renaming it as _ (revive)
database/worker/create.go|3| 3-37 lines are duplicate of database/worker/update.go:3-37 (dupl)
database/worker/update.go|3| 3-37 lines are duplicate of database/worker/create.go:3-37 (dupl)
mock/server/schedule.go|3| 3-283 lines are duplicate of mock/server/secret.go:4-180 (dupl)
mock/server/authentication.go|82 col 9| string error has 4 occurrences, make it a constant (goconst)
compiler/native/compile.go|333 col 26| Function modifyConfig should pass the context parameter (contextcheck)
compiler/native/compile.go|428 col 26| Function modifyConfig should pass the context parameter (contextcheck)
compiler/types/pipeline/ruleset.go|137 col 1| cyclomatic complexity 34 of func (*Rules).Match is high (> 30) (gocyclo)
database/step/create.go|3| 3-35 lines are duplicate of database/step/update.go:3-35 (dupl)
database/step/update.go|3| 3-35 lines are duplicate of database/step/create.go:3-35 (dupl)
secret/vault/get.go|40 col 2| directive //nolint:ineffassign,staticcheck // ignore false positive is unused for linter "staticcheck" (nolintlint)

Filtered Findings (0)

Annotations

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-37 lines are duplicate of `database/deployment/update.go:3-37` (dupl)
Raw output
database/deployment/create.go:3: 3-37 lines are duplicate of `database/deployment/update.go:3-37` (dupl)
package deployment

import (
	"context"

	"github.com/sirupsen/logrus"

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

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

	// cast the API type to database type
	deployment := types.DeploymentFromAPI(d)

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

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

	// send query to the database
	return deployment.ToAPI(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-37 lines are duplicate of `database/deployment/create.go:3-37` (dupl)
Raw output
database/deployment/update.go:3: 3-37 lines are duplicate of `database/deployment/create.go:3-37` (dupl)
package deployment

import (
	"context"

	"github.com/sirupsen/logrus"

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

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

	// cast the API type to database type
	deployment := types.DeploymentFromAPI(d)

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

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

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

Check failure on line 3 in database/hook/get.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] database/hook/get.go#L3

3-40 lines are duplicate of `database/hook/get_webhook.go:3-40` (dupl)
Raw output
database/hook/get.go:3: 3-40 lines are duplicate of `database/hook/get_webhook.go:3-40` (dupl)
package hook

import (
	"context"

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

// GetHook gets a hook by ID from the database.
func (e *engine) GetHook(ctx context.Context, id int64) (*api.Hook, error) {
	e.logger.Tracef("getting hook %d", id)

	// variable to store query results
	h := new(types.Hook)

	// send query to the database and store result in variable
	err := e.client.
		WithContext(ctx).
		Table(constants.TableHook).
		Preload("Repo").
		Preload("Repo.Owner").
		Preload("Build").
		Where("id = ?", id).
		Take(h).
		Error
	if err != nil {
		return nil, err
	}

	err = h.Repo.Decrypt(e.config.EncryptionKey)
	if err != nil {
		e.logger.Errorf("unable to decrypt repo for hook %d: %v", h.ID.Int64, err)
	}

	return h.ToAPI(), nil
}

Check failure on line 3 in database/hook/get_webhook.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] database/hook/get_webhook.go#L3

3-40 lines are duplicate of `database/hook/get.go:3-40` (dupl)
Raw output
database/hook/get_webhook.go:3: 3-40 lines are duplicate of `database/hook/get.go:3-40` (dupl)
package hook

import (
	"context"

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

// GetHookByWebhookID gets a single hook with a matching webhook id in the database.
func (e *engine) GetHookByWebhookID(ctx context.Context, webhookID int64) (*api.Hook, error) {
	e.logger.Tracef("getting a hook with webhook id %d", webhookID)

	// variable to store query results
	h := new(types.Hook)

	// send query to the database and store result in variable
	err := e.client.
		WithContext(ctx).
		Table(constants.TableHook).
		Preload("Repo").
		Preload("Repo.Owner").
		Preload("Build").
		Where("webhook_id = ?", webhookID).
		Take(h).
		Error
	if err != nil {
		return nil, err
	}

	err = h.Repo.Decrypt(e.config.EncryptionKey)
	if err != nil {
		e.logger.Errorf("unable to decrypt repo for hook %d: %v", h.ID.Int64, err)
	}

	return h.ToAPI(), nil
}

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

See this annotation in the file changed.

@github-actions github-actions / golangci

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

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

import (
	"context"

	"github.com/sirupsen/logrus"

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

// CreateHook creates a new hook in the database.
func (e *engine) CreateHook(ctx context.Context, h *api.Hook) (*api.Hook, error) {
	e.logger.WithFields(logrus.Fields{
		"hook": h.GetNumber(),
	}).Tracef("creating hook %d", h.GetNumber())

	hook := types.HookFromAPI(h)

	err := hook.Validate()
	if err != nil {
		return nil, err
	}

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

	result := hook.ToAPI()
	result.SetRepo(h.GetRepo())
	result.SetBuild(h.GetBuild())

	return result, nil
}

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

See this annotation in the file changed.

@github-actions github-actions / golangci

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

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

import (
	"context"

	"github.com/sirupsen/logrus"

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

// UpdateHook updates an existing hook in the database.
func (e *engine) UpdateHook(ctx context.Context, h *api.Hook) (*api.Hook, error) {
	e.logger.WithFields(logrus.Fields{
		"hook": h.GetNumber(),
	}).Tracef("updating hook %d", h.GetNumber())

	hook := types.HookFromAPI(h)

	err := hook.Validate()
	if err != nil {
		return nil, err
	}

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

	result := hook.ToAPI()
	result.SetRepo(h.GetRepo())
	result.SetBuild(h.GetBuild())

	return result, nil
}

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

See this annotation in the file changed.

@github-actions github-actions / golangci

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

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

import (
	"context"

	"github.com/sirupsen/logrus"

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

// CreateService creates a new service in the database.
func (e *engine) CreateService(ctx context.Context, s *api.Service) (*api.Service, error) {
	e.logger.WithFields(logrus.Fields{
		"service": s.GetNumber(),
	}).Tracef("creating service %s in the database", s.GetName())

	service := types.ServiceFromAPI(s)

	err := service.Validate()
	if err != nil {
		return nil, err
	}

	// send query to the database
	result := e.client.
		WithContext(ctx).
		Table(constants.TableService).
		Create(service)

	return service.ToAPI(), result.Error
}

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

See this annotation in the file changed.

@github-actions github-actions / golangci

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

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

import (
	"context"

	"github.com/sirupsen/logrus"

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

// UpdateService updates an existing service in the database.
func (e *engine) UpdateService(ctx context.Context, s *api.Service) (*api.Service, error) {
	e.logger.WithFields(logrus.Fields{
		"service": s.GetNumber(),
	}).Tracef("updating service %s", s.GetName())

	service := types.ServiceFromAPI(s)

	err := service.Validate()
	if err != nil {
		return nil, err
	}

	// send query to the database
	result := e.client.
		WithContext(ctx).
		Table(constants.TableService).
		Save(service)

	return service.ToAPI(), result.Error
}

Check failure on line 384 in database/types/build.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] database/types/build.go#L384

G115: integer overflow conversion int -> int32 (gosec)
Raw output
database/types/build.go:384:44: G115: integer overflow conversion int -> int32 (gosec)
		Number:        sql.NullInt32{Int32: int32(b.GetNumber()), Valid: true},
		                                         ^

Check failure on line 385 in database/types/build.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] database/types/build.go#L385

G115: integer overflow conversion int -> int32 (gosec)
Raw output
database/types/build.go:385:44: G115: integer overflow conversion int -> int32 (gosec)
		Parent:        sql.NullInt32{Int32: int32(b.GetParent()), Valid: true},
		                                         ^

Check failure on line 336 in database/types/repo.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] database/types/repo.go#L336

G115: integer overflow conversion int -> int32 (gosec)
Raw output
database/types/repo.go:336:43: G115: integer overflow conversion int -> int32 (gosec)
		Counter:      sql.NullInt32{Int32: int32(r.GetCounter()), Valid: true},
		                                        ^

Check failure on line 134 in database/types/settings.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] database/types/settings.go#L134

G115: integer overflow conversion int64 -> uint64 (gosec)
Raw output
database/types/settings.go:134:35: G115: integer overflow conversion int64 -> uint64 (gosec)
	psAPI.SetStarlarkExecLimit(uint64(ps.StarlarkExecLimit.Int64))
	                                 ^

Check failure on line 205 in database/types/settings.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] database/types/settings.go#L205

G115: integer overflow conversion uint64 -> int64 (gosec)
Raw output
database/types/settings.go:205:49: G115: integer overflow conversion uint64 -> int64 (gosec)
			StarlarkExecLimit: sql.NullInt64{Int64: int64(s.GetStarlarkExecLimit()), Valid: true},
			                                             ^

Check failure on line 42 in api/build/enqueue.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] api/build/enqueue.go#L42

Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
Raw output
api/build/enqueue.go:42:18: Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
	err = queue.Push(context.Background(), route, byteItem)
	                ^

Check failure on line 46 in api/build/enqueue.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] api/build/enqueue.go#L46

Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
Raw output
api/build/enqueue.go:46:19: Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
		err = queue.Push(context.Background(), route, byteItem)
		                ^

Check failure on line 44 in compiler/template/starlark/render.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] compiler/template/starlark/render.go#L44

SA1019: starlark.ExecFile is deprecated: use [ExecFileOptions] with [syntax.FileOptions] instead, because this function relies on legacy global variables. (staticcheck)
Raw output
compiler/template/starlark/render.go:44:18: SA1019: starlark.ExecFile is deprecated: use [ExecFileOptions] with [syntax.FileOptions] instead, because this function relies on legacy global variables. (staticcheck)
	globals, err := starlark.ExecFile(thread, tName, tmpl, predeclared)
	                ^

Check failure on line 152 in compiler/template/starlark/render.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] compiler/template/starlark/render.go#L152

SA1019: starlark.ExecFile is deprecated: use [ExecFileOptions] with [syntax.FileOptions] instead, because this function relies on legacy global variables. (staticcheck)
Raw output
compiler/template/starlark/render.go:152:18: SA1019: starlark.ExecFile is deprecated: use [ExecFileOptions] with [syntax.FileOptions] instead, because this function relies on legacy global variables. (staticcheck)
	globals, err := starlark.ExecFile(thread, "templated-base", b, predeclared)
	                ^

Check failure on line 131 in compiler/template/starlark/starlark.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] compiler/template/starlark/starlark.go#L131

only one cuddle assignment allowed before if statement (wsl)
Raw output
compiler/template/starlark/starlark.go:131:4: only one cuddle assignment allowed before if statement (wsl)
			if err != nil {
			^

Check failure on line 19 in internal/token/generate_rsa.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] internal/token/generate_rsa.go#L19

unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
Raw output
internal/token/generate_rsa.go:19:32: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (tm *Manager) GenerateRSA(ctx context.Context, db database.Interface) error {
                               ^

Check failure on line 45 in internal/token/generate_rsa.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] internal/token/generate_rsa.go#L45

Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
Raw output
internal/token/generate_rsa.go:45:21: Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
		err = db.CreateJWK(context.TODO(), j)
		                  ^

Check failure on line 3 in api/types/queue_build.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] api/types/queue_build.go#L3

3-134 lines are duplicate of `api/types/template.go:4-137` (dupl)
Raw output
api/types/queue_build.go:3: 3-134 lines are duplicate of `api/types/template.go:4-137` (dupl)
package types

import "fmt"

// QueueBuild is the API representation of the builds in the queue.
//
// swagger:model QueueBuild
type QueueBuild struct {
	Status   *string `json:"status,omitempty"`
	Number   *int32  `json:"number,omitempty"`
	Created  *int64  `json:"created,omitempty"`
	FullName *string `json:"full_name,omitempty"`
}

// GetStatus returns the Status field.
//
// When the provided QueueBuild type is nil, or the field within
// the type is nil, it returns the zero value for the field.
func (b *QueueBuild) GetStatus() string {
	// return zero value if QueueBuild type or Status field is nil
	if b == nil || b.Status == nil {
		return ""
	}

	return *b.Status
}

// GetNumber returns the Number field.
//
// When the provided QueueBuild type is nil, or the field within
// the type is nil, it returns the zero value for the field.
func (b *QueueBuild) GetNumber() int32 {
	// return zero value if QueueBuild type or Number field is nil
	if b == nil || b.Number == nil {
		return 0
	}

	return *b.Number
}

// GetCreated returns the Created field.
//
// When the provided QueueBuild type is nil, or the field within
// the type is nil, it returns the zero value for the field.
func (b *QueueBuild) GetCreated() int64 {
	// return zero value if QueueBuild type or Created field is nil
	if b == nil || b.Created == nil {
		return 0
	}

	return *b.Created
}

// GetFullName returns the FullName field.
//
// When the provided QueueBuild type is nil, or the field within
// the type is nil, it returns the zero value for the field.
func (b *QueueBuild) GetFullName() string {
	// return zero value if QueueBuild type or FullName field is nil
	if b == nil || b.FullName == nil {
		return ""
	}

	return *b.FullName
}

// SetStatus sets the Status field.
//
// When the provided QueueBuild type is nil, it
// will set nothing and immediately return.
func (b *QueueBuild) SetStatus(v string) {
	// return if QueueBuild type is nil
	if b == nil {
		return
	}

	b.Status = &v
}

// SetNumber sets the Number field.
//
// When the provided QueueBuild type is nil, it
// will set nothing and immediately return.
func (b *QueueBuild) SetNumber(v int32) {
	// return if QueueBuild type is nil
	if b == nil {
		return
	}

	b.Number = &v
}

// SetCreated sets the Created field.
//
// When the provided QueueBuild type is nil, it
// will set nothing and immediately return.
func (b *QueueBuild) SetCreated(v int64) {
	// return if QueueBuild type is nil
	if b == nil {
		return
	}

	b.Created = &v
}

// SetFullName sets the FullName field.
//
// When the provided QueueBuild type is nil, it
// will set nothing and immediately return.
func (b *QueueBuild) SetFullName(v string) {
	// return if QueueBuild type is nil
	if b == nil {
		return
	}

	b.FullName = &v
}

// String implements the Stringer interface for the QueueBuild type.
func (b *QueueBuild) String() string {
	return fmt.Sprintf(`{
  Created: %d,
  FullName: %s,
  Number: %d,
  Status: %s,
}`,
		b.GetCreated(),
		b.GetFullName(),
		b.GetNumber(),
		b.GetStatus(),
	)
}

Check failure on line 60 in api/types/build.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] api/types/build.go#L60

string `...` has 3 occurrences, make it a constant (goconst)
Raw output
api/types/build.go:60:10: string `...` has 3 occurrences, make it a constant (goconst)
		return "..."
		       ^

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-51 lines are duplicate of `database/pipeline/update.go:3-52` (dupl)
Raw output
database/pipeline/create.go:3: 3-51 lines are duplicate of `database/pipeline/update.go:3-52` (dupl)
package pipeline

import (
	"context"

	"github.com/sirupsen/logrus"

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

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

	pipeline := types.PipelineFromAPI(p)

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

	err = pipeline.Compress(e.config.CompressionLevel)
	if err != nil {
		return nil, err
	}

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

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

	result := pipeline.ToAPI()
	result.SetRepo(p.GetRepo())

	return result, 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-52 lines are duplicate of `database/pipeline/create.go:3-51` (dupl)
Raw output
database/pipeline/update.go:3: 3-52 lines are duplicate of `database/pipeline/create.go:3-51` (dupl)
package pipeline

import (
	"context"

	"github.com/sirupsen/logrus"

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

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

	pipeline := types.PipelineFromAPI(p)

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

	err = pipeline.Compress(e.config.CompressionLevel)
	if err != nil {
		return nil, err
	}

	// send query to the database
	err = e.client.
		WithContext(ctx).
		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
	}

	result := pipeline.ToAPI()
	result.SetRepo(p.GetRepo())

	return result, nil
}

Check failure on line 16 in secret/vault/delete.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] secret/vault/delete.go#L16

unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
Raw output
secret/vault/delete.go:16:25: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (c *client) Delete(ctx context.Context, sType, org, name, path string) error {
                        ^