1
0
mirror of https://codeberg.org/crowci/crow.git synced 2025-08-09 07:42:52 +03:00

Enable golangci linter contextcheck (#3170)

Split out from https://github.com/woodpecker-ci/woodpecker/pull/2960
This commit is contained in:
Robert Kaussow
2024-01-11 22:15:15 +01:00
committed by GitHub
parent d0380e31b5
commit f813badcf9
10 changed files with 32 additions and 35 deletions

View File

@@ -47,7 +47,6 @@ const (
var defaultDeleteOptions = newDefaultDeleteOptions()
type kube struct {
ctx context.Context
client kubernetes.Interface
config *config
goos string
@@ -117,10 +116,8 @@ func configFromCliContext(ctx context.Context) (*config, error) {
}
// New returns a new Kubernetes Backend.
func New(ctx context.Context) types.Backend {
return &kube{
ctx: ctx,
}
func New() types.Backend {
return &kube{}
}
func (e *kube) Name() string {
@@ -132,8 +129,8 @@ func (e *kube) IsAvailable(context.Context) bool {
return len(host) > 0
}
func (e *kube) Load(context.Context) (*types.BackendInfo, error) {
config, err := configFromCliContext(e.ctx)
func (e *kube) Load(ctx context.Context) (*types.BackendInfo, error) {
config, err := configFromCliContext(ctx)
if err != nil {
return nil, err
}
@@ -334,31 +331,31 @@ func (e *kube) TailStep(ctx context.Context, step *types.Step, taskUUID string)
return rc, nil
}
func (e *kube) DestroyStep(_ context.Context, step *types.Step, taskUUID string) error {
func (e *kube) DestroyStep(ctx context.Context, step *types.Step, taskUUID string) error {
if step.Type == types.StepTypeService {
// a service should be stopped by DestroyWorkflow so we can ignore it
log.Trace().Msgf("DestroyStep got service '%s', ignoring it.", step.Name)
log.Trace().Msgf("destroyStep got service '%s', ignoring it.", step.Name)
return nil
}
log.Trace().Str("taskUUID", taskUUID).Msgf("stopping step: %s", step.Name)
err := stopPod(e.ctx, e, step, defaultDeleteOptions)
log.Trace().Str("taskUUID", taskUUID).Msgf("Stopping step: %s", step.Name)
err := stopPod(ctx, e, step, defaultDeleteOptions)
return err
}
// Destroy the pipeline environment.
func (e *kube) DestroyWorkflow(_ context.Context, conf *types.Config, taskUUID string) error {
func (e *kube) DestroyWorkflow(ctx context.Context, conf *types.Config, taskUUID string) error {
log.Trace().Str("taskUUID", taskUUID).Msg("deleting Kubernetes primitives")
// Use noContext because the ctx sent to this function will be canceled/done in case of error or canceled by user.
for _, stage := range conf.Stages {
for _, step := range stage.Steps {
err := stopPod(e.ctx, e, step, defaultDeleteOptions)
err := stopPod(ctx, e, step, defaultDeleteOptions)
if err != nil {
return err
}
if step.Type == types.StepTypeService {
err := stopService(e.ctx, e, step, defaultDeleteOptions)
err := stopService(ctx, e, step, defaultDeleteOptions)
if err != nil {
return err
}
@@ -367,7 +364,7 @@ func (e *kube) DestroyWorkflow(_ context.Context, conf *types.Config, taskUUID s
}
for _, vol := range conf.Volumes {
err := stopVolume(e.ctx, e, vol.Name, defaultDeleteOptions)
err := stopVolume(ctx, e, vol.Name, defaultDeleteOptions)
if err != nil {
return err
}