github.com/databricks/cli@v0.203.0/bundle/config/mutator/default_workspace_root.go (about) 1 package mutator 2 3 import ( 4 "context" 5 "fmt" 6 7 "github.com/databricks/cli/bundle" 8 ) 9 10 type defineDefaultWorkspaceRoot struct{} 11 12 // DefineDefaultWorkspaceRoot defines the default workspace root path. 13 func DefineDefaultWorkspaceRoot() bundle.Mutator { 14 return &defineDefaultWorkspaceRoot{} 15 } 16 17 func (m *defineDefaultWorkspaceRoot) Name() string { 18 return "DefineDefaultWorkspaceRoot" 19 } 20 21 func (m *defineDefaultWorkspaceRoot) Apply(ctx context.Context, b *bundle.Bundle) error { 22 if b.Config.Workspace.RootPath != "" { 23 return nil 24 } 25 26 if b.Config.Bundle.Name == "" { 27 return fmt.Errorf("unable to define default workspace root: bundle name not defined") 28 } 29 30 if b.Config.Bundle.Environment == "" { 31 return fmt.Errorf("unable to define default workspace root: bundle environment not selected") 32 } 33 34 b.Config.Workspace.RootPath = fmt.Sprintf( 35 "~/.bundle/%s/%s", 36 b.Config.Bundle.Name, 37 b.Config.Bundle.Environment, 38 ) 39 return nil 40 }