2022-12-01 10:17:29 +00:00
|
|
|
package mutator
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2023-05-16 16:35:39 +00:00
|
|
|
"github.com/databricks/cli/bundle"
|
2022-12-01 10:17:29 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type populateCurrentUser struct{}
|
|
|
|
|
|
|
|
// PopulateCurrentUser sets the `current_user` property on the workspace.
|
|
|
|
func PopulateCurrentUser() bundle.Mutator {
|
|
|
|
return &populateCurrentUser{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *populateCurrentUser) Name() string {
|
|
|
|
return "PopulateCurrentUser"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *populateCurrentUser) Apply(ctx context.Context, b *bundle.Bundle) ([]bundle.Mutator, error) {
|
|
|
|
w := b.WorkspaceClient()
|
|
|
|
me, err := w.CurrentUser.Me(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
b.Config.Workspace.CurrentUser = me
|
|
|
|
return nil, nil
|
|
|
|
}
|