Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/blueprint/blueprint_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ var defaultJsonnetTemplate string
//go:embed templates/local.jsonnet
var localJsonnetTemplate string

//go:embed templates/metal.jsonnet
var metalJsonnetTemplate string
//go:embed templates/talos.jsonnet
var talosJsonnetTemplate string

//go:embed templates/aws.jsonnet
var awsJsonnetTemplate string
Expand Down Expand Up @@ -863,8 +863,8 @@ func (b *BaseBlueprintHandler) loadPlatformTemplate(platform string) ([]byte, er
switch platform {
case "local":
return []byte(localJsonnetTemplate), nil
case "metal":
return []byte(metalJsonnetTemplate), nil
case "talos":
return []byte(talosJsonnetTemplate), nil
case "aws":
return []byte(awsJsonnetTemplate), nil
case "azure":
Expand Down
2 changes: 1 addition & 1 deletion pkg/blueprint/blueprint_handler_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func TestBaseBlueprintHandler_loadPlatformTemplate(t *testing.T) {
handler := &BaseBlueprintHandler{}

// When loading templates for valid platforms
platforms := []string{"local", "metal", "aws", "azure", "default"}
platforms := []string{"local", "talos", "aws", "azure", "default"}
for _, platform := range platforms {
// Then the template should be loaded successfully
template, err := handler.loadPlatformTemplate(platform)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ local repositoryConfig = {
};

// Terraform configuration
local terraformConfig = [
{
path: "cluster/talos",
source: "core",
values: {
local talosInfra = if context.provider != "omni" then [{
path: "cluster/talos",
source: "core",
parallelism: 1,
values: {
cluster_endpoint: if endpoint != "" then "https://" + baseUrl + ":6443" else "",
cluster_name: "talos",
controlplanes: if std.objectHas(context.cluster, "controlplanes") && std.objectHas(context.cluster.controlplanes, "nodes") then
Expand Down Expand Up @@ -172,13 +172,13 @@ local terraformConfig = [
else
"",
},
},
{
path: "gitops/flux",
source: "core",
destroy: false,
}
];
}] else [];

local terraformConfig = talosInfra + [{
path: "gitops/flux",
source: "core",
destroy: false,
}];

// Kustomize configuration
local kustomizeConfig = [
Expand Down
70 changes: 0 additions & 70 deletions pkg/env/omni_env.go

This file was deleted.

179 changes: 0 additions & 179 deletions pkg/env/omni_env_test.go

This file was deleted.

33 changes: 14 additions & 19 deletions pkg/env/talos_env.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// The TalosEnvPrinter is a specialized component that manages Talos environment configuration.
// It provides Talos-specific environment variable management and configuration,
// The TalosEnvPrinter handles Talos configuration settings and environment setup,
// ensuring proper Talos CLI integration and environment setup for operations.

package env

import (
Expand All @@ -16,7 +11,8 @@ import (
// Types
// =============================================================================

// TalosEnvPrinter is a struct that implements Talos environment configuration
// TalosEnvPrinter manages Talos environment configuration, providing Talos-specific
// environment variable management and configuration for CLI integration and environment setup.
type TalosEnvPrinter struct {
BaseEnvPrinter
}
Expand All @@ -25,7 +21,7 @@ type TalosEnvPrinter struct {
// Constructor
// =============================================================================

// NewTalosEnvPrinter creates a new TalosEnvPrinter instance
// NewTalosEnvPrinter creates and returns a new TalosEnvPrinter instance using the provided injector.
func NewTalosEnvPrinter(injector di.Injector) *TalosEnvPrinter {
return &TalosEnvPrinter{
BaseEnvPrinter: *NewBaseEnvPrinter(injector),
Expand All @@ -36,35 +32,34 @@ func NewTalosEnvPrinter(injector di.Injector) *TalosEnvPrinter {
// Public Methods
// =============================================================================

// GetEnvVars retrieves the environment variables for the Talos environment.
// GetEnvVars returns a map of environment variables for the Talos environment.
// It sets the TALOSCONFIG variable and, if the cluster driver is "omni", also sets OMNICONFIG.
// Returns an error if the configuration root cannot be determined.
func (e *TalosEnvPrinter) GetEnvVars() (map[string]string, error) {
envVars := make(map[string]string)

// Determine the root directory for configuration files.
configRoot, err := e.configHandler.GetConfigRoot()
if err != nil {
return nil, fmt.Errorf("error retrieving configuration root directory: %w", err)
}

// Construct the path to the talos config file and verify its existence.
talosConfigPath := filepath.Join(configRoot, ".talos", "config")

// Populate environment variables with Talos configuration data.
envVars["TALOSCONFIG"] = talosConfigPath

provider := e.configHandler.GetString("provider", "")
if provider == "omni" {
omniConfigPath := filepath.Join(configRoot, ".omni", "config")
envVars["OMNICONFIG"] = omniConfigPath
}
return envVars, nil
}

// Print prints the environment variables for the Talos environment.
// Print outputs the environment variables for the Talos environment using the embedded BaseEnvPrinter.
// Returns an error if environment variable retrieval fails or printing fails.
func (e *TalosEnvPrinter) Print() error {
envVars, err := e.GetEnvVars()
if err != nil {
// Return the error if GetEnvVars fails
return fmt.Errorf("error getting environment variables: %w", err)
}
// Call the Print method of the embedded BaseEnvPrinter struct with the retrieved environment variables
return e.BaseEnvPrinter.Print(envVars)
}

// Ensure TalosEnvPrinter implements the EnvPrinter interface
// TalosEnvPrinter implements the EnvPrinter interface.
var _ EnvPrinter = (*TalosEnvPrinter)(nil)
Loading
Loading