feature/add-actions (#9)

Co-authored-by: kjuulh <contact@kjuulh.io>
Reviewed-on: https://git.front.kjuulh.io/kjuulh/kraken/pulls/9
This commit is contained in:
2022-09-14 23:40:58 +02:00
parent ce55f6523c
commit 0cb923a3a5
12 changed files with 275 additions and 42 deletions

View File

@@ -47,18 +47,13 @@ func (ac *ActionCreator) Prepare(ctx context.Context, ops *ActionCreatorOps) (*A
return nil, err
}
cloneCtx, _ := context.WithTimeout(ctx, time.Second*5)
repo, err := ac.git.Clone(cloneCtx, area, ops.RepositoryUrl)
cloneCtx, _ := context.WithTimeout(ctx, time.Second*10)
_, err = ac.git.CloneBranch(cloneCtx, area, ops.RepositoryUrl, ops.Branch)
if err != nil {
ac.logger.Error("could not clone repo", zap.Error(err))
return nil, err
}
err = ac.git.Checkout(ctx, repo, ops.Branch)
if err != nil {
return nil, err
}
executorUrl := path.Join(area.Path, ops.Path)
if _, err = os.Stat(executorUrl); os.IsNotExist(err) {
return nil, fmt.Errorf("path is invalid: %s", ops.Path)
@@ -74,8 +69,10 @@ func (ac *ActionCreator) Prepare(ctx context.Context, ops *ActionCreatorOps) (*A
return nil, err
}
ac.logger.Debug("Action creator done")
return &Action{
Schema: krakenSchema,
Schema: krakenSchema,
SchemaPath: executorUrl,
}, nil
}