Skip to content

Commit

Permalink
fix: fix lint and rebase
Browse files Browse the repository at this point in the history
Signed-off-by: FogDong <[email protected]>
  • Loading branch information
FogDong committed Jul 13, 2024
1 parent e9c0f4a commit ce912dc
Show file tree
Hide file tree
Showing 25 changed files with 65 additions and 1,510 deletions.
232 changes: 12 additions & 220 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (wf *WorkflowContext) sync(ctx context.Context) error {
}

// LoadFromConfigMap recover workflow context from configMap.
func (wf *WorkflowContext) LoadFromConfigMap(ctx context.Context, cm corev1.ConfigMap) error {
func (wf *WorkflowContext) LoadFromConfigMap(_ context.Context, cm corev1.ConfigMap) error {
if wf.store == nil {
wf.store = &cm
}
Expand Down
10 changes: 2 additions & 8 deletions pkg/debug/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,15 @@ func setStore(ctx context.Context, instance *wfTypes.WorkflowInstance, id, data
}
cm.Labels = map[string]string{}
cm.SetOwnerReferences(instance.ChildOwnerReferences)
if err := cli.Create(ctx, cm); err != nil {
return err
}
return nil
return cli.Create(ctx, cm)
}
return err
}
cm.Data = map[string]string{
"debug": data,
}
if err := cli.Update(ctx, cm); err != nil {
return err
}

return nil
return cli.Update(ctx, cm)

Check warning on line 81 in pkg/debug/context.go

View check run for this annotation

Codecov / codecov/patch

pkg/debug/context.go#L81

Added line #L81 was not covered by tests
}

// NewContext new workflow context without initialize data.
Expand Down
14 changes: 0 additions & 14 deletions pkg/executor/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package executor

import (
"github.com/kubevela/pkg/cue/cuex"
"github.com/kubevela/workflow/pkg/types"
)

Expand All @@ -26,19 +25,6 @@ type Option interface {
ApplyTo(*workflowExecutor)
}

type withCompiler struct {
compiler *cuex.Compiler
}

func (w *withCompiler) ApplyTo(e *workflowExecutor) {
e.compiler = w.compiler
}

// WithCompiler set the cue compiler
func WithCompiler(compiler *cuex.Compiler) Option {
return &withCompiler{compiler: compiler}
}

type withStatusPatcher struct {
patcher types.StatusPatcher
}
Expand Down
14 changes: 1 addition & 13 deletions pkg/executor/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/util/feature"

"github.com/kubevela/pkg/cue/cuex"
monitorContext "github.com/kubevela/pkg/monitor/context"

"github.com/kubevela/workflow/api/v1alpha1"
Expand All @@ -38,7 +37,6 @@ import (
"github.com/kubevela/workflow/pkg/features"
"github.com/kubevela/workflow/pkg/hooks"
"github.com/kubevela/workflow/pkg/monitor/metrics"
"github.com/kubevela/workflow/pkg/providers"
"github.com/kubevela/workflow/pkg/providers/legacy/workspace"
"github.com/kubevela/workflow/pkg/tasks/custom"
"github.com/kubevela/workflow/pkg/types"
Expand All @@ -62,7 +60,6 @@ type workflowExecutor struct {
instance *types.WorkflowInstance
wfCtx wfContext.Context
patcher types.StatusPatcher
compiler *cuex.Compiler
}

// New returns a Workflow Executor implementation.
Expand All @@ -71,9 +68,6 @@ func New(instance *types.WorkflowInstance, options ...Option) WorkflowExecutor {
for _, opt := range options {
opt.ApplyTo(executor)
}
if executor.compiler == nil {
executor.compiler = providers.Compiler.Get()
}
return executor
}

Expand Down Expand Up @@ -214,7 +208,6 @@ func newEngine(ctx monitorContext.Context, wfCtx wfContext.Context, w *workflowE
stepTimeout: make(map[string]time.Time),
taskRunners: taskRunners,
statusPatcher: w.patcher,
compiler: w.compiler,
}
}

Expand Down Expand Up @@ -587,7 +580,6 @@ func (e *engine) generateRunOptions(ctx monitorContext.Context, dependsOnPhase v
},
StepStatus: e.stepStatus,
Engine: e,
Compiler: e.compiler,
PreCheckHooks: []types.TaskPreCheckHook{
func(step v1alpha1.WorkflowStep, options *types.PreCheckOptions) (*types.PreCheckResult, error) {
if feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendOnFailure) {
Expand Down Expand Up @@ -643,10 +635,7 @@ func (e *engine) generateRunOptions(ctx monitorContext.Context, dependsOnPhase v
if e.debug {
options.Debug = func(id string, v cue.Value) error {
debugContext := debug.NewContext(e.instance, id)
if err := debugContext.Set(v); err != nil {
return err
}
return nil
return debugContext.Set(v)

Check warning on line 638 in pkg/executor/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/executor/workflow.go#L636-L638

Added lines #L636 - L638 were not covered by tests
}
}
return options
Expand All @@ -666,7 +655,6 @@ type engine struct {
stepDependsOn map[string][]string
taskRunners []types.TaskRunner
statusPatcher types.StatusPatcher
compiler *cuex.Compiler
}

func (e *engine) finishStep(operation *types.Operation) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/executor/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
wfContext "github.com/kubevela/workflow/pkg/context"
"github.com/kubevela/workflow/pkg/cue/process"
"github.com/kubevela/workflow/pkg/features"
"github.com/kubevela/workflow/pkg/providers"
"github.com/kubevela/workflow/pkg/tasks/builtin"
"github.com/kubevela/workflow/pkg/tasks/custom"
"github.com/kubevela/workflow/pkg/types"
Expand Down Expand Up @@ -2373,7 +2374,7 @@ func (tr *testTaskRunner) Run(ctx wfContext.Context, options *types.TaskRunOptio
resetter := tr.fillContext(logCtx, options.PCtx)
defer resetter(options.PCtx)

basicVal, err := custom.MakeBasicValue(logCtx, nil, options.PCtx)
basicVal, err := custom.MakeBasicValue(logCtx, providers.Compiler.Get(), nil, options.PCtx)
if err != nil {
return v1alpha1.StepStatus{}, nil, err
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/kubevela/workflow/pkg/executor"
"github.com/kubevela/workflow/pkg/monitor/metrics"

"github.com/kubevela/workflow/pkg/providers"
"github.com/kubevela/workflow/pkg/tasks"
"github.com/kubevela/workflow/pkg/tasks/template"
"github.com/kubevela/workflow/pkg/types"
Expand Down Expand Up @@ -132,13 +133,16 @@ func GenerateWorkflowInstance(ctx context.Context, cli client.Client, run *v1alp
return instance, nil
}

func initStepGeneratorOptions(ctx monitorContext.Context, instance *types.WorkflowInstance, options types.StepGeneratorOptions) types.StepGeneratorOptions {
func initStepGeneratorOptions(_ monitorContext.Context, instance *types.WorkflowInstance, options types.StepGeneratorOptions) types.StepGeneratorOptions {
if options.ProcessCtx == nil {
options.ProcessCtx = process.NewContext(generateContextDataFromWorkflowRun(instance))
}
if options.TemplateLoader == nil {
options.TemplateLoader = template.NewWorkflowStepTemplateLoader()
}
if options.Compiler == nil {
options.Compiler = providers.Compiler.Get()
}
return options
}

Expand Down
Loading

0 comments on commit ce912dc

Please sign in to comment.