From 15eb5f4f9f37ac6a86b08df578335f94bec876f7 Mon Sep 17 00:00:00 2001 From: Ryan VanGundy Date: Tue, 15 Jul 2025 09:30:54 -0400 Subject: [PATCH 1/2] fix(blueprint): Always use "full" default blueprints --- pkg/blueprint/templates/aws.jsonnet | 7 ++----- pkg/blueprint/templates/azure.jsonnet | 7 ++----- pkg/blueprint/templates/local.jsonnet | 7 ++----- pkg/blueprint/templates/metal.jsonnet | 7 ++----- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/pkg/blueprint/templates/aws.jsonnet b/pkg/blueprint/templates/aws.jsonnet index 2f4deca3f..1a8bdb590 100644 --- a/pkg/blueprint/templates/aws.jsonnet +++ b/pkg/blueprint/templates/aws.jsonnet @@ -31,11 +31,8 @@ local terraformConfig = [ } ]; -// Determine the blueprint, defaulting to an empty string if not defined -local blueprint = if std.objectHas(context, "blueprint") then context.blueprint else ""; - // Kustomize configuration -local kustomizeConfig = if blueprint == "full" then [ +local kustomizeConfig = [ { name: "telemetry-base", source: "core", @@ -151,7 +148,7 @@ local kustomizeConfig = if blueprint == "full" then [ "grafana/flux" ], } -] else []; +]; // Blueprint metadata local blueprintMetadata = { diff --git a/pkg/blueprint/templates/azure.jsonnet b/pkg/blueprint/templates/azure.jsonnet index 8f2e01759..def834a3f 100644 --- a/pkg/blueprint/templates/azure.jsonnet +++ b/pkg/blueprint/templates/azure.jsonnet @@ -26,11 +26,8 @@ local terraformConfig = [ } ]; -// Determine the blueprint, defaulting to an empty string if not defined -local blueprint = if std.objectHas(context, "blueprint") then context.blueprint else ""; - // Kustomize configuration -local kustomizeConfig = if blueprint == "full" then [ +local kustomizeConfig = [ { name: "telemetry-base", source: "core", @@ -149,7 +146,7 @@ local kustomizeConfig = if blueprint == "full" then [ "grafana/flux" ], } -] else []; +]; // Blueprint metadata local blueprintMetadata = { diff --git a/pkg/blueprint/templates/local.jsonnet b/pkg/blueprint/templates/local.jsonnet index a88f67a5f..fac54ccc4 100644 --- a/pkg/blueprint/templates/local.jsonnet +++ b/pkg/blueprint/templates/local.jsonnet @@ -198,11 +198,8 @@ local terraformConfig = [ } ]; -// Determine the blueprint, defaulting to an empty string if not defined -local blueprint = if std.objectHas(context, "blueprint") then context.blueprint else ""; - // Kustomize configuration -local kustomizeConfig = if blueprint == "full" then [ +local kustomizeConfig = [ { name: "telemetry-base", source: "core", @@ -379,7 +376,7 @@ local kustomizeConfig = if blueprint == "full" then [ "grafana/flux" ], } -] else []; +]; // Blueprint metadata local blueprintMetadata = { diff --git a/pkg/blueprint/templates/metal.jsonnet b/pkg/blueprint/templates/metal.jsonnet index c4fda6643..421a0a63b 100644 --- a/pkg/blueprint/templates/metal.jsonnet +++ b/pkg/blueprint/templates/metal.jsonnet @@ -180,11 +180,8 @@ local terraformConfig = [ } ]; -// Determine the blueprint, defaulting to an empty string if not defined -local blueprint = if std.objectHas(context, "blueprint") then context.blueprint else ""; - // Kustomize configuration -local kustomizeConfig = if blueprint == "full" then [ +local kustomizeConfig = [ { name: "telemetry-base", source: "core", @@ -346,7 +343,7 @@ local kustomizeConfig = if blueprint == "full" then [ "grafana/flux" ], } -] else []; +]; // Blueprint metadata local blueprintMetadata = { From 91ceb8958cbe554cece3536532f06245065e9246 Mon Sep 17 00:00:00 2001 From: Ryan VanGundy Date: Tue, 15 Jul 2025 09:35:47 -0400 Subject: [PATCH 2/2] Load blueprint config before install --- pkg/pipelines/install.go | 4 ++ pkg/pipelines/install_test.go | 70 +++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/pkg/pipelines/install.go b/pkg/pipelines/install.go index e09d384a3..b28a6facd 100644 --- a/pkg/pipelines/install.go +++ b/pkg/pipelines/install.go @@ -84,6 +84,10 @@ func (p *InstallPipeline) Execute(ctx context.Context) error { return fmt.Errorf("No blueprint handler found") } + if err := p.blueprintHandler.LoadConfig(); err != nil { + return fmt.Errorf("Error loading blueprint config: %w", err) + } + if err := p.blueprintHandler.Install(); err != nil { return fmt.Errorf("Error installing blueprint: %w", err) } diff --git a/pkg/pipelines/install_test.go b/pkg/pipelines/install_test.go index 671e0cae9..da0b311fb 100644 --- a/pkg/pipelines/install_test.go +++ b/pkg/pipelines/install_test.go @@ -276,4 +276,74 @@ func TestInstallPipeline_Execute(t *testing.T) { t.Errorf("Expected blueprint wait error, got %q", err.Error()) } }) + + t.Run("LoadsBlueprintConfigBeforeInstall", func(t *testing.T) { + // Given a pipeline with blueprint handler + pipeline, mocks := setup(t) + + loadConfigCalled := false + installCalled := false + var callOrder []string + + // Track the order of method calls + mocks.BlueprintHandler.LoadConfigFunc = func() error { + loadConfigCalled = true + callOrder = append(callOrder, "LoadConfig") + return nil + } + + mocks.BlueprintHandler.InstallFunc = func() error { + installCalled = true + callOrder = append(callOrder, "Install") + return nil + } + + // When Execute is called + err := pipeline.Execute(context.Background()) + + // Then no error should be returned + if err != nil { + t.Errorf("Expected no error, got %v", err) + } + + // And LoadConfig should be called before Install + if !loadConfigCalled { + t.Error("Expected LoadConfig to be called") + } + if !installCalled { + t.Error("Expected Install to be called") + } + + // And LoadConfig should be called before Install + if len(callOrder) != 2 { + t.Errorf("Expected 2 method calls, got %d", len(callOrder)) + } + if callOrder[0] != "LoadConfig" { + t.Errorf("Expected LoadConfig to be called first, got %s", callOrder[0]) + } + if callOrder[1] != "Install" { + t.Errorf("Expected Install to be called second, got %s", callOrder[1]) + } + }) + + t.Run("ReturnsErrorWhenBlueprintLoadConfigFails", func(t *testing.T) { + // Given a pipeline with failing blueprint LoadConfig + pipeline, mocks := setup(t) + + // Override blueprint handler to return error during LoadConfig + mocks.BlueprintHandler.LoadConfigFunc = func() error { + return fmt.Errorf("blueprint load config failed") + } + + // When Execute is called + err := pipeline.Execute(context.Background()) + + // Then an error should be returned + if err == nil { + t.Fatal("Expected error, got nil") + } + if err.Error() != "Error loading blueprint config: blueprint load config failed" { + t.Errorf("Expected blueprint load config error, got %q", err.Error()) + } + }) }