databricks-cli/bundle/config/mutator/populate_current_user.go

30 lines
604 B
Go

package mutator
import (
"context"
"github.com/databricks/bricks/bundle"
)
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
}