Skip to content

Commit 87c9e86

Browse files
authored
Move libs/apps code into libs/apps/runlocal subdirectory (#3933)
## Changes The code in `libs/apps` was specific to the `apps run-local` command. This moves it to `libs/apps/runlocal` to make `libs/apps` a collection of packages rather than a single package. ## Why Make space for other libraries under `libs/apps`. ## Tests n/a
1 parent a82f3f6 commit 87c9e86

File tree

11 files changed

+21
-21
lines changed

11 files changed

+21
-21
lines changed

cmd/workspace/apps/run_local.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
"github.com/databricks/cli/cmd/root"
1515
"github.com/databricks/cli/libs/appproxy"
16-
"github.com/databricks/cli/libs/apps"
16+
"github.com/databricks/cli/libs/apps/runlocal"
1717
"github.com/databricks/cli/libs/auth"
1818
"github.com/databricks/cli/libs/cmdctx"
1919
"github.com/databricks/cli/libs/cmdio"
@@ -25,7 +25,7 @@ import (
2525
// https://docs.databricks.com/aws/en/dev-tools/databricks-apps/app-development#important-guidelines-for-implementing-databricks-apps
2626
const SHUTDOWN_TIMEOUT = 15 * time.Second
2727

28-
func setupWorkspaceAndConfig(cmd *cobra.Command, entryPoint string, appPort int) (*apps.Config, *apps.AppSpec, error) {
28+
func setupWorkspaceAndConfig(cmd *cobra.Command, entryPoint string, appPort int) (*runlocal.Config, *runlocal.AppSpec, error) {
2929
ctx := cmd.Context()
3030
w := cmdctx.WorkspaceClient(ctx)
3131
workspaceId, err := w.CurrentWorkspaceID(ctx)
@@ -38,22 +38,22 @@ func setupWorkspaceAndConfig(cmd *cobra.Command, entryPoint string, appPort int)
3838
return nil, nil, err
3939
}
4040

41-
config := apps.NewConfig(w.Config.Host, workspaceId, cwd, apps.DEFAULT_HOST, appPort)
41+
config := runlocal.NewConfig(w.Config.Host, workspaceId, cwd, runlocal.DEFAULT_HOST, appPort)
4242
if entryPoint != "" {
4343
config.AppSpecFiles = []string{entryPoint}
4444
}
45-
spec, err := apps.ReadAppSpecFile(config)
45+
spec, err := runlocal.ReadAppSpecFile(config)
4646
if err != nil {
4747
return nil, nil, err
4848
}
4949

5050
return config, spec, nil
5151
}
5252

53-
func setupApp(cmd *cobra.Command, config *apps.Config, spec *apps.AppSpec, customEnv []string, prepareEnvironment bool) (apps.App, []string, error) {
53+
func setupApp(cmd *cobra.Command, config *runlocal.Config, spec *runlocal.AppSpec, customEnv []string, prepareEnvironment bool) (runlocal.App, []string, error) {
5454
ctx := cmd.Context()
5555
cfg := cmdctx.ConfigUsed(ctx)
56-
app, err := apps.NewApp(ctx, config, spec)
56+
app, err := runlocal.NewApp(ctx, config, spec)
5757
if err != nil {
5858
return nil, nil, err
5959
}
@@ -79,7 +79,7 @@ func setupApp(cmd *cobra.Command, config *apps.Config, spec *apps.AppSpec, custo
7979
return app, env, nil
8080
}
8181

82-
func startAppProcess(cmd *cobra.Command, config *apps.Config, app apps.App, env []string, debug bool) (*exec.Cmd, error) {
82+
func startAppProcess(cmd *cobra.Command, config *runlocal.Config, app runlocal.App, env []string, debug bool) (*exec.Cmd, error) {
8383
ctx := cmd.Context()
8484
specCommand, err := app.GetCommand(debug)
8585
if err != nil {
@@ -93,7 +93,7 @@ func startAppProcess(cmd *cobra.Command, config *apps.Config, app apps.App, env
9393
appCmd.Stderr = cmd.ErrOrStderr()
9494

9595
var appCmdEnv []string
96-
appEnvs := apps.GetBaseEnvVars(config)
96+
appEnvs := runlocal.GetBaseEnvVars(config)
9797
for _, envVar := range appEnvs {
9898
appCmdEnv = append(appCmdEnv, envVar.String())
9999
}
@@ -109,7 +109,7 @@ func startAppProcess(cmd *cobra.Command, config *apps.Config, app apps.App, env
109109
return appCmd, nil
110110
}
111111

112-
func setupProxy(ctx context.Context, cmd *cobra.Command, config *apps.Config, w *databricks.WorkspaceClient, port int, debug bool) error {
112+
func setupProxy(ctx context.Context, cmd *cobra.Command, config *runlocal.Config, w *databricks.WorkspaceClient, port int, debug bool) error {
113113
proxy, err := appproxy.New(ctx, config.AppURL)
114114
if err != nil {
115115
return err
@@ -120,7 +120,7 @@ func setupProxy(ctx context.Context, cmd *cobra.Command, config *apps.Config, w
120120
return err
121121
}
122122

123-
for key, value := range apps.GetXHeaders(me) {
123+
for key, value := range runlocal.GetXHeaders(me) {
124124
proxy.InjectHeader(key, value)
125125
}
126126

@@ -191,7 +191,7 @@ func newRunLocal() *cobra.Command {
191191
This command starts an app locally.`
192192

193193
cmd.Flags().IntVar(&port, "port", 8001, "Port on which to run the app app proxy")
194-
cmd.Flags().IntVar(&appPort, "app-port", apps.DEFAULT_PORT, "Port on which to run the app")
194+
cmd.Flags().IntVar(&appPort, "app-port", runlocal.DEFAULT_PORT, "Port on which to run the app")
195195
cmd.Flags().BoolVar(&debug, "debug", false, "Enable debug mode")
196196
cmd.Flags().BoolVar(&prepareEnvironment, "prepare-environment", false, "Prepares the environment for running the app. Requires 'uv' to be installed.")
197197
cmd.Flags().StringSliceVar(&customEnv, "env", nil, "Set environment variables")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package apps
1+
package runlocal
22

33
import (
44
"context"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package apps
1+
package runlocal
22

33
import "fmt"
44

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package apps
1+
package runlocal
22

33
import (
44
"strconv"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package apps
1+
package runlocal
22

33
import (
44
"github.com/databricks/databricks-sdk-go/service/iam"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package apps
1+
package runlocal
22

33
import (
44
"context"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package apps
1+
package runlocal
22

33
import (
44
"context"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package apps
1+
package runlocal
22

33
import (
44
"context"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package apps
1+
package runlocal
22

33
import (
44
"context"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package apps
1+
package runlocal
22

33
import (
44
"context"

0 commit comments

Comments
 (0)