2018-02-20 22:06:15 +00:00
|
|
|
package common
|
|
|
|
|
|
2020-03-18 10:28:31 +00:00
|
|
|
import (
|
|
|
|
|
"os"
|
2020-03-29 08:35:25 +00:00
|
|
|
"time"
|
2020-03-18 10:28:31 +00:00
|
|
|
)
|
|
|
|
|
|
2018-12-01 07:54:01 +00:00
|
|
|
// Default service addresses and URLS of Argo CD internal services
|
2018-02-20 22:06:15 +00:00
|
|
|
const (
|
2018-12-01 07:54:01 +00:00
|
|
|
// DefaultRepoServerAddr is the gRPC address of the Argo CD repo server
|
|
|
|
|
DefaultRepoServerAddr = "argocd-repo-server:8081"
|
|
|
|
|
// DefaultDexServerAddr is the HTTP address of the Dex OIDC server, which we run a reverse proxy against
|
2019-01-31 20:54:46 +00:00
|
|
|
DefaultDexServerAddr = "http://argocd-dex-server:5556"
|
2019-02-13 23:20:40 +00:00
|
|
|
// DefaultRedisAddr is the default redis address
|
2019-02-19 17:23:05 +00:00
|
|
|
DefaultRedisAddr = "argocd-redis:6379"
|
2018-11-18 00:00:55 +00:00
|
|
|
)
|
|
|
|
|
|
2018-12-01 07:54:01 +00:00
|
|
|
// Kubernetes ConfigMap and Secret resource names which hold Argo CD settings
|
2018-04-04 11:11:20 +00:00
|
|
|
const (
|
2018-06-06 04:44:14 +00:00
|
|
|
ArgoCDConfigMapName = "argocd-cm"
|
2018-12-01 07:54:01 +00:00
|
|
|
ArgoCDSecretName = "argocd-secret"
|
2018-06-06 04:44:14 +00:00
|
|
|
ArgoCDRBACConfigMapName = "argocd-rbac-cm"
|
2019-07-11 23:00:47 +00:00
|
|
|
// Contains SSH known hosts data for connecting repositories. Will get mounted as volume to pods
|
|
|
|
|
ArgoCDKnownHostsConfigMapName = "argocd-ssh-known-hosts-cm"
|
|
|
|
|
// Contains TLS certificate data for connecting repositories. Will get mounted as volume to pods
|
|
|
|
|
ArgoCDTLSCertsConfigMapName = "argocd-tls-certs-cm"
|
2020-06-22 16:21:53 +00:00
|
|
|
ArgoCDGPGKeysConfigMapName = "argocd-gpg-keys-cm"
|
2018-04-04 11:11:20 +00:00
|
|
|
)
|
|
|
|
|
|
2019-11-04 04:15:28 +00:00
|
|
|
// Some default configurables
|
2019-06-03 16:50:46 +00:00
|
|
|
const (
|
|
|
|
|
DefaultSystemNamespace = "kube-system"
|
2019-11-04 04:15:28 +00:00
|
|
|
DefaultRepoType = "git"
|
2019-06-03 16:50:46 +00:00
|
|
|
)
|
|
|
|
|
|
2019-05-28 18:41:02 +00:00
|
|
|
// Default listener ports for ArgoCD components
|
2019-02-22 23:20:34 +00:00
|
|
|
const (
|
2019-05-28 18:41:02 +00:00
|
|
|
DefaultPortAPIServer = 8080
|
|
|
|
|
DefaultPortRepoServer = 8081
|
|
|
|
|
DefaultPortArgoCDMetrics = 8082
|
|
|
|
|
DefaultPortArgoCDAPIServerMetrics = 8083
|
|
|
|
|
DefaultPortRepoServerMetrics = 8084
|
2019-02-22 23:20:34 +00:00
|
|
|
)
|
|
|
|
|
|
2019-07-25 00:25:27 +00:00
|
|
|
// Default paths on the pod's file system
|
|
|
|
|
const (
|
|
|
|
|
// The default path where TLS certificates for repositories are located
|
|
|
|
|
DefaultPathTLSConfig = "/app/config/tls"
|
|
|
|
|
// The default path where SSH known hosts are stored
|
|
|
|
|
DefaultPathSSHConfig = "/app/config/ssh"
|
|
|
|
|
// Default name for the SSH known hosts file
|
|
|
|
|
DefaultSSHKnownHostsName = "ssh_known_hosts"
|
2020-06-22 16:21:53 +00:00
|
|
|
// Default path to GnuPG home directory
|
|
|
|
|
DefaultGnuPgHomePath = "/app/config/gpg/keys"
|
2021-03-16 16:23:10 +00:00
|
|
|
// Default path to repo server TLS endpoint config
|
|
|
|
|
DefaultAppConfigPath = "/app/config"
|
2019-07-25 00:25:27 +00:00
|
|
|
)
|
|
|
|
|
|
2018-12-01 07:54:01 +00:00
|
|
|
// Argo CD application related constants
|
|
|
|
|
const (
|
2021-05-19 19:43:04 +00:00
|
|
|
|
2018-12-01 07:54:01 +00:00
|
|
|
// ArgoCDAdminUsername is the username of the 'admin' user
|
|
|
|
|
ArgoCDAdminUsername = "admin"
|
|
|
|
|
// ArgoCDUserAgentName is the default user-agent name used by the gRPC API client library and grpc-gateway
|
|
|
|
|
ArgoCDUserAgentName = "argocd-client"
|
|
|
|
|
// AuthCookieName is the HTTP cookie name where we store our auth token
|
|
|
|
|
AuthCookieName = "argocd.token"
|
2021-05-19 19:43:04 +00:00
|
|
|
|
2020-03-29 08:35:25 +00:00
|
|
|
// ChangePasswordSSOTokenMaxAge is the max token age for password change operation
|
|
|
|
|
ChangePasswordSSOTokenMaxAge = time.Minute * 5
|
2021-02-19 22:24:32 +00:00
|
|
|
// GithubAppCredsExpirationDuration is the default time used to cache the GitHub app credentials
|
|
|
|
|
GithubAppCredsExpirationDuration = time.Minute * 60
|
2018-12-01 07:54:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Dex related constants
|
2018-05-10 22:43:58 +00:00
|
|
|
const (
|
|
|
|
|
// DexAPIEndpoint is the endpoint where we serve the Dex API server
|
|
|
|
|
DexAPIEndpoint = "/api/dex"
|
2018-11-05 19:29:01 +00:00
|
|
|
// LoginEndpoint is Argo CD's shorthand login endpoint which redirects to dex's OAuth 2.0 provider's consent page
|
2018-05-10 22:43:58 +00:00
|
|
|
LoginEndpoint = "/auth/login"
|
2020-11-20 19:19:17 +00:00
|
|
|
// LogoutEndpoint is Argo CD's shorthand logout endpoint which invalidates OIDC session after logout
|
|
|
|
|
LogoutEndpoint = "/auth/logout"
|
2018-11-05 19:29:01 +00:00
|
|
|
// CallbackEndpoint is Argo CD's final callback endpoint we reach after OAuth 2.0 login flow has been completed
|
2018-05-10 22:43:58 +00:00
|
|
|
CallbackEndpoint = "/auth/callback"
|
2019-08-23 21:06:20 +00:00
|
|
|
// DexCallbackEndpoint is Argo CD's final callback endpoint when Dex is configured
|
|
|
|
|
DexCallbackEndpoint = "/api/dex/callback"
|
2018-05-10 22:43:58 +00:00
|
|
|
// ArgoCDClientAppName is name of the Oauth client app used when registering our web app to dex
|
2018-11-05 19:29:01 +00:00
|
|
|
ArgoCDClientAppName = "Argo CD"
|
2018-05-10 22:43:58 +00:00
|
|
|
// ArgoCDClientAppID is the Oauth client ID we will use when registering our app to dex
|
|
|
|
|
ArgoCDClientAppID = "argo-cd"
|
|
|
|
|
// ArgoCDCLIClientAppName is name of the Oauth client app used when registering our CLI to dex
|
2018-11-05 19:29:01 +00:00
|
|
|
ArgoCDCLIClientAppName = "Argo CD CLI"
|
2018-05-10 22:43:58 +00:00
|
|
|
// ArgoCDCLIClientAppID is the Oauth client ID we will use when registering our CLI to dex
|
|
|
|
|
ArgoCDCLIClientAppID = "argo-cd-cli"
|
|
|
|
|
)
|
|
|
|
|
|
2018-12-01 07:54:01 +00:00
|
|
|
// Resource metadata labels and annotations (keys and values) used by Argo CD components
|
|
|
|
|
const (
|
|
|
|
|
// LabelKeyAppInstance is the label key to use to uniquely identify the instance of an application
|
|
|
|
|
// The Argo CD application name is used as the instance name
|
|
|
|
|
LabelKeyAppInstance = "app.kubernetes.io/instance"
|
2021-06-23 17:46:43 +00:00
|
|
|
// LabelKeyLegacyApplicationName is the legacy label (v0.10 and below) and is superceded by 'app.kubernetes.io/instance'
|
2018-12-01 07:54:01 +00:00
|
|
|
LabelKeyLegacyApplicationName = "applications.argoproj.io/app-name"
|
2021-06-23 17:46:43 +00:00
|
|
|
// LabelKeySecretType contains the type of argocd secret (currently: 'cluster', 'repository', 'repo-config' or 'repo-creds')
|
2018-12-01 07:54:01 +00:00
|
|
|
LabelKeySecretType = "argocd.argoproj.io/secret-type"
|
|
|
|
|
// LabelValueSecretTypeCluster indicates a secret type of cluster
|
|
|
|
|
LabelValueSecretTypeCluster = "cluster"
|
2021-06-23 17:46:43 +00:00
|
|
|
// LabelValueSecretTypeRepository indicates a secret type of repository
|
|
|
|
|
LabelValueSecretTypeRepository = "repository"
|
|
|
|
|
// LabelValueSecretTypeRepoCreds indicates a secret type of repository credentials
|
|
|
|
|
LabelValueSecretTypeRepoCreds = "repo-creds"
|
2018-12-01 07:54:01 +00:00
|
|
|
|
2019-06-07 15:46:11 +00:00
|
|
|
// AnnotationCompareOptions is a comma-separated list of options for comparison
|
|
|
|
|
AnnotationCompareOptions = "argocd.argoproj.io/compare-options"
|
2020-05-15 17:01:18 +00:00
|
|
|
|
2018-12-01 07:54:01 +00:00
|
|
|
// AnnotationKeyManagedBy is annotation name which indicates that k8s resource is managed by an application.
|
|
|
|
|
AnnotationKeyManagedBy = "managed-by"
|
|
|
|
|
// AnnotationValueManagedByArgoCD is a 'managed-by' annotation value for resources managed by Argo CD
|
|
|
|
|
AnnotationValueManagedByArgoCD = "argocd.argoproj.io"
|
2020-10-29 20:17:54 +00:00
|
|
|
|
2020-09-30 05:39:10 +00:00
|
|
|
// AnnotationKeyLinkPrefix tells the UI to add an external link icon to the application node
|
|
|
|
|
// that links to the value given in the annotation.
|
|
|
|
|
// The annotation key must be followed by a unique identifier. Ex: link.argocd.argoproj.io/dashboard
|
2020-10-20 01:21:06 +00:00
|
|
|
// It's valid to have multiple annotations that match the prefix.
|
2020-09-30 05:39:10 +00:00
|
|
|
// Values can simply be a url or they can have
|
|
|
|
|
// an optional link title separated by a "|"
|
|
|
|
|
// Ex: "http://grafana.example.com/d/yu5UH4MMz/deployments"
|
|
|
|
|
// Ex: "Go to Dashboard|http://grafana.example.com/d/yu5UH4MMz/deployments"
|
|
|
|
|
AnnotationKeyLinkPrefix = "link.argocd.argoproj.io/"
|
2018-02-20 22:06:15 +00:00
|
|
|
)
|
2018-02-27 11:08:19 +00:00
|
|
|
|
2018-12-01 07:54:01 +00:00
|
|
|
// Environment variables for tuning and debugging Argo CD
|
2018-02-27 11:08:19 +00:00
|
|
|
const (
|
2018-12-01 07:54:01 +00:00
|
|
|
// EnvVarSSODebug is an environment variable to enable additional OAuth debugging in the API server
|
|
|
|
|
EnvVarSSODebug = "ARGOCD_SSO_DEBUG"
|
|
|
|
|
// EnvVarRBACDebug is an environment variable to enable additional RBAC debugging in the API server
|
|
|
|
|
EnvVarRBACDebug = "ARGOCD_RBAC_DEBUG"
|
2019-07-25 00:25:27 +00:00
|
|
|
// Overrides the location where SSH known hosts for repo access data is stored
|
|
|
|
|
EnvVarSSHDataPath = "ARGOCD_SSH_DATA_PATH"
|
|
|
|
|
// Overrides the location where TLS certificate for repo access data is stored
|
|
|
|
|
EnvVarTLSDataPath = "ARGOCD_TLS_DATA_PATH"
|
2019-09-11 05:03:21 +00:00
|
|
|
// Specifies number of git remote operations attempts count
|
|
|
|
|
EnvGitAttemptsCount = "ARGOCD_GIT_ATTEMPTS_COUNT"
|
2019-10-21 22:17:07 +00:00
|
|
|
// Overrides git submodule support, true by default
|
|
|
|
|
EnvGitSubmoduleEnabled = "ARGOCD_GIT_MODULES_ENABLED"
|
2020-06-22 16:21:53 +00:00
|
|
|
// EnvGnuPGHome is the path to ArgoCD's GnuPG keyring for signature verification
|
|
|
|
|
EnvGnuPGHome = "ARGOCD_GNUPGHOME"
|
2020-09-17 23:21:25 +00:00
|
|
|
// EnvWatchAPIBufferSize is the buffer size used to transfer K8S watch events to watch API consumer
|
|
|
|
|
EnvWatchAPIBufferSize = "ARGOCD_WATCH_API_BUFFER_SIZE"
|
2020-10-09 20:47:31 +00:00
|
|
|
// EnvPauseGenerationAfterFailedAttempts will pause manifest generation after the specified number of failed generation attempts
|
|
|
|
|
EnvPauseGenerationAfterFailedAttempts = "ARGOCD_PAUSE_GEN_AFTER_FAILED_ATTEMPTS"
|
|
|
|
|
// EnvPauseGenerationMinutes pauses manifest generation for the specified number of minutes, after sufficient manifest generation failures
|
|
|
|
|
EnvPauseGenerationMinutes = "ARGOCD_PAUSE_GEN_MINUTES"
|
|
|
|
|
// EnvPauseGenerationRequests pauses manifest generation for the specified number of requests, after sufficient manifest generation failures
|
|
|
|
|
EnvPauseGenerationRequests = "ARGOCD_PAUSE_GEN_REQUESTS"
|
2020-10-09 20:16:54 +00:00
|
|
|
// EnvControllerReplicas is the number of controller replicas
|
|
|
|
|
EnvControllerReplicas = "ARGOCD_CONTROLLER_REPLICAS"
|
|
|
|
|
// EnvControllerShard is the shard number that should be handled by controller
|
|
|
|
|
EnvControllerShard = "ARGOCD_CONTROLLER_SHARD"
|
2020-11-24 00:44:09 +00:00
|
|
|
// EnvEnableGRPCTimeHistogramEnv enables gRPC metrics collection
|
|
|
|
|
EnvEnableGRPCTimeHistogramEnv = "ARGOCD_ENABLE_GRPC_TIME_HISTOGRAM"
|
2021-02-19 22:24:32 +00:00
|
|
|
// EnvGithubAppCredsExpirationDuration controls the caching of Github app credentials. This value is in minutes (default: 60)
|
|
|
|
|
EnvGithubAppCredsExpirationDuration = "ARGOCD_GITHUB_APP_CREDS_EXPIRATION_DURATION"
|
2021-03-03 22:07:59 +00:00
|
|
|
// EnvHelmIndexCacheDuration controls how the helm repository index file is cached for (default: 0)
|
|
|
|
|
EnvHelmIndexCacheDuration = "ARGOCD_HELM_INDEX_CACHE_DURATION"
|
2021-03-16 16:23:10 +00:00
|
|
|
// EnvRepoServerConfigPath allows to override the configuration path for repo server
|
|
|
|
|
EnvAppConfigPath = "ARGOCD_APP_CONF_PATH"
|
2021-05-28 23:27:57 +00:00
|
|
|
// EnvLogFormat log format that is defined by `--logformat` option
|
|
|
|
|
EnvLogFormat = "ARGOCD_LOG_FORMAT"
|
|
|
|
|
// EnvLogLevel log level that is defined by `--loglevel` option
|
|
|
|
|
EnvLogLevel = "ARGOCD_LOG_LEVEL"
|
2018-02-27 11:08:19 +00:00
|
|
|
)
|
2019-02-13 23:20:40 +00:00
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
// MinClientVersion is the minimum client version that can interface with this API server.
|
|
|
|
|
// When introducing breaking changes to the API or datastructures, this number should be bumped.
|
|
|
|
|
// The value here may be lower than the current value in VERSION
|
2020-04-15 21:17:24 +00:00
|
|
|
MinClientVersion = "1.4.0"
|
2019-02-13 23:20:40 +00:00
|
|
|
// CacheVersion is a objects version cached using util/cache/cache.go.
|
|
|
|
|
// Number should be bumped in case of backward incompatible change to make sure cache is invalidated after upgrade.
|
2020-12-03 18:24:47 +00:00
|
|
|
CacheVersion = "1.8.3"
|
2019-02-13 23:20:40 +00:00
|
|
|
)
|
2020-03-18 10:28:31 +00:00
|
|
|
|
2020-06-22 16:21:53 +00:00
|
|
|
// GetGnuPGHomePath retrieves the path to use for GnuPG home directory, which is either taken from GNUPGHOME environment or a default value
|
|
|
|
|
func GetGnuPGHomePath() string {
|
|
|
|
|
if gnuPgHome := os.Getenv(EnvGnuPGHome); gnuPgHome == "" {
|
|
|
|
|
return DefaultGnuPgHomePath
|
|
|
|
|
} else {
|
|
|
|
|
return gnuPgHome
|
|
|
|
|
}
|
|
|
|
|
}
|