argocd

package
v5.28.9 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package argocd provides Argo CD GitOps integration for KSail-Go.

This package is responsible for creating and maintaining Argo CD resources required for local GitOps workflows (e.g., repository Secret and Application).

Implementations must remain credential-free: KSail-Go must not fetch or print Argo CD admin credentials.

Index

Constants

View Source
const (
	// DefaultNamespace is the default namespace for ArgoCD resources.
	DefaultNamespace = "argocd"
)

Reconciler constants.

Variables

View Source
var (
	// ErrReconcileTimeout is returned when reconciliation times out.
	ErrReconcileTimeout = errors.New("timeout waiting for argocd application sync")
	// ErrSourceNotAvailable is returned when the ArgoCD source is not available.
	ErrSourceNotAvailable = errors.New(
		"argocd source is not available - ensure you have pushed an artifact with 'ksail workload push'",
	)
	// ErrOperationFailed is returned when an ArgoCD operation fails.
	ErrOperationFailed = errors.New("argocd operation failed")
)

Reconciler errors.

Functions

This section is empty.

Types

type EnsureOptions

type EnsureOptions struct {
	// RepositoryURL is the Argo CD repository URL, typically an OCI repository.
	// Example: oci://local-registry:5000/<repository>
	RepositoryURL string

	// SourcePath is the path inside the repository to the kustomization root.
	// This is derived from the existing `spec.sourceDirectory` setting.
	//
	// If empty, defaults to "k8s".
	SourcePath string

	// ApplicationName is the Argo CD Application name.
	ApplicationName string

	// TargetRevision is the initial revision (tag or digest).
	TargetRevision string

	// Username for OCI registry authentication (optional, for external registries).
	Username string

	// Password for OCI registry authentication (optional, for external registries).
	Password string

	// Insecure allows HTTP connections (for local registries). Default is false.
	Insecure bool
}

EnsureOptions configures how KSail ensures Argo CD resources.

type Installer

type Installer interface {
	Install(ctx context.Context) error
}

Installer installs or ensures Argo CD is present in the cluster.

Implementations are expected to be idempotent.

type Manager

type Manager interface {
	Ensure(ctx context.Context, opts EnsureOptions) error
	UpdateTargetRevision(ctx context.Context, opts UpdateTargetRevisionOptions) error
}

Manager ensures Argo CD GitOps resources exist and can update reconciliation to a new OCI revision.

Implementations are expected to be idempotent.

type ManagerImpl

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

ManagerImpl implements the Argo CD GitOps manager.

func NewManager

func NewManager(clientset kubernetes.Interface, dyn dynamic.Interface) *ManagerImpl

NewManager creates a manager using provided Kubernetes clients.

This is the primary constructor for unit tests.

func NewManagerFromKubeconfig

func NewManagerFromKubeconfig(kubeconfig string) (*ManagerImpl, error)

NewManagerFromKubeconfig creates a manager by building Kubernetes clients from kubeconfig.

func (*ManagerImpl) Ensure

func (m *ManagerImpl) Ensure(ctx context.Context, opts EnsureOptions) error

Ensure creates or updates the Argo CD repository secret and Application.

func (*ManagerImpl) UpdateTargetRevision

func (m *ManagerImpl) UpdateTargetRevision(
	ctx context.Context,
	opts UpdateTargetRevisionOptions,
) error

UpdateTargetRevision updates the Application target revision and optionally requests a hard refresh.

type MockInstaller added in v5.28.9

type MockInstaller struct {
	mock.Mock
}

MockInstaller is an autogenerated mock type for the Installer type

func NewMockInstaller added in v5.28.9

func NewMockInstaller(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockInstaller

NewMockInstaller creates a new instance of MockInstaller. 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 (*MockInstaller) EXPECT added in v5.28.9

func (_m *MockInstaller) EXPECT() *MockInstaller_Expecter

func (*MockInstaller) Install added in v5.28.9

func (_mock *MockInstaller) Install(ctx context.Context) error

Install provides a mock function for the type MockInstaller

type MockInstaller_Expecter added in v5.28.9

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

func (*MockInstaller_Expecter) Install added in v5.28.9

func (_e *MockInstaller_Expecter) Install(ctx interface{}) *MockInstaller_Install_Call

Install is a helper method to define mock.On call

  • ctx context.Context

type MockInstaller_Install_Call added in v5.28.9

type MockInstaller_Install_Call struct {
	*mock.Call
}

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

func (*MockInstaller_Install_Call) Return added in v5.28.9

func (*MockInstaller_Install_Call) Run added in v5.28.9

func (*MockInstaller_Install_Call) RunAndReturn added in v5.28.9

type MockManager added in v5.28.9

type MockManager struct {
	mock.Mock
}

MockManager is an autogenerated mock type for the Manager type

func NewMockManager added in v5.28.9

func NewMockManager(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockManager

NewMockManager creates a new instance of MockManager. 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 (*MockManager) EXPECT added in v5.28.9

func (_m *MockManager) EXPECT() *MockManager_Expecter

func (*MockManager) Ensure added in v5.28.9

func (_mock *MockManager) Ensure(ctx context.Context, opts EnsureOptions) error

Ensure provides a mock function for the type MockManager

func (*MockManager) UpdateTargetRevision added in v5.28.9

func (_mock *MockManager) UpdateTargetRevision(ctx context.Context, opts UpdateTargetRevisionOptions) error

UpdateTargetRevision provides a mock function for the type MockManager

type MockManager_Ensure_Call added in v5.28.9

type MockManager_Ensure_Call struct {
	*mock.Call
}

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

func (*MockManager_Ensure_Call) Return added in v5.28.9

func (*MockManager_Ensure_Call) Run added in v5.28.9

func (*MockManager_Ensure_Call) RunAndReturn added in v5.28.9

func (_c *MockManager_Ensure_Call) RunAndReturn(run func(ctx context.Context, opts EnsureOptions) error) *MockManager_Ensure_Call

type MockManager_Expecter added in v5.28.9

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

func (*MockManager_Expecter) Ensure added in v5.28.9

func (_e *MockManager_Expecter) Ensure(ctx interface{}, opts interface{}) *MockManager_Ensure_Call

Ensure is a helper method to define mock.On call

  • ctx context.Context
  • opts EnsureOptions

func (*MockManager_Expecter) UpdateTargetRevision added in v5.28.9

func (_e *MockManager_Expecter) UpdateTargetRevision(ctx interface{}, opts interface{}) *MockManager_UpdateTargetRevision_Call

UpdateTargetRevision is a helper method to define mock.On call

  • ctx context.Context
  • opts UpdateTargetRevisionOptions

type MockManager_UpdateTargetRevision_Call added in v5.28.9

type MockManager_UpdateTargetRevision_Call struct {
	*mock.Call
}

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

func (*MockManager_UpdateTargetRevision_Call) Return added in v5.28.9

func (*MockManager_UpdateTargetRevision_Call) Run added in v5.28.9

func (*MockManager_UpdateTargetRevision_Call) RunAndReturn added in v5.28.9

type MockStatusProvider added in v5.28.9

type MockStatusProvider struct {
	mock.Mock
}

MockStatusProvider is an autogenerated mock type for the StatusProvider type

func NewMockStatusProvider added in v5.28.9

func NewMockStatusProvider(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockStatusProvider

NewMockStatusProvider creates a new instance of MockStatusProvider. 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 (*MockStatusProvider) EXPECT added in v5.28.9

func (*MockStatusProvider) GetStatus added in v5.28.9

func (_mock *MockStatusProvider) GetStatus(ctx context.Context) (Status, error)

GetStatus provides a mock function for the type MockStatusProvider

type MockStatusProvider_Expecter added in v5.28.9

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

func (*MockStatusProvider_Expecter) GetStatus added in v5.28.9

func (_e *MockStatusProvider_Expecter) GetStatus(ctx interface{}) *MockStatusProvider_GetStatus_Call

GetStatus is a helper method to define mock.On call

  • ctx context.Context

type MockStatusProvider_GetStatus_Call added in v5.28.9

type MockStatusProvider_GetStatus_Call struct {
	*mock.Call
}

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

func (*MockStatusProvider_GetStatus_Call) Return added in v5.28.9

func (*MockStatusProvider_GetStatus_Call) Run added in v5.28.9

func (*MockStatusProvider_GetStatus_Call) RunAndReturn added in v5.28.9

type ReconcileOptions added in v5.13.0

type ReconcileOptions struct {
	// Timeout for waiting for application sync.
	Timeout time.Duration
	// HardRefresh requests ArgoCD to refresh caches.
	HardRefresh bool
}

ReconcileOptions configures the reconciliation behavior.

type Reconciler added in v5.13.0

type Reconciler struct {
	*reconciler.Base
}

Reconciler handles ArgoCD reconciliation operations.

func NewReconciler added in v5.13.0

func NewReconciler(kubeconfigPath string) (*Reconciler, error)

NewReconciler creates a new ArgoCD reconciler from kubeconfig path.

func NewReconcilerWithClient added in v5.13.0

func NewReconcilerWithClient(dynamicClient dynamic.Interface) *Reconciler

NewReconcilerWithClient creates a Reconciler with a provided dynamic client (for testing).

func (*Reconciler) Reconcile added in v5.13.0

func (r *Reconciler) Reconcile(ctx context.Context, opts ReconcileOptions) error

Reconcile triggers and waits for ArgoCD application sync.

func (*Reconciler) TriggerRefresh added in v5.13.0

func (r *Reconciler) TriggerRefresh(ctx context.Context, hardRefresh bool) error

TriggerRefresh triggers an ArgoCD application refresh. Uses retry logic to handle optimistic concurrency conflicts when the Application is modified by ArgoCD controllers between GET and UPDATE operations.

func (*Reconciler) WaitForApplicationReady added in v5.13.0

func (r *Reconciler) WaitForApplicationReady(ctx context.Context, timeout time.Duration) error

WaitForApplicationReady waits for the ArgoCD application to be synced and healthy.

type Status

type Status struct {
	// Engine is a human-friendly engine name, e.g. "ArgoCD".
	Engine string
	// Installed indicates whether Argo CD appears installed.
	Installed bool
	// ApplicationPresent indicates whether the expected Application exists.
	ApplicationPresent bool
	// Message is a short user-facing summary.
	Message string
}

Status is a lightweight user-facing summary of Argo CD state.

type StatusProvider

type StatusProvider interface {
	GetStatus(ctx context.Context) (Status, error)
}

StatusProvider returns a lightweight, user-facing status summary.

type UpdateTargetRevisionOptions

type UpdateTargetRevisionOptions struct {
	ApplicationName string
	TargetRevision  string
	// HardRefresh requests Argo CD to refresh caches when updating revision.
	HardRefresh bool
}

UpdateTargetRevisionOptions configures how KSail updates an Application to a new OCI revision.

Jump to

Keyboard shortcuts

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