Skip to content

Commit

Permalink
Add functions to check if distros are enabled
Browse files Browse the repository at this point in the history
Signed-off-by: Mauro Morales <[email protected]>
  • Loading branch information
mauromorales committed Jan 14, 2025
1 parent a144b7a commit e8bfaaa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/provider/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func oneTimeBootstrap(l types.KairosLogger, c *providerConfig.Config, vpnSetupFN
var svcName, svcRole, envFile, binPath string

// Determine the service type (K3s or K0s) and set appropriate variables
if c.K3s.Enabled || c.K3sAgent.Enabled {
if c.IsK3sDistributionEnabled() {
k3sConfig := c.K3s
if c.K3sAgent.Enabled {
k3sConfig = c.K3sAgent
Expand Down Expand Up @@ -213,7 +213,7 @@ func oneTimeBootstrap(l types.KairosLogger, c *providerConfig.Config, vpnSetupFN
return err
}
} else {
l.Info("No K3s or K0s configuration found, skipping bootstrap.")
l.Info("No Kubernetes configuration found, skipping bootstrap.")
return nil
}

Expand Down
8 changes: 8 additions & 0 deletions internal/provider/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ func (c Config) IsK3sEnabled() bool {
return c.K3s.IsEnabled()
}

func (c Config) IsK3sDistributionEnabled() bool {
return c.IsK3sAgentEnabled() || c.IsK3sEnabled()
}

func (c Config) IsK0sEnabled() bool {
return c.K0s.IsEnabled()
}
Expand All @@ -57,6 +61,10 @@ func (c Config) IsK0sWorkerEnabled() bool {
return c.K0sWorker.IsEnabled()
}

func (c Config) IsK0sDistributionEnabled() bool {
return c.IsK0sEnabled() || c.IsK0sWorkerEnabled()
}

func (c Config) IsAKubernetesDistributionEnabled() bool {
return c.IsK3sAgentEnabled() || c.IsK3sEnabled() || c.IsK0sEnabled() || c.IsK0sWorkerEnabled()
}
Expand Down

0 comments on commit e8bfaaa

Please sign in to comment.