From bc51640391722e6deead17d5a0a9622bbfdd3420 Mon Sep 17 00:00:00 2001 From: Ryan VanGundy Date: Mon, 13 Oct 2025 09:00:48 -0400 Subject: [PATCH 1/4] fix(blueprint): Correctly generate default repo URL The default repo URL generated when initializing a new blueprint is fixed. It will correctly normalize the URLs and retain or add the HTTP protocol appropriately. It also correctly establishes the local dev URL. --- pkg/blueprint/blueprint_handler.go | 23 ++++- .../blueprint_handler_private_test.go | 98 ++++++++++++++++++- .../blueprint_handler_public_test.go | 66 +++++++++++++ 3 files changed, 182 insertions(+), 5 deletions(-) diff --git a/pkg/blueprint/blueprint_handler.go b/pkg/blueprint/blueprint_handler.go index 2f93e5601..d300638e4 100644 --- a/pkg/blueprint/blueprint_handler.go +++ b/pkg/blueprint/blueprint_handler.go @@ -146,6 +146,10 @@ func (b *BaseBlueprintHandler) LoadConfig() error { return err } + if err := b.setRepositoryDefaults(); err != nil { + return fmt.Errorf("error setting repository defaults: %w", err) + } + b.configLoaded = true return nil } @@ -169,6 +173,10 @@ func (b *BaseBlueprintHandler) LoadData(data map[string]any, ociInfo ...*artifac return err } + if err := b.setRepositoryDefaults(); err != nil { + return fmt.Errorf("error setting repository defaults: %w", err) + } + return nil } @@ -1841,17 +1849,28 @@ func (b *BaseBlueprintHandler) setRepositoryDefaults() error { gitURL, err := b.shell.ExecSilent("git", "config", "--get", "remote.origin.url") if err == nil && gitURL != "" { - b.blueprint.Repository.Url = strings.TrimSpace(gitURL) + b.blueprint.Repository.Url = b.normalizeGitURL(strings.TrimSpace(gitURL)) return nil } return nil } +// normalizeGitURL normalizes git repository URLs by prepending https:// when needed. +// Preserves SSH URLs (git@...), http://, and https:// URLs as-is. +func (b *BaseBlueprintHandler) normalizeGitURL(url string) string { + if strings.HasPrefix(url, "git@") || + strings.HasPrefix(url, "http://") || + strings.HasPrefix(url, "https://") { + return url + } + return "https://" + url +} + // getDevelopmentRepositoryURL generates a development repository URL from configuration. // Returns URL in format: http://git./git/ func (b *BaseBlueprintHandler) getDevelopmentRepositoryURL() string { - domain := b.configHandler.GetString("dns.domain") + domain := b.configHandler.GetString("dns.domain", "test") if domain == "" { return "" } diff --git a/pkg/blueprint/blueprint_handler_private_test.go b/pkg/blueprint/blueprint_handler_private_test.go index 40e4cb74c..77deea1a2 100644 --- a/pkg/blueprint/blueprint_handler_private_test.go +++ b/pkg/blueprint/blueprint_handler_private_test.go @@ -3511,6 +3511,33 @@ func TestBaseBlueprintHandler_setRepositoryDefaults(t *testing.T) { } }) + t.Run("PreservesSSHGitRemoteOrigin", func(t *testing.T) { + handler := setup(t) + + mockConfigHandler := handler.configHandler.(*config.MockConfigHandler) + mockConfigHandler.GetBoolFunc = func(key string, defaultValue ...bool) bool { + return false + } + + mockShell := handler.shell.(*shell.MockShell) + mockShell.ExecSilentFunc = func(command string, args ...string) (string, error) { + if command == "git" && len(args) == 3 && args[0] == "config" && args[2] == "remote.origin.url" { + return "git@github.com:windsorcli/core.git\n", nil + } + return "", fmt.Errorf("command not found") + } + + err := handler.setRepositoryDefaults() + + if err != nil { + t.Fatalf("Expected no error, got %v", err) + } + expectedURL := "git@github.com:windsorcli/core.git" + if handler.blueprint.Repository.Url != expectedURL { + t.Errorf("Expected URL to be %s, got %s", expectedURL, handler.blueprint.Repository.Url) + } + }) + t.Run("HandlesGitRemoteOriginError", func(t *testing.T) { handler := setup(t) @@ -3591,6 +3618,63 @@ func TestBaseBlueprintHandler_setRepositoryDefaults(t *testing.T) { }) } +func TestBaseBlueprintHandler_normalizeGitURL(t *testing.T) { + setup := func(t *testing.T) *BaseBlueprintHandler { + t.Helper() + mocks := setupMocks(t) + handler := NewBlueprintHandler(mocks.Injector) + return handler + } + + t.Run("PreservesSSHURL", func(t *testing.T) { + handler := setup(t) + + input := "git@github.com:windsorcli/core.git" + expected := "git@github.com:windsorcli/core.git" + result := handler.normalizeGitURL(input) + + if result != expected { + t.Errorf("Expected %s, got %s", expected, result) + } + }) + + t.Run("PreservesHTTPSURL", func(t *testing.T) { + handler := setup(t) + + input := "https://github.com/windsorcli/core.git" + expected := "https://github.com/windsorcli/core.git" + result := handler.normalizeGitURL(input) + + if result != expected { + t.Errorf("Expected %s, got %s", expected, result) + } + }) + + t.Run("PreservesHTTPURL", func(t *testing.T) { + handler := setup(t) + + input := "http://git.test/git/core" + expected := "http://git.test/git/core" + result := handler.normalizeGitURL(input) + + if result != expected { + t.Errorf("Expected %s, got %s", expected, result) + } + }) + + t.Run("PrependsHTTPSToPlainURL", func(t *testing.T) { + handler := setup(t) + + input := "github.com/windsorcli/core.git" + expected := "https://github.com/windsorcli/core.git" + result := handler.normalizeGitURL(input) + + if result != expected { + t.Errorf("Expected %s, got %s", expected, result) + } + }) +} + func TestBaseBlueprintHandler_getDevelopmentRepositoryURL(t *testing.T) { setup := func(t *testing.T) *BaseBlueprintHandler { t.Helper() @@ -3630,11 +3714,14 @@ func TestBaseBlueprintHandler_getDevelopmentRepositoryURL(t *testing.T) { } }) - t.Run("ReturnsEmptyWhenDomainNotSet", func(t *testing.T) { + t.Run("UsesDefaultDomainWhenNotSet", func(t *testing.T) { handler := setup(t) mockConfigHandler := handler.configHandler.(*config.MockConfigHandler) mockConfigHandler.GetStringFunc = func(key string, defaultValue ...string) string { + if key == "dns.domain" && len(defaultValue) > 0 { + return defaultValue[0] + } return "" } @@ -3643,10 +3730,15 @@ func TestBaseBlueprintHandler_getDevelopmentRepositoryURL(t *testing.T) { return "/home/user/projects/my-project", nil } + handler.shims.FilepathBase = func(path string) string { + return "my-project" + } + url := handler.getDevelopmentRepositoryURL() - if url != "" { - t.Errorf("Expected empty URL when domain not set, got %s", url) + expectedURL := "http://git.test/git/my-project" + if url != expectedURL { + t.Errorf("Expected URL to be %s, got %s", expectedURL, url) } }) diff --git a/pkg/blueprint/blueprint_handler_public_test.go b/pkg/blueprint/blueprint_handler_public_test.go index 9784d878f..76deb85dc 100644 --- a/pkg/blueprint/blueprint_handler_public_test.go +++ b/pkg/blueprint/blueprint_handler_public_test.go @@ -913,6 +913,72 @@ func TestBlueprintHandler_LoadConfig(t *testing.T) { t.Errorf("expected normalized path, got %q", ks[0].Path) } }) + + t.Run("SetsRepositoryDefaultsInDevMode", func(t *testing.T) { + handler, mocks := setup(t) + + mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) + mockConfigHandler.GetBoolFunc = func(key string, defaultValue ...bool) bool { + if key == "dev" { + return true + } + return false + } + mockConfigHandler.GetStringFunc = func(key string, defaultValue ...string) string { + if key == "dns.domain" && len(defaultValue) > 0 { + return defaultValue[0] + } + return "" + } + + mocks.Shell.GetProjectRootFunc = func() (string, error) { + return "/Users/test/project/cli", nil + } + + handler.shims.FilepathBase = func(path string) string { + if path == "/Users/test/project/cli" { + return "cli" + } + return "" + } + + handler.shims.Stat = func(name string) (os.FileInfo, error) { + if strings.HasSuffix(name, ".yaml") { + return nil, nil + } + return nil, os.ErrNotExist + } + + blueprintWithoutURL := `kind: Blueprint +apiVersion: v1alpha1 +metadata: + name: test-blueprint + description: A test blueprint +repository: + ref: + branch: main +sources: [] +terraform: [] +kustomize: []` + + handler.shims.ReadFile = func(name string) ([]byte, error) { + if strings.HasSuffix(name, ".yaml") { + return []byte(blueprintWithoutURL), nil + } + return nil, os.ErrNotExist + } + + err := handler.LoadConfig() + + if err != nil { + t.Fatalf("Expected no error, got %v", err) + } + + expectedURL := "http://git.test/git/cli" + if handler.blueprint.Repository.Url != expectedURL { + t.Errorf("Expected repository URL to be %s, got %s", expectedURL, handler.blueprint.Repository.Url) + } + }) } func TestBlueprintHandler_Install(t *testing.T) { From 699437caa21695fed48917ff203adf25a396c022 Mon Sep 17 00:00:00 2001 From: Ryan VanGundy Date: Mon, 13 Oct 2025 10:32:02 -0400 Subject: [PATCH 2/4] Properly check dev mode --- pkg/blueprint/blueprint_handler.go | 7 +- .../blueprint_handler_private_test.go | 208 ++++++++++++++++++ 2 files changed, 214 insertions(+), 1 deletion(-) diff --git a/pkg/blueprint/blueprint_handler.go b/pkg/blueprint/blueprint_handler.go index d300638e4..986967535 100644 --- a/pkg/blueprint/blueprint_handler.go +++ b/pkg/blueprint/blueprint_handler.go @@ -1839,7 +1839,12 @@ func (b *BaseBlueprintHandler) setRepositoryDefaults() error { return nil } - if b.configHandler.GetBool("dev") { + devMode := b.configHandler.GetBool("dev") + if !devMode { + devMode = b.checkDevModeInValuesYaml() + } + + if devMode { url := b.getDevelopmentRepositoryURL() if url != "" { b.blueprint.Repository.Url = url diff --git a/pkg/blueprint/blueprint_handler_private_test.go b/pkg/blueprint/blueprint_handler_private_test.go index 77deea1a2..2f1ba4aa0 100644 --- a/pkg/blueprint/blueprint_handler_private_test.go +++ b/pkg/blueprint/blueprint_handler_private_test.go @@ -3616,6 +3616,66 @@ func TestBaseBlueprintHandler_setRepositoryDefaults(t *testing.T) { t.Errorf("Expected URL to be %s, got %s", expectedURL, handler.blueprint.Repository.Url) } }) + + t.Run("UsesDevelopmentURLWhenDevInValuesYaml", func(t *testing.T) { + handler := setup(t) + + mockConfigHandler := handler.configHandler.(*config.MockConfigHandler) + mockConfigHandler.GetBoolFunc = func(key string, defaultValue ...bool) bool { + return false + } + mockConfigHandler.GetStringFunc = func(key string, defaultValue ...string) string { + if key == "dns.domain" && len(defaultValue) > 0 { + return defaultValue[0] + } + return "" + } + mockConfigHandler.GetConfigRootFunc = func() (string, error) { + return "/test/contexts/local", nil + } + + mockShell := handler.shell.(*shell.MockShell) + mockShell.GetProjectRootFunc = func() (string, error) { + return "/test/project/core", nil + } + + handler.shims.FilepathBase = func(path string) string { + if path == "/test/project/core" { + return "core" + } + return "" + } + + handler.shims.ReadFile = func(name string) ([]byte, error) { + if name == "/test/contexts/local/values.yaml" { + return []byte("dev: true\n"), nil + } + return nil, fmt.Errorf("file not found") + } + + handler.shims.YamlUnmarshal = func(data []byte, v interface{}) error { + if string(data) == "dev: true\n" { + if m, ok := v.(*map[string]any); ok { + if *m == nil { + *m = make(map[string]any) + } + (*m)["dev"] = true + return nil + } + } + return fmt.Errorf("unexpected data") + } + + err := handler.setRepositoryDefaults() + + if err != nil { + t.Fatalf("Expected no error, got %v", err) + } + expectedURL := "http://git.test/git/core" + if handler.blueprint.Repository.Url != expectedURL { + t.Errorf("Expected URL to be %s, got %s", expectedURL, handler.blueprint.Repository.Url) + } + }) } func TestBaseBlueprintHandler_normalizeGitURL(t *testing.T) { @@ -3675,6 +3735,154 @@ func TestBaseBlueprintHandler_normalizeGitURL(t *testing.T) { }) } +func TestBaseBlueprintHandler_checkDevModeInValuesYaml(t *testing.T) { + setup := func(t *testing.T) *BaseBlueprintHandler { + t.Helper() + mocks := setupMocks(t) + handler := NewBlueprintHandler(mocks.Injector) + handler.shims = mocks.Shims + handler.configHandler = mocks.ConfigHandler + return handler + } + + t.Run("ReturnsTrueWhenDevTrueInValuesYaml", func(t *testing.T) { + handler := setup(t) + + mockConfigHandler := handler.configHandler.(*config.MockConfigHandler) + mockConfigHandler.GetConfigRootFunc = func() (string, error) { + return "/test/contexts/local", nil + } + + handler.shims.ReadFile = func(name string) ([]byte, error) { + if name == "/test/contexts/local/values.yaml" { + return []byte("dev: true\n"), nil + } + return nil, fmt.Errorf("file not found") + } + + handler.shims.YamlUnmarshal = func(data []byte, v interface{}) error { + if string(data) == "dev: true\n" { + if m, ok := v.(*map[string]any); ok { + if *m == nil { + *m = make(map[string]any) + } + (*m)["dev"] = true + return nil + } + } + return fmt.Errorf("unexpected data") + } + + result := handler.checkDevModeInValuesYaml() + + if !result { + t.Errorf("Expected true, got false") + } + }) + + t.Run("ReturnsFalseWhenDevFalseInValuesYaml", func(t *testing.T) { + handler := setup(t) + + mockConfigHandler := handler.configHandler.(*config.MockConfigHandler) + mockConfigHandler.GetConfigRootFunc = func() (string, error) { + return "/test/contexts/local", nil + } + + handler.shims.ReadFile = func(name string) ([]byte, error) { + if name == "/test/contexts/local/values.yaml" { + return []byte("dev: false\n"), nil + } + return nil, fmt.Errorf("file not found") + } + + handler.shims.YamlUnmarshal = func(data []byte, v interface{}) error { + if string(data) == "dev: false\n" { + if m, ok := v.(*map[string]any); ok { + if *m == nil { + *m = make(map[string]any) + } + (*m)["dev"] = false + return nil + } + } + return fmt.Errorf("unexpected data") + } + + result := handler.checkDevModeInValuesYaml() + + if result { + t.Errorf("Expected false, got true") + } + }) + + t.Run("ReturnsFalseWhenValuesYamlNotFound", func(t *testing.T) { + handler := setup(t) + + mockConfigHandler := handler.configHandler.(*config.MockConfigHandler) + mockConfigHandler.GetConfigRootFunc = func() (string, error) { + return "/test/contexts/local", nil + } + + handler.shims.ReadFile = func(name string) ([]byte, error) { + return nil, fmt.Errorf("file not found") + } + + result := handler.checkDevModeInValuesYaml() + + if result { + t.Errorf("Expected false when file not found, got true") + } + }) + + t.Run("ReturnsFalseWhenDevNotInValuesYaml", func(t *testing.T) { + handler := setup(t) + + mockConfigHandler := handler.configHandler.(*config.MockConfigHandler) + mockConfigHandler.GetConfigRootFunc = func() (string, error) { + return "/test/contexts/local", nil + } + + handler.shims.ReadFile = func(name string) ([]byte, error) { + if name == "/test/contexts/local/values.yaml" { + return []byte("other_key: value\n"), nil + } + return nil, fmt.Errorf("file not found") + } + + handler.shims.YamlUnmarshal = func(data []byte, v interface{}) error { + if m, ok := v.(*map[string]any); ok { + if *m == nil { + *m = make(map[string]any) + } + (*m)["other_key"] = "value" + return nil + } + return fmt.Errorf("unexpected data") + } + + result := handler.checkDevModeInValuesYaml() + + if result { + t.Errorf("Expected false when dev key not present, got true") + } + }) + + t.Run("ReturnsFalseWhenGetConfigRootFails", func(t *testing.T) { + handler := setup(t) + + mockConfigHandler := handler.configHandler.(*config.MockConfigHandler) + mockConfigHandler.GetConfigRootFunc = func() (string, error) { + return "", fmt.Errorf("config root error") + } + + result := handler.checkDevModeInValuesYaml() + + if result { + t.Errorf("Expected false when GetConfigRoot fails, got true") + } + }) +} + func TestBaseBlueprintHandler_getDevelopmentRepositoryURL(t *testing.T) { setup := func(t *testing.T) *BaseBlueprintHandler { t.Helper() From 4f3c1e5935ef1dd3214b75364d9337d07440b5df Mon Sep 17 00:00:00 2001 From: Ryan VanGundy Date: Wed, 15 Oct 2025 08:46:44 -0400 Subject: [PATCH 3/4] Don't check values.yaml for dev mode --- pkg/blueprint/blueprint_handler.go | 3 - .../blueprint_handler_private_test.go | 207 ------------------ 2 files changed, 210 deletions(-) diff --git a/pkg/blueprint/blueprint_handler.go b/pkg/blueprint/blueprint_handler.go index 986967535..71cdc39b3 100644 --- a/pkg/blueprint/blueprint_handler.go +++ b/pkg/blueprint/blueprint_handler.go @@ -1840,9 +1840,6 @@ func (b *BaseBlueprintHandler) setRepositoryDefaults() error { } devMode := b.configHandler.GetBool("dev") - if !devMode { - devMode = b.checkDevModeInValuesYaml() - } if devMode { url := b.getDevelopmentRepositoryURL() diff --git a/pkg/blueprint/blueprint_handler_private_test.go b/pkg/blueprint/blueprint_handler_private_test.go index 2f1ba4aa0..d17165be2 100644 --- a/pkg/blueprint/blueprint_handler_private_test.go +++ b/pkg/blueprint/blueprint_handler_private_test.go @@ -3617,65 +3617,6 @@ func TestBaseBlueprintHandler_setRepositoryDefaults(t *testing.T) { } }) - t.Run("UsesDevelopmentURLWhenDevInValuesYaml", func(t *testing.T) { - handler := setup(t) - - mockConfigHandler := handler.configHandler.(*config.MockConfigHandler) - mockConfigHandler.GetBoolFunc = func(key string, defaultValue ...bool) bool { - return false - } - mockConfigHandler.GetStringFunc = func(key string, defaultValue ...string) string { - if key == "dns.domain" && len(defaultValue) > 0 { - return defaultValue[0] - } - return "" - } - mockConfigHandler.GetConfigRootFunc = func() (string, error) { - return "/test/contexts/local", nil - } - - mockShell := handler.shell.(*shell.MockShell) - mockShell.GetProjectRootFunc = func() (string, error) { - return "/test/project/core", nil - } - - handler.shims.FilepathBase = func(path string) string { - if path == "/test/project/core" { - return "core" - } - return "" - } - - handler.shims.ReadFile = func(name string) ([]byte, error) { - if name == "/test/contexts/local/values.yaml" { - return []byte("dev: true\n"), nil - } - return nil, fmt.Errorf("file not found") - } - - handler.shims.YamlUnmarshal = func(data []byte, v interface{}) error { - if string(data) == "dev: true\n" { - if m, ok := v.(*map[string]any); ok { - if *m == nil { - *m = make(map[string]any) - } - (*m)["dev"] = true - return nil - } - } - return fmt.Errorf("unexpected data") - } - - err := handler.setRepositoryDefaults() - - if err != nil { - t.Fatalf("Expected no error, got %v", err) - } - expectedURL := "http://git.test/git/core" - if handler.blueprint.Repository.Url != expectedURL { - t.Errorf("Expected URL to be %s, got %s", expectedURL, handler.blueprint.Repository.Url) - } - }) } func TestBaseBlueprintHandler_normalizeGitURL(t *testing.T) { @@ -3735,154 +3676,6 @@ func TestBaseBlueprintHandler_normalizeGitURL(t *testing.T) { }) } -func TestBaseBlueprintHandler_checkDevModeInValuesYaml(t *testing.T) { - setup := func(t *testing.T) *BaseBlueprintHandler { - t.Helper() - mocks := setupMocks(t) - handler := NewBlueprintHandler(mocks.Injector) - handler.shims = mocks.Shims - handler.configHandler = mocks.ConfigHandler - return handler - } - - t.Run("ReturnsTrueWhenDevTrueInValuesYaml", func(t *testing.T) { - handler := setup(t) - - mockConfigHandler := handler.configHandler.(*config.MockConfigHandler) - mockConfigHandler.GetConfigRootFunc = func() (string, error) { - return "/test/contexts/local", nil - } - - handler.shims.ReadFile = func(name string) ([]byte, error) { - if name == "/test/contexts/local/values.yaml" { - return []byte("dev: true\n"), nil - } - return nil, fmt.Errorf("file not found") - } - - handler.shims.YamlUnmarshal = func(data []byte, v interface{}) error { - if string(data) == "dev: true\n" { - if m, ok := v.(*map[string]any); ok { - if *m == nil { - *m = make(map[string]any) - } - (*m)["dev"] = true - return nil - } - } - return fmt.Errorf("unexpected data") - } - - result := handler.checkDevModeInValuesYaml() - - if !result { - t.Errorf("Expected true, got false") - } - }) - - t.Run("ReturnsFalseWhenDevFalseInValuesYaml", func(t *testing.T) { - handler := setup(t) - - mockConfigHandler := handler.configHandler.(*config.MockConfigHandler) - mockConfigHandler.GetConfigRootFunc = func() (string, error) { - return "/test/contexts/local", nil - } - - handler.shims.ReadFile = func(name string) ([]byte, error) { - if name == "/test/contexts/local/values.yaml" { - return []byte("dev: false\n"), nil - } - return nil, fmt.Errorf("file not found") - } - - handler.shims.YamlUnmarshal = func(data []byte, v interface{}) error { - if string(data) == "dev: false\n" { - if m, ok := v.(*map[string]any); ok { - if *m == nil { - *m = make(map[string]any) - } - (*m)["dev"] = false - return nil - } - } - return fmt.Errorf("unexpected data") - } - - result := handler.checkDevModeInValuesYaml() - - if result { - t.Errorf("Expected false, got true") - } - }) - - t.Run("ReturnsFalseWhenValuesYamlNotFound", func(t *testing.T) { - handler := setup(t) - - mockConfigHandler := handler.configHandler.(*config.MockConfigHandler) - mockConfigHandler.GetConfigRootFunc = func() (string, error) { - return "/test/contexts/local", nil - } - - handler.shims.ReadFile = func(name string) ([]byte, error) { - return nil, fmt.Errorf("file not found") - } - - result := handler.checkDevModeInValuesYaml() - - if result { - t.Errorf("Expected false when file not found, got true") - } - }) - - t.Run("ReturnsFalseWhenDevNotInValuesYaml", func(t *testing.T) { - handler := setup(t) - - mockConfigHandler := handler.configHandler.(*config.MockConfigHandler) - mockConfigHandler.GetConfigRootFunc = func() (string, error) { - return "/test/contexts/local", nil - } - - handler.shims.ReadFile = func(name string) ([]byte, error) { - if name == "/test/contexts/local/values.yaml" { - return []byte("other_key: value\n"), nil - } - return nil, fmt.Errorf("file not found") - } - - handler.shims.YamlUnmarshal = func(data []byte, v interface{}) error { - if m, ok := v.(*map[string]any); ok { - if *m == nil { - *m = make(map[string]any) - } - (*m)["other_key"] = "value" - return nil - } - return fmt.Errorf("unexpected data") - } - - result := handler.checkDevModeInValuesYaml() - - if result { - t.Errorf("Expected false when dev key not present, got true") - } - }) - - t.Run("ReturnsFalseWhenGetConfigRootFails", func(t *testing.T) { - handler := setup(t) - - mockConfigHandler := handler.configHandler.(*config.MockConfigHandler) - mockConfigHandler.GetConfigRootFunc = func() (string, error) { - return "", fmt.Errorf("config root error") - } - - result := handler.checkDevModeInValuesYaml() - - if result { - t.Errorf("Expected false when GetConfigRoot fails, got true") - } - }) -} - func TestBaseBlueprintHandler_getDevelopmentRepositoryURL(t *testing.T) { setup := func(t *testing.T) *BaseBlueprintHandler { t.Helper() From b8bee58ca6438159c48b36b30d66614a8e85fdf3 Mon Sep 17 00:00:00 2001 From: Ryan VanGundy Date: Wed, 15 Oct 2025 09:24:43 -0400 Subject: [PATCH 4/4] Don't load repository defaults early --- pkg/blueprint/blueprint_handler.go | 4 ---- pkg/blueprint/blueprint_handler_public_test.go | 9 +++++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/blueprint/blueprint_handler.go b/pkg/blueprint/blueprint_handler.go index 71cdc39b3..55edd732f 100644 --- a/pkg/blueprint/blueprint_handler.go +++ b/pkg/blueprint/blueprint_handler.go @@ -173,10 +173,6 @@ func (b *BaseBlueprintHandler) LoadData(data map[string]any, ociInfo ...*artifac return err } - if err := b.setRepositoryDefaults(); err != nil { - return fmt.Errorf("error setting repository defaults: %w", err) - } - return nil } diff --git a/pkg/blueprint/blueprint_handler_public_test.go b/pkg/blueprint/blueprint_handler_public_test.go index 76deb85dc..e4674d133 100644 --- a/pkg/blueprint/blueprint_handler_public_test.go +++ b/pkg/blueprint/blueprint_handler_public_test.go @@ -930,6 +930,15 @@ func TestBlueprintHandler_LoadConfig(t *testing.T) { } return "" } + mockConfigHandler.GetBoolFunc = func(key string, defaultValue ...bool) bool { + if key == "dev" { + return true + } + return false + } + mockConfigHandler.GetConfigRootFunc = func() (string, error) { + return "/tmp/test-config", nil + } mocks.Shell.GetProjectRootFunc = func() (string, error) { return "/Users/test/project/cli", nil