2023-02-20 18:42:55 +00:00
|
|
|
package files
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2023-04-18 14:55:06 +00:00
|
|
|
"fmt"
|
2023-02-20 18:42:55 +00:00
|
|
|
|
|
|
|
"github.com/databricks/bricks/bundle"
|
2023-04-18 14:55:06 +00:00
|
|
|
"github.com/databricks/bricks/libs/cmdio"
|
2023-02-20 18:42:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type upload struct{}
|
|
|
|
|
|
|
|
func (m *upload) Name() string {
|
|
|
|
return "files.Upload"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *upload) Apply(ctx context.Context, b *bundle.Bundle) ([]bundle.Mutator, error) {
|
2023-04-18 14:55:06 +00:00
|
|
|
cmdio.LogString(ctx, "Starting upload of bundle files")
|
2023-04-11 14:57:01 +00:00
|
|
|
sync, err := getSync(ctx, b)
|
2023-02-20 18:42:55 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = sync.RunOnce(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-04-18 14:55:06 +00:00
|
|
|
cmdio.LogString(ctx, fmt.Sprintf("Uploaded bundle files at %s!\n", b.Config.Workspace.FilesPath))
|
2023-02-20 18:42:55 +00:00
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func Upload() bundle.Mutator {
|
|
|
|
return &upload{}
|
|
|
|
}
|