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

30 lines
571 B
Go

package mutator
import (
"context"
"github.com/databricks/cli/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) error {
w := b.WorkspaceClient()
me, err := w.CurrentUser.Me(ctx)
if err != nil {
return err
}
b.Config.Workspace.CurrentUser = me
return nil
}