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
|
|
|
|
2023-05-16 16:35:39 +00:00
|
|
|
"github.com/databricks/cli/bundle"
|
|
|
|
"github.com/databricks/cli/libs/cmdio"
|
2023-02-20 18:42:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type upload struct{}
|
|
|
|
|
|
|
|
func (m *upload) Name() string {
|
|
|
|
return "files.Upload"
|
|
|
|
}
|
|
|
|
|
2023-05-24 12:45:19 +00:00
|
|
|
func (m *upload) Apply(ctx context.Context, b *bundle.Bundle) 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 {
|
2023-05-24 12:45:19 +00:00
|
|
|
return err
|
2023-02-20 18:42:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = sync.RunOnce(ctx)
|
|
|
|
if err != nil {
|
2023-05-24 12:45:19 +00:00
|
|
|
return err
|
2023-02-20 18:42:55 +00:00
|
|
|
}
|
|
|
|
|
2023-04-18 14:55:06 +00:00
|
|
|
cmdio.LogString(ctx, fmt.Sprintf("Uploaded bundle files at %s!\n", b.Config.Workspace.FilesPath))
|
2023-05-24 12:45:19 +00:00
|
|
|
return nil
|
2023-02-20 18:42:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func Upload() bundle.Mutator {
|
|
|
|
return &upload{}
|
|
|
|
}
|