Documentation
¶
Index ¶
- type Client
- func (c *Client) ApplyAppOfApps(ctx context.Context, repoURL, targetRevision, env, appPath string, dryRun bool) (string, bool, error)
- func (c *Client) CreateGitCryptKeySecret(ctx context.Context, keyData []byte) (bool, error)
- func (c *Client) CreateRepoSSHSecret(ctx context.Context, repoURL, sshPrivateKey string, dryRun bool) (*corev1.Secret, bool, error)
- func (c *Client) EnsureNamespace(ctx context.Context, name string) (bool, error)
- type ClientInterface
- type MockClient
- func (m *MockClient) ApplyAppOfApps(ctx context.Context, repoURL, targetRevision, env, appPath string, dryRun bool) (string, bool, error)
- func (m *MockClient) CreateGitCryptKeySecret(ctx context.Context, keyData []byte) (bool, error)
- func (m *MockClient) CreateRepoSSHSecret(ctx context.Context, repoURL, sshPrivateKey string, dryRun bool) (*corev1.Secret, bool, error)
- func (m *MockClient) EnsureNamespace(ctx context.Context, name string) (bool, error)
- func (m *MockClient) GetApplication(name string) *unstructured.Unstructured
- func (m *MockClient) GetSecret(namespace, name string) *corev1.Secret
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
Clientset kubernetes.Interface
DynamicClient dynamic.Interface
}
Client wraps the Kubernetes clientset and dynamic client.
func NewClient ¶
NewClient creates a Kubernetes client from the given kubeconfig and context. If kubeconfig is empty, it uses the default loading rules. If context is empty, it uses the current context.
func (*Client) ApplyAppOfApps ¶
func (c *Client) ApplyAppOfApps(ctx context.Context, repoURL, targetRevision, env, appPath string, dryRun bool) (string, bool, error)
ApplyAppOfApps creates or updates the App of Apps root Application CR. Returns a boolean indicating if it was created (true) or updated (false) when not in dry-run mode. NOTE: This function's signature was changed to return an additional boolean value, which is a breaking API change. External callers must be updated to handle the extra return value.
func (*Client) CreateGitCryptKeySecret ¶
CreateGitCryptKeySecret creates or updates the git-crypt-key secret in the argocd namespace. The key data is the raw symmetric key used by git-crypt. Returns a boolean indicating if it was created (true) or updated (false).
func (*Client) CreateRepoSSHSecret ¶
func (c *Client) CreateRepoSSHSecret(ctx context.Context, repoURL, sshPrivateKey string, dryRun bool) (*corev1.Secret, bool, error)
CreateRepoSSHSecret creates or updates the repo-ssh-key secret in the argocd namespace. This matches the exact labels/annotations from the original install.sh. Returns the secret and a boolean indicating if it was created (true) or updated (false).
type ClientInterface ¶
type ClientInterface interface {
EnsureNamespace(ctx context.Context, name string) (bool, error)
CreateRepoSSHSecret(ctx context.Context, repoURL, sshPrivateKey string, dryRun bool) (*corev1.Secret, bool, error)
CreateGitCryptKeySecret(ctx context.Context, keyData []byte) (bool, error)
ApplyAppOfApps(ctx context.Context, repoURL, targetRevision, env, appPath string, dryRun bool) (string, bool, error)
}
ClientInterface defines the interface that both Client and MockClient implement. This is useful for testing code that uses a K8s client.
type MockClient ¶
type MockClient struct {
// Namespaces created in this mock.
Namespaces map[string]bool
// Secrets created in this mock.
Secrets map[string]map[string]*corev1.Secret
// Applications created in this mock.
Applications map[string]*unstructured.Unstructured
// Simulate errors for specific operations.
EnsureNamespaceErr error
CreateRepoSSHSecretErr error
CreateGitCryptKeyErr error
ApplyAppOfAppsErr error
EnsureNamespaceForbidden bool
CreateSecretForbidden bool
}
MockClient is a mock Kubernetes client for testing. It allows simulating errors and state.
func NewMockClient ¶
func NewMockClient() *MockClient
NewMockClient creates a new mock client for testing.
func (*MockClient) ApplyAppOfApps ¶
func (m *MockClient) ApplyAppOfApps(ctx context.Context, repoURL, targetRevision, env, appPath string, dryRun bool) (string, bool, error)
ApplyAppOfApps simulates Application CR creation.
func (*MockClient) CreateGitCryptKeySecret ¶
CreateGitCryptKeySecret simulates git-crypt key secret creation.
func (*MockClient) CreateRepoSSHSecret ¶
func (m *MockClient) CreateRepoSSHSecret(ctx context.Context, repoURL, sshPrivateKey string, dryRun bool) (*corev1.Secret, bool, error)
CreateRepoSSHSecret simulates secret creation with mock state.
func (*MockClient) EnsureNamespace ¶
EnsureNamespace simulates namespace creation with mock state.
func (*MockClient) GetApplication ¶
func (m *MockClient) GetApplication(name string) *unstructured.Unstructured
GetApplication retrieves a stored application from the mock (for testing verification).