diff --git a/pipeline/executor.go b/pipeline/executor.go index 7632bfd..7d3b0b8 100644 --- a/pipeline/executor.go +++ b/pipeline/executor.go @@ -39,6 +39,7 @@ type actContext struct { t TemplateEngine } +func (ac actContext) Action() Action { return ac.c } func (ac actContext) Data() dom.ContainerBuilder { return ac.d } func (ac actContext) Factory() dom.ContainerFactory { return ac.f } func (ac actContext) Executor() Executor { return ac.e } @@ -47,8 +48,9 @@ func (ac actContext) Snapshot() map[string]interface{} { return dom.DefaultNodeMappingFn(ac.Data()).(map[string]interface{}) } -func (p *exec) newCtx() *actContext { +func (p *exec) newCtx(a Action) *actContext { return &actContext{ + c: a, d: p.gd, e: p, f: b, @@ -57,7 +59,7 @@ func (p *exec) newCtx() *actContext { } func (p *exec) Execute(act Action) (err error) { - ctx := p.newCtx() + ctx := p.newCtx(act) p.l.OnBefore(ctx) defer p.l.OnAfter(ctx, err) err = act.Do(ctx) diff --git a/pipeline/types.go b/pipeline/types.go index 095d653..b4b7a01 100644 --- a/pipeline/types.go +++ b/pipeline/types.go @@ -86,6 +86,8 @@ type ActionContext interface { Executor() Executor // TemplateEngine return reference to TemplateEngine TemplateEngine() TemplateEngine + // Action return reference to actual Action + Action() Action } // Action is implemented by actions within ActionSpec diff --git a/pipeline/utils_test.go b/pipeline/utils_test.go index dd07f7e..79c3137 100644 --- a/pipeline/utils_test.go +++ b/pipeline/utils_test.go @@ -32,7 +32,13 @@ func mockEmptyActCtx() ActionContext { } func mockActCtx(data dom.ContainerBuilder) ActionContext { - return New(WithData(data)).(*exec).newCtx() + return New(WithData(data)).(*exec).newCtx(nil) +} + +func TestGetActionFromContext(t *testing.T) { + ac := mockEmptyActCtx().(*actContext) + ac.c = &ExportOp{} + assert.NotNil(t, ac.Action()) } func TestNonEmpty(t *testing.T) {