diff --git a/bundle/config/environment.go b/bundle/config/environment.go index 5288676e8..5e58b9a78 100644 --- a/bundle/config/environment.go +++ b/bundle/config/environment.go @@ -2,12 +2,6 @@ package config type Mode string -const ( - Debug Mode = "debug" - Default Mode = "default" - PullRequest Mode = "pull-request" -) - // Environment defines overrides for a single environment. // This structure is recursively merged into the root configuration. type Environment struct { @@ -30,3 +24,9 @@ type Environment struct { // in the scope of an environment Variables map[string]string `json:"variables,omitempty"` } + +const ( + // Right now, we just have a default / "" mode and a "development" mode. + // Additional modes are expected to come for pull-requests and production. + Development Mode = "development" +) diff --git a/bundle/config/mutator/override_compute.go b/bundle/config/mutator/override_compute.go index 0e1aaa21e..fbca28322 100644 --- a/bundle/config/mutator/override_compute.go +++ b/bundle/config/mutator/override_compute.go @@ -37,7 +37,7 @@ func (m *overrideCompute) Apply(ctx context.Context, b *bundle.Bundle) error { if m.compute == "" { return nil } - if b.Config.Bundle.Mode != config.Debug { + if b.Config.Bundle.Mode != config.Development { return fmt.Errorf("cannot override compute for an environment that does not use 'mode: debug'") } diff --git a/bundle/config/mutator/override_compute_test.go b/bundle/config/mutator/override_compute_test.go index f6e0eca70..07a8578bb 100644 --- a/bundle/config/mutator/override_compute_test.go +++ b/bundle/config/mutator/override_compute_test.go @@ -18,7 +18,7 @@ func TestOverrideCompute(t *testing.T) { bundle := &bundle.Bundle{ Config: config.Root{ Bundle: config.Bundle{ - Mode: config.Debug, + Mode: config.Development, }, Resources: config.Resources{ Jobs: map[string]*resources.Job{ diff --git a/bundle/config/mutator/process_environment_mode.go b/bundle/config/mutator/process_environment_mode.go index cd2510acd..ad2d2d4c6 100644 --- a/bundle/config/mutator/process_environment_mode.go +++ b/bundle/config/mutator/process_environment_mode.go @@ -21,18 +21,18 @@ func (m *processEnvironmentMode) Name() string { return "ProcessEnvironmentMode" } -// Mark all resources as being for 'debug' purposes, i.e. +// Mark all resources as being for 'development' purposes, i.e. // changing their their name, adding tags, and (in the future) // marking them as 'hidden' in the UI. -func processDebugMode(b *bundle.Bundle) error { +func processDevelopmentMode(b *bundle.Bundle) error { r := b.Config.Resources for i := range r.Jobs { - r.Jobs[i].Name = "[debug] " + r.Jobs[i].Name + r.Jobs[i].Name = "[dev] " + r.Jobs[i].Name if r.Jobs[i].Tags == nil { r.Jobs[i].Tags = make(map[string]string) } - r.Jobs[i].Tags["debug"] = "" + r.Jobs[i].Tags["dev"] = "" if r.Jobs[i].MaxConcurrentRuns == 0 { r.Jobs[i].MaxConcurrentRuns = debugConcurrentRuns } @@ -48,19 +48,19 @@ func processDebugMode(b *bundle.Bundle) error { } for i := range r.Pipelines { - r.Pipelines[i].Name = "[debug] " + r.Pipelines[i].Name + r.Pipelines[i].Name = "[dev] " + r.Pipelines[i].Name r.Pipelines[i].Development = true // (pipelines don't yet support tags) } for i := range r.Models { - r.Models[i].Name = "[debug] " + r.Models[i].Name - r.Models[i].Tags = append(r.Models[i].Tags, ml.ModelTag{Key: "debug", Value: ""}) + r.Models[i].Name = "[dev] " + r.Models[i].Name + r.Models[i].Tags = append(r.Models[i].Tags, ml.ModelTag{Key: "dev", Value: ""}) } for i := range r.Experiments { - r.Experiments[i].Name = "[debug] " + r.Experiments[i].Name - r.Experiments[i].Tags = append(r.Experiments[i].Tags, ml.ExperimentTag{Key: "debug", Value: ""}) + r.Experiments[i].Name = "[dev] " + r.Experiments[i].Name + r.Experiments[i].Tags = append(r.Experiments[i].Tags, ml.ExperimentTag{Key: "dev", Value: ""}) } return nil @@ -68,12 +68,10 @@ func processDebugMode(b *bundle.Bundle) error { func (m *processEnvironmentMode) Apply(ctx context.Context, b *bundle.Bundle) error { switch b.Config.Bundle.Mode { - case config.Debug: - return processDebugMode(b) - case config.Default, "": + case config.Development: + return processDevelopmentMode(b) + case "": // No action - case config.PullRequest: - return fmt.Errorf("not implemented") default: return fmt.Errorf("unsupported value specified for 'mode': %s", b.Config.Bundle.Mode) } diff --git a/bundle/config/mutator/process_environment_mode_test.go b/bundle/config/mutator/process_environment_mode_test.go index c48182c76..d3ecbd559 100644 --- a/bundle/config/mutator/process_environment_mode_test.go +++ b/bundle/config/mutator/process_environment_mode_test.go @@ -19,7 +19,7 @@ func TestProcessEnvironmentModeApplyDebug(t *testing.T) { bundle := &bundle.Bundle{ Config: config.Root{ Bundle: config.Bundle{ - Mode: config.Debug, + Mode: config.Development, }, Resources: config.Resources{ Jobs: map[string]*resources.Job{ diff --git a/bundle/config/root_test.go b/bundle/config/root_test.go index 3081b8990..818e89a2d 100644 --- a/bundle/config/root_test.go +++ b/bundle/config/root_test.go @@ -159,7 +159,7 @@ func TestRootMergeEnvironmentWithMode(t *testing.T) { root := &Root{ Bundle: Bundle{}, } - env := &Environment{Mode: Debug} + env := &Environment{Mode: Development} require.NoError(t, root.MergeEnvironment(env)) - assert.Equal(t, Debug, root.Bundle.Mode) + assert.Equal(t, Development, root.Bundle.Mode) } diff --git a/bundle/tests/job_and_pipeline_test.go b/bundle/tests/job_and_pipeline_test.go index d6f05b932..775f415c2 100644 --- a/bundle/tests/job_and_pipeline_test.go +++ b/bundle/tests/job_and_pipeline_test.go @@ -16,7 +16,7 @@ func TestJobAndPipelineDevelopment(t *testing.T) { p := b.Config.Resources.Pipelines["nyc_taxi_pipeline"] assert.Equal(t, "job_and_pipeline/bundle.yml", filepath.ToSlash(p.ConfigFilePath)) - assert.Equal(t, b.Config.Bundle.Mode, config.Debug) + assert.Equal(t, b.Config.Bundle.Mode, config.Development) assert.True(t, p.Development) require.Len(t, p.Libraries, 1) assert.Equal(t, "./dlt/nyc_taxi_loader", p.Libraries[0].Notebook.Path)