argocd

package
v0.0.0-...-7e3aec1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterApplicationsForUpdate

func FilterApplicationsForUpdate(apps []v1alpha1.Application, patterns []string) (map[string]ApplicationImages, error)

Retrieve a list of applications from ArgoCD that qualify for image updates Application needs either to be of type Kustomize or Helm and must have the correct annotation in order to be considered.

func GetApplicationSource

func GetApplicationSource(app *v1alpha1.Application) *v1alpha1.ApplicationSource

GetApplicationSource returns the main source of a Helm or Kustomize type of the ArgoCD application

func GetApplicationSourceType

func GetApplicationSourceType(app *v1alpha1.Application) v1alpha1.ApplicationSourceType

GetApplicationSourceType returns the source type of the ArgoCD application

func GetGitCreds

func GetGitCreds(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 GetImagesAndAliasesFromApplication

func GetImagesAndAliasesFromApplication(app *v1alpha1.Application) image.ContainerImageList

GetImagesFromApplicationImagesAnnotation returns the list of known images for the given application from the images annotation

func GetImagesFromApplication

func GetImagesFromApplication(app *v1alpha1.Application) image.ContainerImageList

GetImagesFromApplication returns the list of known images for the given application

func IsValidApplicationType

func IsValidApplicationType(app *v1alpha1.Application) bool

IsValidApplicationType returns true if we can update the application

func SetHelmImage

func SetHelmImage(app *v1alpha1.Application, newImage *image.ContainerImage) error

SetHelmImage sets image parameters for a Helm application

func SetKustomizeImage

func SetKustomizeImage(app *v1alpha1.Application, newImage *image.ContainerImage) error

SetKustomizeImage sets a Kustomize image for given application

func TemplateBranchName

func TemplateBranchName(branchName 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

func TemplateCommitMessage(tpl *template.Template, appName string, changeList []ChangeEntry) string

templateCommitMessage renders a commit message template and returns it as as a string. If the template could not be rendered, returns a default message.

Types

type ApplicationImages

type ApplicationImages struct {
	Application v1alpha1.Application
	Images      image.ContainerImageList
}

type ApplicationType

type ApplicationType int

Type of the application

const (
	ApplicationTypeUnsupported ApplicationType = 0
	ApplicationTypeHelm        ApplicationType = 1
	ApplicationTypeKustomize   ApplicationType = 2
)

func GetApplicationType

func GetApplicationType(app *v1alpha1.Application) ApplicationType

GetApplicationType returns the type of the ArgoCD application

func GetApplicationTypeByName

func GetApplicationTypeByName(client ArgoCD, appName string) (ApplicationType, error)

GetApplicationTypeByName first retrieves application with given appName and returns its application type

func (ApplicationType) String

func (a ApplicationType) String() string

String returns a string representation of the application type

type ArgoCD

type ArgoCD interface {
	GetApplication(ctx context.Context, appName string) (*v1alpha1.Application, error)
	ListApplications(labelSelector string) ([]v1alpha1.Application, error)
	UpdateSpec(ctx context.Context, spec *application.ApplicationUpdateSpecRequest) (*v1alpha1.ApplicationSpec, error)
}

ArgoCD is the interface for accessing Argo CD functions we need

func NewAPIClient

func NewAPIClient(opts *ClientOptions) (ArgoCD, error)

NewAPIClient creates a new API client for ArgoCD and connects to the ArgoCD API server.

func NewK8SClient

func NewK8SClient(kubeClient *kube.KubernetesClient) (ArgoCD, error)

NewK8SClient creates a new kubernetes client to interact with kubernetes api-server.

type ChangeEntry

type ChangeEntry struct {
	Image  *image.ContainerImage
	OldTag *tag.ImageTag
	NewTag *tag.ImageTag
}

ChangeEntry represents an image that has been changed by Image Updater

type ClientOptions

type ClientOptions struct {
	ServerAddr      string
	Insecure        bool
	Plaintext       bool
	Certfile        string
	GRPCWeb         bool
	GRPCWebRootPath string
	AuthToken       string
}

Basic wrapper struct for ArgoCD client options

type GitCredsSource

type GitCredsSource func(app *v1alpha1.Application) (git.Creds, error)

type ImageList

type ImageList map[string]ApplicationImages

Will hold a list of applications with the images allowed to considered for update.

type ImageUpdaterResult

type ImageUpdaterResult struct {
	NumApplicationsProcessed int
	NumImagesFound           int
	NumImagesUpdated         int
	NumImagesConsidered      int
	NumSkipped               int
	NumErrors                int
}

Stores some statistics about the results of a run

func UpdateApplication

func UpdateApplication(updateConf *UpdateConfiguration, state *SyncIterationState) ImageUpdaterResult

UpdateApplication update all images of a single application. Will run in a goroutine.

type SyncIterationState

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

SyncIterationState holds shared state of a running update operation

func NewSyncIterationState

func NewSyncIterationState() *SyncIterationState

NewSyncIterationState returns a new instance of SyncIterationState

func (*SyncIterationState) GetRepositoryLock

func (state *SyncIterationState) GetRepositoryLock(repository string) *sync.Mutex

GetRepositoryLock returns the lock for a specified repository

type UpdateConfiguration

type UpdateConfiguration struct {
	NewRegFN               registry.NewRegistryClient
	ArgoClient             ArgoCD
	KubeClient             *kube.KubernetesClient
	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 WriteBackConfig

type WriteBackConfig struct {
	Method     WriteBackMethod
	ArgoClient ArgoCD
	// 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
}

WriteBackConfig holds information on how to write back the changes to an Application

func (*WriteBackConfig) RequiresLocking

func (wbc *WriteBackConfig) RequiresLocking() bool

RequiresLocking returns true if write-back method requires repository locking

type WriteBackMethod

type WriteBackMethod int
const (
	WriteBackApplication WriteBackMethod = 0
	WriteBackGit         WriteBackMethod = 1
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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