Documentation ¶
Index ¶
- Constants
- func NewProxy(targetURL string, config ProxyConfig) (*httputil.ReverseProxy, error)
- type ApplicationGetter
- type BackendConfig
- type ClusterConfig
- type DefaultApplicationGetter
- type DefaultProjectGetter
- type DefaultSettingsGetter
- type ExtensionConfig
- type ExtensionConfigs
- type Manager
- type ProjectGetter
- type ProxyConfig
- type ProxyKey
- type ProxyRegistry
- type RbacEnforcer
- type RequestResources
- type ServiceConfig
- type SettingsGetter
Constants ¶
const ( URLPrefix = "/extensions" DefaultConnectionTimeout = 2 * time.Second DefaultKeepAlive = 15 * time.Second DefaultIdleConnectionTimeout = 60 * time.Second DefaultMaxIdleConnections = 30 // HeaderArgoCDApplicationName defines the name of the // expected application header to be passed to the extension // handler. The header value must follow the format: // "<namespace>:<app-name>" // Example: // Argocd-Application-Name: "namespace:app-name" HeaderArgoCDApplicationName = "Argocd-Application-Name" // HeaderArgoCDProjectName defines the name of the expected // project header to be passed to the extension handler. // Example: // Argocd-Project-Name: "default" HeaderArgoCDProjectName = "Argocd-Project-Name" )
Variables ¶
This section is empty.
Functions ¶
func NewProxy ¶
func NewProxy(targetURL string, config ProxyConfig) (*httputil.ReverseProxy, error)
NewProxy will instantiate a new reverse proxy based on the provided targetURL and config.
Types ¶
type ApplicationGetter ¶
type ApplicationGetter interface {
Get(ns, name string) (*v1alpha1.Application, error)
}
ApplicationGetter defines the contract to retrieve the application resource.
type BackendConfig ¶
type BackendConfig struct { ProxyConfig Services []ServiceConfig `json:"services"` }
BackendConfig defines the backend service configurations that will be used by an specific extension. An extension can have multiple services associated. This is necessary when Argo CD is managing applications in external clusters. In this case, each cluster may have its own backend service.
type ClusterConfig ¶ added in v2.7.0
type DefaultApplicationGetter ¶
type DefaultApplicationGetter struct {
// contains filtered or unexported fields
}
DefaultApplicationGetter is the real application getter implementation.
func NewDefaultApplicationGetter ¶
func NewDefaultApplicationGetter(al applisters.ApplicationLister) *DefaultApplicationGetter
NewDefaultApplicationGetter returns the default application getter.
func (*DefaultApplicationGetter) Get ¶
func (a *DefaultApplicationGetter) Get(ns, name string) (*v1alpha1.Application, error)
Get will retrieve the application resorce for the given namespace and name.
type DefaultProjectGetter ¶ added in v2.7.0
type DefaultProjectGetter struct {
// contains filtered or unexported fields
}
DefaultProjectGetter is the real ProjectGetter implementation.
func NewDefaultProjectGetter ¶ added in v2.7.0
func NewDefaultProjectGetter(lister applisters.AppProjectNamespaceLister, db db.ArgoDB) *DefaultProjectGetter
NewDefaultProjectGetter returns a new default project getter
func (*DefaultProjectGetter) Get ¶ added in v2.7.0
func (p *DefaultProjectGetter) Get(name string) (*v1alpha1.AppProject, error)
Get will retrieve the live AppProject state.
func (*DefaultProjectGetter) GetClusters ¶ added in v2.7.0
func (p *DefaultProjectGetter) GetClusters(project string) ([]*v1alpha1.Cluster, error)
GetClusters will retrieve the clusters configured by a project.
type DefaultSettingsGetter ¶
type DefaultSettingsGetter struct {
// contains filtered or unexported fields
}
DefaultSettingsGetter is the real settings getter implementation.
func NewDefaultSettingsGetter ¶
func NewDefaultSettingsGetter(mgr *settings.SettingsManager) *DefaultSettingsGetter
NewDefaultSettingsGetter returns a new default settings getter.
func (*DefaultSettingsGetter) Get ¶
func (s *DefaultSettingsGetter) Get() (*settings.ArgoCDSettings, error)
Get will retrieve the Argo CD settings.
type ExtensionConfig ¶
type ExtensionConfig struct { // Name defines the endpoint that will be used to register // the extension route. Mandatory field. Name string `json:"name"` Backend BackendConfig `json:"backend"` }
ExtensionConfig defines the configuration for one extension.
type ExtensionConfigs ¶
type ExtensionConfigs struct {
Extensions []ExtensionConfig `json:"extensions"`
}
ExtensionConfigs defines the configurations for all extensions retrieved from Argo CD configmap (argocd-cm).
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the object that will be responsible for registering and handling proxy extensions.
func NewManager ¶
func NewManager(log *log.Entry, sg SettingsGetter, ag ApplicationGetter, pg ProjectGetter, rbac RbacEnforcer) *Manager
NewManager will initialize a new manager.
func (*Manager) CallExtension ¶
func (m *Manager) CallExtension(extName string, registry ProxyRegistry) func(http.ResponseWriter, *http.Request)
CallExtension returns a handler func responsible for forwarding requests to the extension service. The request will be sanitized by removing sensitive headers.
type ProjectGetter ¶ added in v2.7.0
type ProjectGetter interface { Get(name string) (*v1alpha1.AppProject, error) GetClusters(project string) ([]*v1alpha1.Cluster, error) }
ProjectGetter defines the contract to retrieve Argo CD Project.
type ProxyConfig ¶
type ProxyConfig struct { // ConnectionTimeout is the maximum amount of time a dial to // the extension server will wait for a connect to complete. // Default: 2 seconds ConnectionTimeout time.Duration `json:"connectionTimeout"` // KeepAlive specifies the interval between keep-alive probes // for an active network connection between the API server and // the extension server. // Default: 15 seconds KeepAlive time.Duration `json:"keepAlive"` // IdleConnectionTimeout is the maximum amount of time an idle // (keep-alive) connection between the API server and the extension // server will remain idle before closing itself. // Default: 60 seconds IdleConnectionTimeout time.Duration `json:"idleConnectionTimeout"` // MaxIdleConnections controls the maximum number of idle (keep-alive) // connections between the API server and the extension server. // Default: 30 MaxIdleConnections int `json:"maxIdleConnections"` }
ProxyConfig allows configuring connection behaviour between Argo CD API Server and the backend service.
type ProxyKey ¶ added in v2.7.0
type ProxyKey struct {
// contains filtered or unexported fields
}
ProxyKey defines the struct used as a key in the proxy registry map (ProxyRegistry).
type ProxyRegistry ¶ added in v2.7.0
type ProxyRegistry map[ProxyKey]*httputil.ReverseProxy
ProxyRegistry is an in memory registry that contains all proxies for a given extension. Different extensions will have independent proxy registries. This is required to address the use case when one extension is configured with multiple backend services in different clusters.
func NewProxyRegistry ¶ added in v2.7.0
func NewProxyRegistry() ProxyRegistry
NewProxyRegistry will instantiate a new in memory registry for proxies.
type RbacEnforcer ¶ added in v2.7.0
type RbacEnforcer interface {
EnforceErr(rvals ...interface{}) error
}
RbacEnforcer defines the contract to enforce rbac rules
type RequestResources ¶ added in v2.7.0
type RequestResources struct { ApplicationName string ApplicationNamespace string ProjectName string }
RequestResources defines the authorization scope for an incoming request to a given extension. This struct is populated from pre-defined Argo CD headers.
func ValidateHeaders ¶ added in v2.7.0
func ValidateHeaders(r *http.Request) (*RequestResources, error)
ValidateHeaders will validate the pre-defined Argo CD request headers for extensions and extract the resources information populating and returning a RequestResources object. The pre-defined headers are: - Argocd-Application-Name - Argocd-Project-Name
The headers expected format is documented in each of the constant types defined for them.
type ServiceConfig ¶
type ServiceConfig struct { // URL is the address where the extension backend must be available. // Mandatory field. URL string `json:"url"` // Cluster if provided, will have to match the application // destination name to have requests properly forwarded to this // service URL. Cluster *ClusterConfig `json:"cluster,omitempty"` }
ServiceConfig provides the configuration for a backend service.
type SettingsGetter ¶
type SettingsGetter interface {
Get() (*settings.ArgoCDSettings, error)
}
SettingsGetter defines the contract to retrieve Argo CD Settings.