argocd

package
v0.0.0-...-6cdb919 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrResourceNotFound = stderrors.New("resource not found")
	ErrResponseNotOK    = stderrors.New("response for argoCD is not 200 OK")
	ErrUnexpected       = stderrors.New("unexpected error")
)

Functions

This section is empty.

Types

type Application

type Application struct {
	APIVersion string              `json:"apiVersion" yaml:"apiVersion"`
	Kind       string              `json:"kind" yaml:"kind"`
	Metadata   ApplicationMetadata `json:"metadata" yaml:"metadata"`
	Spec       ApplicationSpec     `json:"spec" yaml:"spec"`
}

type ApplicationDestination

type ApplicationDestination struct {
	// Server overrides the environment server value in the ksonnet app.yaml
	Server string `json:"server" yaml:"server,omitempty"`
	// Namespace overrides the environment namespace value in the ksonnet app.yaml
	Namespace string `json:"namespace" yaml:"namespace,omitempty"`
}

ApplicationDestination contains deployment destination information

type ApplicationMetadata

type ApplicationMetadata struct {
	Finalizers []string `json:"finalizers" yaml:"finalizers"`
	Name       string   `json:"name" yaml:"name"`
	Namespace  string   `json:"namespace" yaml:"namespace"`
}

type ApplicationSource

type ApplicationSource struct {
	// RepoURL is the repository GitlabHTTPS of the application manifests
	RepoURL string `json:"repoURL" yaml:"repoURL"`
	// Path is a directory path within the Git repository
	Path string `json:"path" yaml:"path,omitempty"`
	// TargetRevision defines the commit, tag, or branch in which to sync the application to.
	// If omitted, will sync to HEAD
	TargetRevision string `json:"targetRevision" yaml:"targetRevision,omitempty"`
	// Helm holds helm specific options
	Helm *ApplicationSourceHelm `json:"helm" yaml:"helm,omitempty"`
}

ApplicationSource contains information about github repository, path within repository and target application environment.

type ApplicationSourceHelm

type ApplicationSourceHelm struct {
	// ValuesFiles is a list of Helm value files to use when generating a template
	ValueFiles []string `json:"valueFiles" yaml:"valueFiles,omitempty"`
}

ApplicationSourceHelm holds helm specific options

type ApplicationSpec

type ApplicationSpec struct {
	// Source is a reference to the location ksonnet application definition
	Source ApplicationSource `json:"source" yaml:"source"`
	// Destination overrides the kubernetes server and namespace defined in the environment ksonnet app.yaml
	Destination ApplicationDestination `json:"destination" yaml:"destination"`
	// Project is a application project name. Empty name means that application belongs to 'default' project.
	Project string `json:"project" yaml:"project"`
	// SyncPolicy controls when a sync will be performed
	SyncPolicy *SyncPolicy `json:"syncPolicy" yaml:"syncPolicy,omitempty"`
}

ApplicationSpec represents desired application state. Contains link to repository with application definition and additional parameters link definition revision.

type ArgoCD

type ArgoCD interface {
	// AssembleArgoApplication assemble application by params
	AssembleArgoApplication(name, namespace, gitRepoURL, server string,
		valueFiles []string, targetRevision string) *Application

	// CreateApplication create an application in argoCD
	CreateApplication(ctx context.Context, manifest []byte) error

	// DeployApplication deploy an application in argoCD
	DeployApplication(ctx context.Context, application string, revision string) error

	// DeleteApplication delete an application in argoCD
	// You need to delete Argo Application first, then delete gitlab repo,
	// otherwise Argo Application can never be deleted.
	// ref:https://argoproj.github.io/argo-cd/faq/#ive-deletedcorrupted-my-repo-and-cant-delete-my-app
	DeleteApplication(ctx context.Context, application string) error

	// WaitApplication Wait for the app sync to complete
	WaitApplication(ctx context.Context, application string, uid string, status int) error

	// GetApplication get an application in argoCD
	GetApplication(ctx context.Context, application string) (*v1alpha1.Application, error)

	// RefreshApplication ...
	RefreshApplication(ctx context.Context, application string) (app *v1alpha1.Application, err error)

	// GetApplicationTree get resource-tree of an application in argoCD
	GetApplicationTree(ctx context.Context, application string) (*v1alpha1.ApplicationTree, error)

	// GetApplicationResource get a resource under an application in argoCD
	GetApplicationResource(ctx context.Context, application string,
		param ResourceParams, resource interface{}) error

	// ListResourceEvents get resource's events of an application in argoCD
	ListResourceEvents(ctx context.Context, application string, param EventParam) (*corev1.EventList, error)

	// ResumeRollout ...
	ResumeRollout(ctx context.Context, application string) error

	// GetContainerLog get standard output of container of an application in argoCD
	GetContainerLog(ctx context.Context, application string,
		param ContainerLogParams) (<-chan ContainerLog, <-chan error, error)
}

ArgoCD interact with ArgoCD Server

func NewArgoCD

func NewArgoCD(URL, token, namespace string) ArgoCD

type ContainerLog

type ContainerLog struct {
	Result struct {
		Content   string `json:"content,omitempty" yaml:"content,omitempty"`
		Timestamp string `json:"timestamp,omitempty" yaml:"timestamp,omitempty"`
	} `json:"result"`
}

type ContainerLogParams

type ContainerLogParams struct {
	Namespace     string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
	PodName       string `json:"podName,omitempty" yaml:"podName,omitempty"`
	ContainerName string `json:"containerName,omitempty" yaml:"containerName,omitempty"`
	TailLines     int    `json:"tailLines,omitempty" yaml:"tailLines,omitempty"`
}

ContainerLogParams the params for GetContainerLog

type DeployApplicationRequest

type DeployApplicationRequest struct {
	Revision string   `json:"revision"`
	Prune    bool     `json:"prune"`
	DryRun   bool     `json:"dryRun"`
	Strategy Strategy `json:"strategy"`
}

type ErrorResponse

type ErrorResponse struct {
	StreamError struct {
		GrpcCode   int    `json:"grpc_code"`
		HTTPCode   int    `json:"http_code"`
		Message    string `json:"message"`
		HTTPStatus string `json:"http_status"`
	} `json:"error"`
}

type EventParam

type EventParam struct {
	ResourceNamespace string `json:"resourceNamespace"`
	ResourceUID       string `json:"resourceUID"`
	ResourceName      string `json:"resourceName"`
}

EventParam the params for ListResourceEvents

type Factory

type Factory interface {
	GetArgoCD(region string, environment string) (ArgoCD, error)
}

func NewFactory

func NewFactory(argoCDMapper argocd.Mapper, regionArgoCDMapper argocd.RegionMapper) Factory

type Hook

type Hook struct{}

type ResourceParams

type ResourceParams struct {
	// Group name in k8s, for example, Deployment resource is in 'apps' group
	Group string `json:"group,omitempty"`
	// Version in k8s, for example, Deployment resource has a 'v1' version
	Version string `json:"version,omitempty"`
	// the Kind of resource in k8s, for example, the kind of Deployment resource is 'Deployment'
	Kind string `json:"kind,omitempty"`
	// the namespace of a resource in k8s
	Namespace string `json:"namespace,omitempty"`
	// the resource name
	ResourceName string `json:"resourceName,omitempty"`
}

ResourceParams the params for GetApplicationResource

type Strategy

type Strategy struct {
	Hook Hook `json:"hook"`
}

type SyncOptions

type SyncOptions []string

type SyncPolicy

type SyncPolicy struct {
	// Options allow you to specify whole app sync-options
	SyncOptions SyncOptions `json:"syncOptions" yaml:"syncOptions,omitempty"`
}

SyncPolicy controls when a sync will be performed in response to updates in git

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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