clusterprovisioner

package
v1.11.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

README

pkg/provisioner/cluster

This package provides core cluster provisioning implementations for KSail.

Purpose

Implements the ClusterProvisioner interface for managing Kubernetes clusters across different distributions. This package contains the core logic for cluster lifecycle operations including creation, deletion, starting, stopping, and listing clusters.

Interface

type ClusterProvisioner interface {
    // Create creates a Kubernetes cluster
    Create(ctx context.Context, name string) error
    
    // Delete deletes a Kubernetes cluster by name
    Delete(ctx context.Context, name string) error
    
    // Start starts a Kubernetes cluster by name
    Start(ctx context.Context, name string) error
    
    // Stop stops a Kubernetes cluster by name
    Stop(ctx context.Context, name string) error
    
    // List lists all Kubernetes clusters
    List(ctx context.Context) ([]string, error)
    
    // Exists checks if a Kubernetes cluster exists by name
    Exists(ctx context.Context, name string) (bool, error)
}

Features

  • Context Support: All operations support context for cancellation and timeouts
  • Multi-Distribution: Support for different Kubernetes distributions
  • Lifecycle Management: Complete cluster lifecycle operations
  • Name-based Operations: Cluster identification by name

Subpackages

Usage

import "github.com/devantler-tech/ksail-go/pkg/provisioner/cluster"

// Use specific cluster provisioner
var provisioner ClusterProvisioner = // ... get specific implementation

ctx := context.Background()

// Create a cluster
if err := provisioner.Create(ctx, "my-cluster"); err != nil {
    log.Fatal("Failed to create cluster:", err)
}

// List clusters
clusters, err := provisioner.List(ctx)
if err != nil {
    log.Fatal("Failed to list clusters:", err)
}

⬅️ Go Back

Documentation

Overview

Package clusterprovisioner provides implementations of the Provisioner interface for provisioning clusters in different providers.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedDistribution = errors.New("unsupported distribution")

ErrUnsupportedDistribution is returned when an unsupported distribution is specified.

Functions

This section is empty.

Types

type ClusterProvisioner

type ClusterProvisioner interface {
	// Create creates a Kubernetes cluster. If name is non-empty, target that name; otherwise use config defaults.
	Create(ctx context.Context, name string) error

	// Delete deletes a Kubernetes cluster by name or config default when name is empty.
	Delete(ctx context.Context, name string) error

	// Start starts a Kubernetes cluster by name or config default when name is empty.
	Start(ctx context.Context, name string) error

	// Stop stops a Kubernetes cluster by name or config default when name is empty.
	Stop(ctx context.Context, name string) error

	// List lists all Kubernetes clusters.
	List(ctx context.Context) ([]string, error)

	// Exists checks if a Kubernetes cluster exists by name or config default when name is empty.
	Exists(ctx context.Context, name string) (bool, error)
}

ClusterProvisioner defines methods for managing Kubernetes clusters.

type DefaultFactory

type DefaultFactory struct{}

DefaultFactory implements Factory using the existing CreateClusterProvisioner helper.

func (DefaultFactory) Create

Create selects the correct distribution provisioner for the KSail cluster configuration.

type Factory

type Factory interface {
	Create(ctx context.Context, cluster *v1alpha1.Cluster) (ClusterProvisioner, any, error)
}

Factory creates distribution-specific cluster provisioners based on the KSail cluster configuration.

type MockClusterProvisioner

type MockClusterProvisioner struct {
	mock.Mock
}

MockClusterProvisioner is an autogenerated mock type for the ClusterProvisioner type

func NewMockClusterProvisioner

func NewMockClusterProvisioner(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockClusterProvisioner

NewMockClusterProvisioner creates a new instance of MockClusterProvisioner. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockClusterProvisioner) Create

func (_mock *MockClusterProvisioner) Create(ctx context.Context, name string) error

Create provides a mock function for the type MockClusterProvisioner

func (*MockClusterProvisioner) Delete

func (_mock *MockClusterProvisioner) Delete(ctx context.Context, name string) error

Delete provides a mock function for the type MockClusterProvisioner

func (*MockClusterProvisioner) EXPECT

func (*MockClusterProvisioner) Exists

func (_mock *MockClusterProvisioner) Exists(ctx context.Context, name string) (bool, error)

Exists provides a mock function for the type MockClusterProvisioner

func (*MockClusterProvisioner) List

func (_mock *MockClusterProvisioner) List(ctx context.Context) ([]string, error)

List provides a mock function for the type MockClusterProvisioner

func (*MockClusterProvisioner) Start

func (_mock *MockClusterProvisioner) Start(ctx context.Context, name string) error

Start provides a mock function for the type MockClusterProvisioner

func (*MockClusterProvisioner) Stop

func (_mock *MockClusterProvisioner) Stop(ctx context.Context, name string) error

Stop provides a mock function for the type MockClusterProvisioner

type MockClusterProvisioner_Create_Call

type MockClusterProvisioner_Create_Call struct {
	*mock.Call
}

MockClusterProvisioner_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create'

func (*MockClusterProvisioner_Create_Call) Return

func (*MockClusterProvisioner_Create_Call) Run

func (*MockClusterProvisioner_Create_Call) RunAndReturn

type MockClusterProvisioner_Delete_Call

type MockClusterProvisioner_Delete_Call struct {
	*mock.Call
}

MockClusterProvisioner_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete'

func (*MockClusterProvisioner_Delete_Call) Return

func (*MockClusterProvisioner_Delete_Call) Run

func (*MockClusterProvisioner_Delete_Call) RunAndReturn

type MockClusterProvisioner_Exists_Call

type MockClusterProvisioner_Exists_Call struct {
	*mock.Call
}

MockClusterProvisioner_Exists_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Exists'

func (*MockClusterProvisioner_Exists_Call) Return

func (*MockClusterProvisioner_Exists_Call) Run

func (*MockClusterProvisioner_Exists_Call) RunAndReturn

type MockClusterProvisioner_Expecter

type MockClusterProvisioner_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockClusterProvisioner_Expecter) Create

func (_e *MockClusterProvisioner_Expecter) Create(ctx interface{}, name interface{}) *MockClusterProvisioner_Create_Call

Create is a helper method to define mock.On call

  • ctx context.Context
  • name string

func (*MockClusterProvisioner_Expecter) Delete

func (_e *MockClusterProvisioner_Expecter) Delete(ctx interface{}, name interface{}) *MockClusterProvisioner_Delete_Call

Delete is a helper method to define mock.On call

  • ctx context.Context
  • name string

func (*MockClusterProvisioner_Expecter) Exists

func (_e *MockClusterProvisioner_Expecter) Exists(ctx interface{}, name interface{}) *MockClusterProvisioner_Exists_Call

Exists is a helper method to define mock.On call

  • ctx context.Context
  • name string

func (*MockClusterProvisioner_Expecter) List

List is a helper method to define mock.On call

  • ctx context.Context

func (*MockClusterProvisioner_Expecter) Start

func (_e *MockClusterProvisioner_Expecter) Start(ctx interface{}, name interface{}) *MockClusterProvisioner_Start_Call

Start is a helper method to define mock.On call

  • ctx context.Context
  • name string

func (*MockClusterProvisioner_Expecter) Stop

func (_e *MockClusterProvisioner_Expecter) Stop(ctx interface{}, name interface{}) *MockClusterProvisioner_Stop_Call

Stop is a helper method to define mock.On call

  • ctx context.Context
  • name string

type MockClusterProvisioner_List_Call

type MockClusterProvisioner_List_Call struct {
	*mock.Call
}

MockClusterProvisioner_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List'

func (*MockClusterProvisioner_List_Call) Return

func (*MockClusterProvisioner_List_Call) Run

func (*MockClusterProvisioner_List_Call) RunAndReturn

type MockClusterProvisioner_Start_Call

type MockClusterProvisioner_Start_Call struct {
	*mock.Call
}

MockClusterProvisioner_Start_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Start'

func (*MockClusterProvisioner_Start_Call) Return

func (*MockClusterProvisioner_Start_Call) Run

func (*MockClusterProvisioner_Start_Call) RunAndReturn

type MockClusterProvisioner_Stop_Call

type MockClusterProvisioner_Stop_Call struct {
	*mock.Call
}

MockClusterProvisioner_Stop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Stop'

func (*MockClusterProvisioner_Stop_Call) Return

func (*MockClusterProvisioner_Stop_Call) Run

func (*MockClusterProvisioner_Stop_Call) RunAndReturn

type MockFactory

type MockFactory struct {
	mock.Mock
}

MockFactory is an autogenerated mock type for the Factory type

func NewMockFactory

func NewMockFactory(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockFactory

NewMockFactory creates a new instance of MockFactory. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockFactory) Create

func (_mock *MockFactory) Create(ctx context.Context, cluster *v1alpha1.Cluster) (ClusterProvisioner, any, error)

Create provides a mock function for the type MockFactory

func (*MockFactory) EXPECT

func (_m *MockFactory) EXPECT() *MockFactory_Expecter

type MockFactory_Create_Call

type MockFactory_Create_Call struct {
	*mock.Call
}

MockFactory_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create'

func (*MockFactory_Create_Call) Return

func (_c *MockFactory_Create_Call) Return(clusterProvisioner ClusterProvisioner, v any, err error) *MockFactory_Create_Call

func (*MockFactory_Create_Call) Run

func (*MockFactory_Create_Call) RunAndReturn

type MockFactory_Expecter

type MockFactory_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockFactory_Expecter) Create

func (_e *MockFactory_Expecter) Create(ctx interface{}, cluster interface{}) *MockFactory_Create_Call

Create is a helper method to define mock.On call

  • ctx context.Context
  • cluster *v1alpha1.Cluster

Directories

Path Synopsis
Package k3dprovisioner contains the K3d cluster provisioner and its client provider interfaces.
Package k3dprovisioner contains the K3d cluster provisioner and its client provider interfaces.
Package kindprovisioner provides implementations of the Provisioner interface for provisioning clusters in different providers.
Package kindprovisioner provides implementations of the Provisioner interface for provisioning clusters in different providers.
Package clustertestutils provides common test utilities for cluster provisioner testing, including shared test cases and helper functions for standardizing test patterns.
Package clustertestutils provides common test utilities for cluster provisioner testing, including shared test cases and helper functions for standardizing test patterns.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL