github.com/kubevela/workflow@v0.6.0/pkg/cue/process/contexthook.go (about) 1 /* 2 Copyright 2022 The KubeVela Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package process 18 19 import "github.com/kubevela/workflow/pkg/cue/model" 20 21 // BaseHook defines function to be invoked before setting base to a 22 // process.Context 23 type BaseHook interface { 24 Exec(Context, model.Instance) error 25 } 26 27 // BaseHookFn implements BaseHook interface 28 type BaseHookFn func(Context, model.Instance) error 29 30 // Exec will be invoked before settiing 'base' into ctx.Base 31 func (fn BaseHookFn) Exec(ctx Context, base model.Instance) error { 32 return fn(ctx, base) 33 } 34 35 // AuxiliaryHook defines function to be invoked before appending auxiliaries to 36 // a process.Context 37 type AuxiliaryHook interface { 38 Exec(Context, []Auxiliary) error 39 } 40 41 // AuxiliaryHookFn implements AuxiliaryHook interface 42 type AuxiliaryHookFn func(Context, []Auxiliary) error 43 44 // Exec will be invoked before appending 'auxs' into ctx.Auxiliaries 45 func (fn AuxiliaryHookFn) Exec(ctx Context, auxs []Auxiliary) error { 46 return fn(ctx, auxs) 47 }