|
|
|
@ -7,6 +7,7 @@ import (
|
|
|
|
|
|
|
|
|
|
"github.com/drone/drone-go/drone"
|
|
|
|
|
"github.com/drone/runner-go/client"
|
|
|
|
|
"github.com/drone/runner-go/internal"
|
|
|
|
|
"github.com/drone/runner-go/pipeline"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -22,7 +23,8 @@ func New(client client.Client) *Upload {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *Upload) UploadCard(ctx context.Context, r io.ReadCloser, step int64) error {
|
|
|
|
|
func (s *Upload) UploadCard(ctx context.Context, r io.ReadCloser, state *pipeline.State, stepName string) error {
|
|
|
|
|
src := state.Find(stepName)
|
|
|
|
|
bytes, err := io.ReadAll(r)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
@ -32,9 +34,20 @@ func (s *Upload) UploadCard(ctx context.Context, r io.ReadCloser, step int64) er
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
err = s.client.UploadCard(ctx, step, &card)
|
|
|
|
|
err = s.client.UploadCard(ctx, src.ID, &card)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
// update step schema
|
|
|
|
|
state.Lock()
|
|
|
|
|
src.Schema = card.Schema
|
|
|
|
|
cpy := internal.CloneStep(src)
|
|
|
|
|
state.Unlock()
|
|
|
|
|
err = s.client.UpdateStep(ctx, cpy)
|
|
|
|
|
if err == nil {
|
|
|
|
|
state.Lock()
|
|
|
|
|
internal.MergeStep(cpy, src)
|
|
|
|
|
state.Unlock()
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|