Documentation
¶
Index ¶
- Constants
- Variables
- func FilterApplicationsForUpdate(ctx context.Context, ctrlClient *ArgoCDK8sClient, ...) (map[string]ApplicationImages, error)
- func GetApplicationSource(ctx context.Context, app *argocdapi.Application, wbc *WriteBackConfig) *argocdapi.ApplicationSource
- func GetApplicationSourceType(app *argocdapi.Application, wbc *WriteBackConfig) argocdapi.ApplicationSourceType
- func GetGitCreds(ctx context.Context, repo *v1alpha1.Repository, store git.CredsStore) git.Creds
- func GetHelmImage(ctx context.Context, app *argocdapi.Application, wbc *WriteBackConfig, ...) (string, error)
- func GetImagesFromApplication(applicationImages *ApplicationImages) image.ContainerImageList
- func GetKubeConfig(ctx context.Context, namespace string, kubeConfig string) (*kube.ImageUpdaterKubernetesClient, error)
- func GetKustomizeImage(ctx context.Context, app *argocdapi.Application, wbc *WriteBackConfig, ...) (string, error)
- func GetPrintableHealthPort(port int) string
- func GetPrintableInterval(interval time.Duration) string
- func IsValidApplicationType(app *argocdapi.Application, wbc *WriteBackConfig) bool
- func SetHelmImage(ctx context.Context, app *argocdapi.Application, ...) error
- func SetKustomizeImage(ctx context.Context, app *argocdapi.Application, ...) error
- func TemplateBranchName(ctx context.Context, branchName, appNamespace, appName string, ...) string
- func TemplateCommitMessage(ctx context.Context, tpl *template.Template, appName string, ...) string
- type ApplicationImages
- type ApplicationType
- type ArgoCD
- type ArgoCDK8sClient
- type ChangeEntry
- type GitCredsSource
- type GitLabMRService
- type GithubPRService
- type Image
- type ImageList
- type ImageUpdaterResult
- type PRProvider
- type PullRequest
- type PullRequestService
- type SyncIterationState
- type UpdateConfiguration
- type UpdateStrategyAnnotations
- type WebhookEvent
- type WriteBackConfig
- type WriteBackMethod
Constants ¶
const ( WriteBackMethodAnnotation = ImageUpdaterAnnotationPrefix + "/write-back-method" GitBranchAnnotation = ImageUpdaterAnnotationPrefix + "/git-branch" GitRepositoryAnnotation = ImageUpdaterAnnotationPrefix + "/git-repository" WriteBackTargetAnnotation = ImageUpdaterAnnotationPrefix + "/write-back-target" )
Application update configuration related annotations
const ( HelmParamImageNameAnnotationSuffix = "/%s.helm.image-name" HelmParamImageTagAnnotationSuffix = "/%s.helm.image-tag" HelmParamImageSpecAnnotationSuffix = "/%s.helm.image-spec" )
Helm related annotations
const ImageUpdaterAnnotation = ImageUpdaterAnnotationPrefix + "/image-list"
ImageUpdaterAnnotation is an annotation on the application resources to indicate the list of images allowed for updates.
const ImageUpdaterAnnotationPrefix = "argocd-image-updater.argoproj.io"
ImageUpdaterAnnotationPrefix is the base prefix for all argocd-image-updater annotations.
const (
KustomizeApplicationNameAnnotationSuffix = "/%s.kustomize.image-name"
)
KustomizeApplicationNameAnnotationSuffix Kustomize related annotations
Variables ¶
var ErrMRAlreadyExists = errors.New("MR already exists")
ErrMRAlreadyExists is returned by create when GitLab reports that an open MR for the same source → target pair already exists. The caller can treat this as a successful no-op rather than a reconciliation failure.
var ErrPRAlreadyExists = errors.New("PR already exists")
ErrPRAlreadyExists is returned by create when GitHub reports that an open PR for the same head → base pair already exists. The caller can treat this as a successful no-op rather than a reconciliation failure.
Functions ¶
func FilterApplicationsForUpdate ¶
func FilterApplicationsForUpdate(ctx context.Context, ctrlClient *ArgoCDK8sClient, kubeClient *kube.ImageUpdaterKubernetesClient, argocdDB db.ArgoDB, cr *iuapi.ImageUpdater, webhookEvent *WebhookEvent) (map[string]ApplicationImages, error)
FilterApplicationsForUpdate Retrieve a list of applications from ArgoCD that qualify for image updates Application needs either to be of type Kustomize or Helm.
func GetApplicationSource ¶ added in v0.13.0
func GetApplicationSource(ctx context.Context, app *argocdapi.Application, wbc *WriteBackConfig) *argocdapi.ApplicationSource
GetApplicationSource returns the main source of a Helm or Kustomize type of the ArgoCD application
func GetApplicationSourceType ¶ added in v0.13.0
func GetApplicationSourceType(app *argocdapi.Application, wbc *WriteBackConfig) argocdapi.ApplicationSourceType
GetApplicationSourceType returns the source type of the ArgoCD application
func GetGitCreds ¶ added in v0.14.0
func GetGitCreds(ctx context.Context, repo *v1alpha1.Repository, store git.CredsStore) git.Creds
GetGitCreds returns the credentials from a repository configuration used to authenticate at a Git repository This is a slightly modified version of upstream's Repository.GetGitCreds method. We need it so it does not return the upstream type. TODO(jannfis): Can be removed once we have the change to the git client's getGitAskPassEnv upstream.
func GetHelmImage ¶ added in v0.15.2
func GetHelmImage(ctx context.Context, app *argocdapi.Application, wbc *WriteBackConfig, applicationImage *Image) (string, error)
GetHelmImage gets the image set in Application source matching new image or an empty string if match is not found
func GetImagesFromApplication ¶ added in v0.2.0
func GetImagesFromApplication(applicationImages *ApplicationImages) image.ContainerImageList
GetImagesFromApplication returns the list of known images for the given application
func GetKubeConfig ¶ added in v1.0.0
func GetKustomizeImage ¶ added in v0.15.2
func GetKustomizeImage(ctx context.Context, app *argocdapi.Application, wbc *WriteBackConfig, applicationImage *Image) (string, error)
GetKustomizeImage gets the image set in Application source matching new image or an empty string if match is not found
func GetPrintableHealthPort ¶ added in v1.0.0
func GetPrintableInterval ¶ added in v1.0.0
func IsValidApplicationType ¶
func IsValidApplicationType(app *argocdapi.Application, wbc *WriteBackConfig) bool
IsValidApplicationType returns true if we can update the application
func SetHelmImage ¶ added in v0.4.0
func SetHelmImage(ctx context.Context, app *argocdapi.Application, newImage *image.ContainerImage, wbc *WriteBackConfig, applicationImage *Image) error
SetHelmImage sets image parameters for a Helm application
func SetKustomizeImage ¶ added in v0.4.0
func SetKustomizeImage(ctx context.Context, app *argocdapi.Application, newImage *image.ContainerImage, wbc *WriteBackConfig, applicationImage *Image) error
SetKustomizeImage sets a Kustomize image for given application
func TemplateBranchName ¶ added in v0.12.0
func TemplateBranchName(ctx context.Context, branchName, appNamespace, appName string, changeList []ChangeEntry) string
TemplateBranchName parses a string to a template, and returns a branch name from that new template. If a branch name can not be rendered, it returns an empty value.
func TemplateCommitMessage ¶ added in v0.10.2
func TemplateCommitMessage(ctx context.Context, tpl *template.Template, appName string, changeList []ChangeEntry) string
TemplateCommitMessage renders a commit message template and returns it as a string, including image labels that can be used to add custom information to commit messages. If the template could not be rendered, returns a default message.
Types ¶
type ApplicationImages ¶
type ApplicationImages struct {
argocdapi.Application
*WriteBackConfig
Images ImageList
}
ApplicationImages holds an Argo CD application, its write-back config, and a list of its images that are allowed to be considered for updates.
type ApplicationType ¶
type ApplicationType int
ApplicationType Type of the application
const ( ApplicationTypeUnsupported ApplicationType = 0 ApplicationTypeHelm ApplicationType = 1 ApplicationTypeKustomize ApplicationType = 2 )
func GetApplicationType ¶ added in v0.2.0
func GetApplicationType(app *argocdapi.Application, wbc *WriteBackConfig) ApplicationType
GetApplicationType returns the type of the ArgoCD application
type ArgoCD ¶
type ArgoCD interface {
GetApplication(ctx context.Context, appNamespace string, appName string) (*argocdapi.Application, error)
UpdateSpec(ctx context.Context, spec *application.ApplicationUpdateSpecRequest) (*argocdapi.ApplicationSpec, error)
}
ArgoCD is the interface for accessing Argo CD functions we need
type ArgoCDK8sClient ¶ added in v1.0.0
type ArgoCDK8sClient struct {
ctrlclient.Client
}
ArgoCDK8sClient is a controller-runtime based client specifically for ArgoCD application operations. It wraps ctrlclient.Client to provide ArgoCD-specific functionality like getting, listing, and updating ArgoCD Application resources.
func NewArgoCDK8sClient ¶ added in v1.0.0
func NewArgoCDK8sClient(ctrlClient ctrlclient.Client) (*ArgoCDK8sClient, error)
NewArgoCDK8sClient creates a new ArgoCD-specific Kubernetes client for managing ArgoCD applications. This client is designed to work with controller-runtime and provides methods for ArgoCD Application CRUD operations.
func (*ArgoCDK8sClient) GetApplication ¶ added in v1.0.0
func (client *ArgoCDK8sClient) GetApplication(ctx context.Context, appNamespace string, appName string) (*argocdapi.Application, error)
GetApplication retrieves a single application by its name and namespace.
func (*ArgoCDK8sClient) UpdateSpec ¶ added in v1.0.0
func (client *ArgoCDK8sClient) UpdateSpec(ctx context.Context, spec *application.ApplicationUpdateSpecRequest) (*argocdapi.ApplicationSpec, error)
UpdateSpec updates the spec for given application
type ChangeEntry ¶ added in v0.10.2
ChangeEntry represents an image that has been changed by Image Updater
type GitCredsSource ¶ added in v0.9.0
type GitCredsSource func(app *argocdapi.Application) (git.Creds, error)
type GitLabMRService ¶ added in v1.2.0
type GitLabMRService struct {
// contains filtered or unexported fields
}
GitLabMRService implements PullRequestService for GitLab and self-managed GitLab instances.
func NewGitLabMRService ¶ added in v1.2.0
func NewGitLabMRService(ctx context.Context, wbc *WriteBackConfig, tokenProvider git.SCMTokenProvider) (*GitLabMRService, error)
NewGitLabMRService builds a GitLabMRService from the resolved write-back config and the credential token provider. It obtains a token, resolves the API base URL, and parses the project path from the repo URL.
type GithubPRService ¶ added in v1.2.0
type GithubPRService struct {
// contains filtered or unexported fields
}
GithubPRService implements PullRequestService for GitHub and GitHub Enterprise.
func NewGithubPRService ¶ added in v1.2.0
func NewGithubPRService(ctx context.Context, wbc *WriteBackConfig, tokenProvider git.SCMTokenProvider) (*GithubPRService, error)
NewGithubPRService builds a GithubPRService from the resolved write-back config and the credential token provider. It obtains a token, resolves the API base URL, and parses the owner/repo from the repo URL.
type Image ¶ added in v1.0.0
type Image struct {
*image.ContainerImage
// Update settings
UpdateStrategy image.UpdateStrategy
ForceUpdate bool
AllowTags string
IgnoreTags []string
PullSecret string
Platforms []string
// ManifestTarget settings
HelmImageName string
HelmImageTag string
HelmImageSpec string
KustomizeImageName string
}
Image represents a container image and its update configuration. It embeds the neutral ContainerImage type and adds updater-specific configuration. Use this struct to populate elements from ImageUpdater CR.
func NewImage ¶ added in v1.0.0
func NewImage(ci *image.ContainerImage) *Image
NewImage creates a new Image object from a neutral ContainerImage
type ImageList ¶
type ImageList []*Image
ImageList is a list of Image objects that can be updated.
func GetImagesAndAliasesFromApplication ¶ added in v0.14.0
func GetImagesAndAliasesFromApplication(applicationImages *ApplicationImages) ImageList
GetImagesAndAliasesFromApplication returns only the images that are considered "live", with ImageAlias and ContainerImage set from the corresponding entry returned by GetImagesFromApplication.
The live-image set is built by GetImagesFromApplication from two sources:
- app.Status.Summary.Images — images actually running in the cluster.
- Force-update images — configured images with ForceUpdate == true are injected with a nil tag so they are always treated as live even when no running container is detected.
For each image in applicationImages.Images the function checks whether it is live (i.e. present in GetImagesFromApplication). Images that are not live are silently dropped from the result. For each live image:
- ContainerImage is replaced with the live instance, which carries the actual running tag (or nil for force-update images). This is a mutation of the original *Image element.
- ImageAlias is set from the configured alias (or ImageName as fallback).
When two configured aliases reference the same live image, the second alias receives a shallow copy of the live ContainerImage so that both alias entries carry independent ImageAlias values without interfering with each other.
TODO: this function together with GetImagesFromApplication should be refactored. We iterate through applicationImages.Images 3 times in one place (2 in functions and in containerImages.ContainsImage). Also the 4th loop is in marshalParamsOverride. See GITOPS-7415
func (ImageList) ToContainerImageList ¶ added in v1.0.0
func (list ImageList) ToContainerImageList() image.ContainerImageList
ToContainerImageList is a private helper that converts an ImageList to a neutral image.ContainerImageList. This allows us to reuse methods defined on ContainerImageList without duplicating code.
type ImageUpdaterResult ¶ added in v0.4.0
type ImageUpdaterResult struct {
NumApplicationsProcessed int
NumImagesFound int
NumImagesUpdated int
NumImagesConsidered int
NumSkipped int
NumErrors int
ApplicationsMatched int
Changes []ChangeEntry
}
ImageUpdaterResult Stores some statistics about the results of a run
func UpdateApplication ¶ added in v0.4.0
func UpdateApplication(ctx context.Context, updateConf *UpdateConfiguration, state *SyncIterationState) ImageUpdaterResult
UpdateApplication update all images of a single application. Will run in a goroutine.
type PRProvider ¶ added in v1.2.0
type PRProvider int
PRProvider identifies which SCM provider is used to open pull/merge requests.
const ( // PRProviderUnsupported is the zero value; no PR provider has been configured. PRProviderUnsupported PRProvider = iota // PRProviderGitHub opens pull requests via the GitHub REST API. PRProviderGitHub // PRProviderGitLab opens merge requests via the GitLab REST API. PRProviderGitLab )
type PullRequest ¶ added in v1.2.0
type PullRequest struct {
// contains filtered or unexported fields
}
PullRequest holds the metadata required to open a pull/merge request.
type PullRequestService ¶ added in v1.2.0
type PullRequestService interface {
// contains filtered or unexported methods
}
PullRequestService is implemented by each SCM provider that supports opening pull/merge requests.
type SyncIterationState ¶ added in v0.9.2
type SyncIterationState struct {
// contains filtered or unexported fields
}
SyncIterationState holds shared state of a running update operation
func NewSyncIterationState ¶ added in v0.9.2
func NewSyncIterationState() *SyncIterationState
NewSyncIterationState returns a new instance of SyncIterationState
func (*SyncIterationState) GetRepositoryLock ¶ added in v0.9.2
func (state *SyncIterationState) GetRepositoryLock(repository string) *sync.Mutex
GetRepositoryLock returns the lock for a specified repository
type UpdateConfiguration ¶ added in v0.9.0
type UpdateConfiguration struct {
NewRegFN registry.NewRegistryClient
ArgoClient ArgoCD
KubeClient *kube.ImageUpdaterKubernetesClient
ArgocdDB db.ArgoDB
UpdateApp *ApplicationImages
DryRun bool
GitCommitUser string
GitCommitEmail string
GitCommitMessage *template.Template
GitCommitSigningKey string
GitCommitSigningMethod string
GitCommitSignOff bool
DisableKubeEvents bool
IgnorePlatforms bool
GitCreds git.CredsStore
}
type UpdateStrategyAnnotations ¶ added in v1.1.0
type UpdateStrategyAnnotations struct {
AllowTags string
IgnoreTags string
ForceUpdate string
UpdateStrategy string
PullSecret string
Platforms string
}
UpdateStrategyAnnotations holds the annotation key mappings for update strategy settings.
type WebhookEvent ¶ added in v1.0.0
type WebhookEvent struct {
// RegistryURL is the URL of the registry that sent the webhook
RegistryURL string `json:"registryUrl,omitempty"`
// Repository is the repository name
Repository string `json:"repository,omitempty"`
// Tag is the image tag
Tag string `json:"tag,omitempty"`
// Digest is the content digest of the image
Digest string `json:"digest,omitempty"`
}
WebhookEvent represents a generic webhook payload
type WriteBackConfig ¶ added in v0.9.0
type WriteBackConfig struct {
Method WriteBackMethod
ArgoClient ArgoCD
ArgocdDB db.ArgoDB
// If GitClient is not nil, the client will be used for updates. Otherwise, a new client will be created.
GitClient git.Client
GetCreds GitCredsSource
GitBranch string
GitWriteBranch string
GitCommitUser string
GitCommitEmail string
GitCommitMessage string
GitCommitSigningKey string
GitCommitSigningMethod string
GitCommitSignOff bool
KustomizeBase string
Target string
GitRepo string
GitCreds git.CredsStore
PRProvider PRProvider
PullRequest *PullRequest
}
WriteBackConfig holds information on how to write back the changes to an Application
func (*WriteBackConfig) RequiresLocking ¶ added in v0.9.2
func (wbc *WriteBackConfig) RequiresLocking() bool
RequiresLocking returns true if write-back method requires repository locking
type WriteBackMethod ¶ added in v0.9.0
type WriteBackMethod int
const ( WriteBackApplication WriteBackMethod = 0 WriteBackGit WriteBackMethod = 1 )