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
- Variables
- type EnsureOptions
- type Installer
- type Manager
- type ManagerImpl
- type MockInstaller
- type MockInstaller_Expecter
- type MockInstaller_Install_Call
- func (_c *MockInstaller_Install_Call) Return(err error) *MockInstaller_Install_Call
- func (_c *MockInstaller_Install_Call) Run(run func(ctx context.Context)) *MockInstaller_Install_Call
- func (_c *MockInstaller_Install_Call) RunAndReturn(run func(ctx context.Context) error) *MockInstaller_Install_Call
- type MockManager
- type MockManager_Ensure_Call
- func (_c *MockManager_Ensure_Call) Return(err error) *MockManager_Ensure_Call
- func (_c *MockManager_Ensure_Call) Run(run func(ctx context.Context, opts EnsureOptions)) *MockManager_Ensure_Call
- func (_c *MockManager_Ensure_Call) RunAndReturn(run func(ctx context.Context, opts EnsureOptions) error) *MockManager_Ensure_Call
- type MockManager_Expecter
- type MockManager_UpdateTargetRevision_Call
- func (_c *MockManager_UpdateTargetRevision_Call) Return(err error) *MockManager_UpdateTargetRevision_Call
- func (_c *MockManager_UpdateTargetRevision_Call) Run(run func(ctx context.Context, opts UpdateTargetRevisionOptions)) *MockManager_UpdateTargetRevision_Call
- func (_c *MockManager_UpdateTargetRevision_Call) RunAndReturn(run func(ctx context.Context, opts UpdateTargetRevisionOptions) error) *MockManager_UpdateTargetRevision_Call
- type MockStatusProvider
- type MockStatusProvider_Expecter
- type MockStatusProvider_GetStatus_Call
- func (_c *MockStatusProvider_GetStatus_Call) Return(status Status, err error) *MockStatusProvider_GetStatus_Call
- func (_c *MockStatusProvider_GetStatus_Call) Run(run func(ctx context.Context)) *MockStatusProvider_GetStatus_Call
- func (_c *MockStatusProvider_GetStatus_Call) RunAndReturn(run func(ctx context.Context) (Status, error)) *MockStatusProvider_GetStatus_Call
- type ReconcileOptions
- type Reconciler
- type Status
- type StatusProvider
- type UpdateTargetRevisionOptions
Constants ¶
const (
// DefaultNamespace is the default namespace for ArgoCD resources.
DefaultNamespace = "argocd"
)
Reconciler constants.
Variables ¶
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 ¶
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
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
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
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 (_c *MockInstaller_Install_Call) Return(err error) *MockInstaller_Install_Call
func (*MockInstaller_Install_Call) Run ¶ added in v5.28.9
func (_c *MockInstaller_Install_Call) Run(run func(ctx context.Context)) *MockInstaller_Install_Call
func (*MockInstaller_Install_Call) RunAndReturn ¶ added in v5.28.9
func (_c *MockInstaller_Install_Call) RunAndReturn(run func(ctx context.Context) error) *MockInstaller_Install_Call
type MockManager ¶ added in v5.28.9
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
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 (_c *MockManager_Ensure_Call) Return(err error) *MockManager_Ensure_Call
func (*MockManager_Ensure_Call) Run ¶ added in v5.28.9
func (_c *MockManager_Ensure_Call) Run(run func(ctx context.Context, opts EnsureOptions)) *MockManager_Ensure_Call
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
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 (_c *MockManager_UpdateTargetRevision_Call) Return(err error) *MockManager_UpdateTargetRevision_Call
func (*MockManager_UpdateTargetRevision_Call) Run ¶ added in v5.28.9
func (_c *MockManager_UpdateTargetRevision_Call) Run(run func(ctx context.Context, opts UpdateTargetRevisionOptions)) *MockManager_UpdateTargetRevision_Call
func (*MockManager_UpdateTargetRevision_Call) RunAndReturn ¶ added in v5.28.9
func (_c *MockManager_UpdateTargetRevision_Call) RunAndReturn(run func(ctx context.Context, opts UpdateTargetRevisionOptions) error) *MockManager_UpdateTargetRevision_Call
type MockStatusProvider ¶ added in v5.28.9
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 (_m *MockStatusProvider) EXPECT() *MockStatusProvider_Expecter
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
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 (_c *MockStatusProvider_GetStatus_Call) Return(status Status, err error) *MockStatusProvider_GetStatus_Call
func (*MockStatusProvider_GetStatus_Call) Run ¶ added in v5.28.9
func (_c *MockStatusProvider_GetStatus_Call) Run(run func(ctx context.Context)) *MockStatusProvider_GetStatus_Call
func (*MockStatusProvider_GetStatus_Call) RunAndReturn ¶ added in v5.28.9
func (_c *MockStatusProvider_GetStatus_Call) RunAndReturn(run func(ctx context.Context) (Status, error)) *MockStatusProvider_GetStatus_Call
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
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 ¶
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.