diff --git a/context/context.go b/context/context.go index 2c2d7f1..a486410 100644 --- a/context/context.go +++ b/context/context.go @@ -750,10 +750,37 @@ func hasPlugin(plugins []string, target string) bool { } func GetRuntimeContext() (RuntimeContext, error) { - if ctx, err := parseContext(); err != nil { + ctx, err := parseContext() + if err != nil { return nil, err - } else { - return ctx, nil + } + return ctx, nil +} + +func CloneRuntimeContext(ctx RuntimeContext) RuntimeContext { + return &FunctionContext{ + + Name: ctx.GetName(), + Version: ctx.GetContext().Version, + Inputs: ctx.GetInputs(), + Outputs: ctx.GetOutputs(), + + Runtime: ctx.GetRuntime(), + Port: ctx.GetPort(), + State: ctx.GetContext().State, + + PrePlugins: ctx.GetPrePlugins(), + PostPlugins: ctx.GetPostPlugins(), + PluginsTracing: ctx.GetContext().PluginsTracing, + HttpPattern: ctx.GetHttpPattern(), + + Event: &EventRequest{}, + SyncRequest: &SyncRequest{}, + mode: ctx.GetMode(), + podName: ctx.GetPodName(), + podNamespace: ctx.GetPodNamespace(), + options: ctx.GetContext().options, + daprClient: ctx.GetContext().daprClient, } } diff --git a/runtime/runtime.go b/runtime/runtime.go index 89332d5..c0d6dcf 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -49,7 +49,7 @@ type RuntimeManager struct { } func NewRuntimeManager(funcContext ofctx.RuntimeContext, prePlugin []plugin.Plugin, postPlugin []plugin.Plugin) *RuntimeManager { - ctx := funcContext + ctx := ofctx.CloneRuntimeContext(funcContext) rm := &RuntimeManager{ FuncContext: ctx, prePlugins: prePlugin,