argocd

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ApplicationGVR is the GroupVersionResource for ArgoCD applications
	ApplicationGVR = schema.GroupVersionResource{
		Group:    "argoproj.io",
		Version:  "v1alpha1",
		Resource: "applications",
	}
)

Common resource GVRs

Functions

func ApplySecretsFromFolder added in v0.1.4

func ApplySecretsFromFolder(client *k8s.Client, secretsFolder string, namespace string) error

ApplySecretsFromFolder applies all secret manifests from a folder using the Kubernetes API

Types

type APIOperations added in v0.1.22

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

APIOperations implements the Operations interface using the ArgoCD HTTP API.

func (*APIOperations) AddSourceNamespaceToDefaultAppProject added in v0.1.22

func (a *APIOperations) AddSourceNamespaceToDefaultAppProject() error

AddSourceNamespaceToDefaultAppProject adds "*" to the sourceNamespaces of the default AppProject

func (*APIOperations) AppsetGenerate added in v0.1.22

func (a *APIOperations) AppsetGenerate(resource *unstructured.Unstructured, tempFolder string) ([]unstructured.Unstructured, error)

AppsetGenerate generates applications from an ApplicationSet using the ArgoCD API. The tempFolder parameter is not used in API mode but is required by the interface.

func (*APIOperations) CheckVersionCompatibility added in v0.1.22

func (a *APIOperations) CheckVersionCompatibility() error

CheckVersionCompatibility compares the ArgoCD library version (from go.mod) against the ArgoCD server version.

func (*APIOperations) Cleanup added in v0.1.22

func (a *APIOperations) Cleanup()

Cleanup performs any necessary cleanup for API mode

func (*APIOperations) GetManifests added in v0.1.22

func (a *APIOperations) GetManifests(appName string) ([]unstructured.Unstructured, bool, error)

GetManifests returns the manifests for an application using the ArgoCD API. It uses the /manifests endpoint which fetches and renders manifests directly from the source (Git/Helm) without requiring cluster sync permissions. This is preferred over /managed-resources for diff preview because: 1. It works in locked-down clusters without cluster-level RBAC 2. It returns freshly rendered manifests from the source 3. It doesn't require the application to have been synced first

func (*APIOperations) IsExpectedError added in v0.1.22

func (a *APIOperations) IsExpectedError(errorMessage string) (bool, string)

IsExpectedError checks if an error message matches expected error patterns. In API mode, certain errors are expected when running with 'createClusterRoles: false'. Returns: (isExpected, reason)

func (*APIOperations) Login added in v0.1.22

func (a *APIOperations) Login() error

Login performs login to ArgoCD using the HTTP API. If an auth token was provided during construction, this method will use that token instead of authenticating with username/password.

type ArgoCDInstallation

type ArgoCDInstallation struct {
	K8sClient         *k8s.Client
	Namespace         string
	Version           string
	ConfigPath        string
	ChartName         string
	ChartURL          string
	ChartRepoUsername string
	ChartRepoPassword string
	LoginOptions      string
	// contains filtered or unexported fields
}

func New

func New(client *k8s.Client, namespace string, version string, repoName string, repoURL string, repoUsername string, repoPassword string, loginOptions string, renderMode vars.RenderMethod, authToken string, configPath string) *ArgoCDInstallation

func (*ArgoCDInstallation) AppsetGenerate

func (a *ArgoCDInstallation) AppsetGenerate(resource *unstructured.Unstructured, tempFolder string) ([]unstructured.Unstructured, error)

AppsetGenerate generates applications from an ApplicationSet

func (*ArgoCDInstallation) AppsetGenerateWithRetry added in v0.1.10

func (a *ArgoCDInstallation) AppsetGenerateWithRetry(resource *unstructured.Unstructured, tempFolder string, maxAttempts int) ([]unstructured.Unstructured, error)

AppsetGenerateWithRetry runs AppsetGenerate with retry logic

func (*ArgoCDInstallation) Cleanup added in v0.1.22

func (a *ArgoCDInstallation) Cleanup()

Cleanup performs any necessary cleanup (e.g., stopping port forwards). This delegates to the operations implementation.

func (*ArgoCDInstallation) EnsureArgoCdIsReady added in v0.1.7

func (a *ArgoCDInstallation) EnsureArgoCdIsReady() error

EnsureArgoCdIsReady waits for ArgoCD deployments to be ready

func (*ArgoCDInstallation) GetManifests

func (a *ArgoCDInstallation) GetManifests(appName string) ([]unstructured.Unstructured, bool, error)

GetManifests returns the manifests for an application

func (*ArgoCDInstallation) Install

func (a *ArgoCDInstallation) Install(debug bool, secretsFolder string) (time.Duration, error)

func (*ArgoCDInstallation) IsExpectedError added in v0.1.22

func (a *ArgoCDInstallation) IsExpectedError(errorMessage string) (bool, string)

IsExpectedError checks if an error message is expected for the current mode. In API mode, certain errors are expected when running with 'createClusterRoles: false'. In CLI mode, this always returns false. Returns: (isExpected, reason)

func (*ArgoCDInstallation) OnlyLogin added in v0.1.11

func (a *ArgoCDInstallation) OnlyLogin() (time.Duration, error)

OnlyLogin performs only the login step without installing ArgoCD

func (*ArgoCDInstallation) RefreshApp

func (a *ArgoCDInstallation) RefreshApp(appName string) error

RefreshApp triggers a refresh of an application by setting the refresh annotation

func (*ArgoCDInstallation) RenderMethod added in v0.1.26

func (a *ArgoCDInstallation) RenderMethod() vars.RenderMethod

type CLIOperations added in v0.1.22

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

CLIOperations implements the Operations interface using the ArgoCD CLI.

func (*CLIOperations) AddSourceNamespaceToDefaultAppProject added in v0.1.22

func (c *CLIOperations) AddSourceNamespaceToDefaultAppProject() error

AddSourceNamespaceToDefaultAppProject adds "*" to the sourceNamespaces of the default AppProject

func (*CLIOperations) AppsetGenerate added in v0.1.22

func (c *CLIOperations) AppsetGenerate(resource *unstructured.Unstructured, tempFolder string) ([]unstructured.Unstructured, error)

AppsetGenerate runs 'argocd appset generate' on an ApplicationSet resource and returns the generated applications. The tempFolder parameter specifies where to write the temporary ApplicationSet file.

func (*CLIOperations) CheckVersionCompatibility added in v0.1.22

func (c *CLIOperations) CheckVersionCompatibility() error

CheckVersionCompatibility checks Argo CD CLI version vs Argo CD Server version

func (*CLIOperations) Cleanup added in v0.1.22

func (c *CLIOperations) Cleanup()

Cleanup is a no-op for CLI mode (no resources to clean up)

func (*CLIOperations) GetManifests added in v0.1.22

func (c *CLIOperations) GetManifests(appName string) ([]unstructured.Unstructured, bool, error)

GetManifests returns the manifests for an application using the CLI

func (*CLIOperations) IsExpectedError added in v0.1.22

func (c *CLIOperations) IsExpectedError(errorMessage string) (bool, string)

IsExpectedError always returns false for CLI mode. Expected errors only occur in API mode when running with 'createClusterRoles: false'.

func (*CLIOperations) Login added in v0.1.22

func (c *CLIOperations) Login() error

Login performs login to ArgoCD using the CLI. If a token was provided during construction, this method will skip the normal authentication and use the provided token instead (passed as ARGOCD_AUTH_TOKEN env var to CLI commands).

type Operations added in v0.1.22

type Operations interface {
	// Login authenticates with ArgoCD and caches credentials for future calls.
	// If a token was provided during construction, this method will skip authentication
	// and use the provided token instead.
	Login() error

	// AppsetGenerate generates applications from an ApplicationSet resource.
	// The tempFolder parameter specifies where to write temporary files (CLI mode only).
	AppsetGenerate(resource *unstructured.Unstructured, tempFolder string) ([]unstructured.Unstructured, error)

	// GetManifests returns the manifests for an application.
	// Returns: (manifests, appExists, error)
	GetManifests(appName string) ([]unstructured.Unstructured, bool, error)

	// CheckVersionCompatibility checks if the client/library version is compatible
	// with the ArgoCD server version
	CheckVersionCompatibility() error

	// AddSourceNamespaceToDefaultAppProject adds "*" to the sourceNamespaces
	// of the default AppProject to allow applications from any namespace
	AddSourceNamespaceToDefaultAppProject() error

	// Cleanup performs any necessary cleanup (e.g., stopping port forwards)
	Cleanup()

	// IsExpectedError checks if an error message is expected for this mode.
	// In API mode, certain errors are expected when running with 'createClusterRoles: false'.
	// In CLI mode, this always returns false.
	// Returns: (isExpected, reason)
	IsExpectedError(errorMessage string) (bool, string)
}

Operations defines the interface for ArgoCD operations. There are two implementations: CLIOperations and APIOperations. The implementation is chosen at construction time based on the useAPI flag.

func NewOperations added in v0.1.22

func NewOperations(renderMode vars.RenderMethod, k8sClient *k8s.Client, namespace string, loginOptions string, authToken string) Operations

NewOperations creates the appropriate Operations implementation based on the renderMode. If renderMode is server-api or repo-server-api, returns an APIOperations instance. If renderMode is cli, returns a CLIOperations instance. The authToken parameter is optional - if provided, it will be used instead of authenticating with the ArgoCD server during Login().

Jump to

Keyboard shortcuts

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