settings

package
v1.8.8 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ClusterCacheByURLIndexer indexes clusters by server URL
	ClusterCacheByURLIndexer = "byClusterURL"
	// ClusterCacheByNameIndexer indexes clusters by name
	ClusterCacheByNameIndexer = "byClusterName"
	// ClusterCacheByProjectIndexer indexes clusters by project
	ClusterCacheByProjectIndexer = "byProjectCluster"
)
View Source
const (

	// ApplicationDeepLinks is the application deep link key
	ApplicationDeepLinks = "application.links"
	// ProjectDeepLinks is the project deep link key
	ProjectDeepLinks = "project.links"
	// ResourceDeepLinks is the resource deep link key
	ResourceDeepLinks = "resource.links"

	// RespectRBAC is the key to configure cd to respect rbac while watching for resources
	RespectRBAC            = "resource.respectRBAC"
	RespectRBACValueStrict = "strict"
	RespectRBACValueNormal = "normal"
)

Variables

View Source
var (
	ByProjectRepoIndexer      = "byProjectRepo"
	ByProjectRepoWriteIndexer = "byProjectRepoWrite"
)
View Source
var CommitMessageTemplate = `` /* 340-byte string literal not displayed */
View Source
var DefaultManifestHydrationReadmeTemplate = `# Manifest Hydration

To hydrate the manifests in this repository, run the following commands:

` + "```shell" + `
git clone {{ .RepoURL }}
# cd into the cloned directory
git checkout {{ .DrySHA }}
{{ range $command := .Commands -}}
{{ $command }}
{{ end -}}` + "```" + `
{{ if .References -}}

## References

{{ range $ref := .References -}}
{{ if $ref.Commit -}}
* [{{ $ref.Commit.SHA | mustRegexFind "[0-9a-f]+" | trunc 7 }}]({{ $ref.Commit.RepoURL }}): {{ $ref.Commit.Subject }} ({{ $ref.Commit.Author }})
{{ end -}}
{{ end -}}
{{ end -}}`

Functions

func ConfigureGoClientFeatures added in v1.8.8

func ConfigureGoClientFeatures()

FIXME: remove when we have proper WatchListClient and InOrderInformers support

func DeriveServiceAccountToImpersonate added in v1.8.8

func DeriveServiceAccountToImpersonate(project *v1alpha1.AppProject, application *v1alpha1.Application, destCluster *v1alpha1.Cluster) (string, error)

DeriveServiceAccountToImpersonate determines the service account to be used for impersonation for the sync operation. The returned service account will be fully qualified including namespace and the service account name in the format system:serviceaccount:<namespace>:<service_account>

func EscapeDollarSignsInConnectorConfig added in v1.8.8

func EscapeDollarSignsInConnectorConfig(obj map[string]any, secretValues map[string]string) map[string]any

EscapeDollarSignsInConnectorConfig escapes dollar signs in string values, ONLY if they are resolved from the secrets map. This skips unresolved environment variable references from being escaped. It protects resolved secret values from Dex's os.ExpandEnv expansion.

func GetKustomizeBinaryPath added in v1.8.8

func GetKustomizeBinaryPath(ks *v1alpha1.KustomizeOptions, source v1alpha1.ApplicationSource) (string, error)

GetKustomizeBinaryPath returns the path to the kustomize binary based on the provided KustomizeOptions and ApplicationSource.

func ReplaceMapSecrets added in v1.8.8

func ReplaceMapSecrets(obj map[string]any, secretValues map[string]string) map[string]any

ReplaceMapSecrets takes a json object and recursively looks for any secret key references in the object and replaces the value with the secret value

func ReplaceStringSecret added in v0.11.0

func ReplaceStringSecret(val string, secretValues map[string]string) string

ReplaceStringSecret checks if given string is a secret key reference ( starts with $ ) and returns corresponding value from provided map

func UnmarshalDexConfig added in v1.5.3

func UnmarshalDexConfig(config string) (map[string]any, error)

func ValidateAzureGraphAPIEndpoint added in v1.8.8

func ValidateAzureGraphAPIEndpoint(endpoint string) error

ValidateAzureGraphAPIEndpoint returns an error if endpoint is not a trusted Microsoft Graph API URL. A valid endpoint must use the https scheme and a known Microsoft Graph hostname.

func ValidateExternalURL added in v1.8.8

func ValidateExternalURL(u string) error

ValidateExternalURL ensures the external URL that is set on the configmap is valid

func ValidateOIDCConfig added in v1.8.8

func ValidateOIDCConfig(configStr string) error

Types

type Account added in v1.5.0

type Account struct {
	PasswordHash  string
	PasswordMtime *time.Time
	Enabled       bool
	Capabilities  []AccountCapability
	Tokens        []Token
}

Account holds local account information

func (*Account) FormatCapabilities added in v1.5.0

func (a *Account) FormatCapabilities() string

FormatCapabilities returns comma separate list of user capabilities.

func (*Account) FormatPasswordMtime added in v1.5.0

func (a *Account) FormatPasswordMtime() string

FormatPasswordMtime return the formatted password modify time or empty string of password modify time is nil.

func (*Account) HasCapability added in v1.5.0

func (a *Account) HasCapability(capability AccountCapability) bool

HasCapability return true if the account has the specified capability.

func (*Account) TokenIndex added in v1.5.0

func (a *Account) TokenIndex(id string) int

TokenIndex return an index of a token with the given identifier or -1 if token not found.

type AccountCapability added in v1.5.0

type AccountCapability string
const (
	// AccountCapabilityLogin represents capability to create UI session tokens.
	AccountCapabilityLogin AccountCapability = "login"
	// AccountCapabilityLogin represents capability to generate API auth tokens.
	AccountCapabilityApiKey AccountCapability = "apiKey" //nolint:revive //FIXME(var-naming)
)

type AzureOIDCConfig added in v1.8.8

type AzureOIDCConfig struct {
	UseWorkloadIdentity                  bool   `json:"useWorkloadIdentity,omitempty"`
	EnableUserGroupOverageClaim          bool   `json:"enableUserGroupOverageClaim,omitempty"`
	GraphAPIEndpoint                     string `json:"graphApiEndpoint,omitempty"`
	UserGroupOverageClaimCacheExpiration string `json:"userGroupOverageClaimCacheExpiration,omitempty"`
}

type ClusterInformer added in v1.8.8

type ClusterInformer struct {
	cache.SharedIndexInformer
}

ClusterInformer provides a cached view of cluster secrets as Cluster objects. It uses an informer with a transform function to convert Secret -> Cluster once during ingestion, avoiding repeated conversions.

This eliminates the performance cost of calling SecretToCluster on every GetCluster/GetClusterServersByName call, which can be significant in hot paths.

func NewClusterInformer added in v1.8.8

func NewClusterInformer(clientset kubernetes.Interface, namespace string) (*ClusterInformer, error)

NewClusterInformer creates a new cluster cache that watches cluster secrets and stores them as pre-converted Cluster objects using informer transforms.

The transform function runs once per secret during informer ingestion, converting Secret -> Cluster at that time. This means: - Zero conversion overhead on reads (already converted) - Same freshness guarantees as regular informers - Automatic updates when secrets change

func (*ClusterInformer) GetAvailableProjectClusters added in v1.8.8

func (cc *ClusterInformer) GetAvailableProjectClusters(project string) ([]*appv1.Cluster, error)

GetAvailableProjectClusters is like GetProjectClusters but skips malformed entries instead of returning an error, for callers that prefer partial results.

func (*ClusterInformer) GetClusterByURL added in v1.8.8

func (cc *ClusterInformer) GetClusterByURL(url string) (*appv1.Cluster, error)

GetClusterByURL retrieves a cluster by its server URL from the cache. Returns the pre-converted Cluster object with zero conversion overhead.

func (*ClusterInformer) GetClusterServersByName added in v1.8.8

func (cc *ClusterInformer) GetClusterServersByName(name string) ([]string, error)

GetClusterServersByName retrieves all server URLs for clusters with the given name.

func (*ClusterInformer) GetProjectClusters added in v1.8.8

func (cc *ClusterInformer) GetProjectClusters(project string) ([]*appv1.Cluster, error)

func (*ClusterInformer) ListAvailableClusters added in v1.8.8

func (cc *ClusterInformer) ListAvailableClusters() ([]*appv1.Cluster, error)

ListAvailableClusters is like ListClusters but skips malformed entries instead of returning an error, for callers that prefer partial results.

func (*ClusterInformer) ListClusters added in v1.8.8

func (cc *ClusterInformer) ListClusters() ([]*appv1.Cluster, error)

ListClusters returns all clusters in the cache. Returns an error if any item in the cache is not a *Cluster (indicates transform failure).

type DeepLink struct {
	// URL that the deep link will redirect to
	URL string `json:"url"`
	// Title that will be displayed in the UI corresponding to that link
	Title string `json:"title"`
	// Description (optional) a description for what the deep link is about
	Description *string `json:"description,omitempty"`
	// IconClass (optional) a font-awesome icon class to be used when displaying the links in dropdown menus.
	IconClass *string `json:"icon.class,omitempty"`
	// Condition (optional) a conditional statement depending on which the deep link shall be rendered
	Condition *string `json:"if,omitempty"`
}

DeepLink structure

type DiffOptions added in v1.8.8

type DiffOptions struct {
	IgnoreAggregatedRoles bool `json:"ignoreAggregatedRoles,omitempty"`

	// If set to true then differences caused by status are ignored.
	IgnoreResourceStatusField IgnoreStatus `json:"ignoreResourceStatusField,omitempty"`

	// If set to true then ignoreDifferences are applied to ignore application refresh on resource updates.
	IgnoreDifferencesOnResourceUpdates bool `json:"ignoreDifferencesOnResourceUpdates,omitempty"`
}

func GetDefaultDiffOptions added in v1.8.8

func GetDefaultDiffOptions() DiffOptions

type FilteredResource added in v1.0.0

type FilteredResource struct {
	APIGroups []string `json:"apiGroups,omitempty"`
	Kinds     []string `json:"kinds,omitempty"`
	Clusters  []string `json:"clusters,omitempty"`
}

func (FilteredResource) Match added in v1.0.0

func (r FilteredResource) Match(apiGroup, kind, cluster string) bool

func (FilteredResource) MatchCluster added in v1.8.8

func (r FilteredResource) MatchCluster(cluster string) bool

type GlobalProjectSettings added in v1.8.8

type GlobalProjectSettings struct {
	ProjectName   string               `json:"projectName,omitempty"`
	LabelSelector metav1.LabelSelector `json:"labelSelector,omitempty"`
}

type GoogleAnalytics added in v1.2.0

type GoogleAnalytics struct {
	TrackingID     string `json:"trackingID,omitempty"`
	AnonymizeUsers bool   `json:"anonymizeUsers,omitempty"`
}

type Help added in v1.2.0

type Help struct {
	// the URL for getting chat help, this will typically be your Slack channel for support
	ChatURL string `json:"chatUrl,omitempty"`
	// the text for getting chat help, defaults to "Chat now!"
	ChatText string `json:"chatText,omitempty"`
	// the URLs for downloading cd binaries
	BinaryURLs map[string]string `json:"binaryUrl,omitempty"`
}

Help settings

type IgnoreStatus added in v1.8.8

type IgnoreStatus string
const (
	// IgnoreResourceStatusInCRD ignores status changes for all CRDs
	IgnoreResourceStatusInCRD IgnoreStatus = "crd"
	// IgnoreResourceStatusInAll ignores status changes for all resources
	IgnoreResourceStatusInAll IgnoreStatus = "all"
	// IgnoreResourceStatusInNone ignores status changes for no resources
	IgnoreResourceStatusInNone IgnoreStatus = "none"
)

type KustomizeVersionNotRegisteredError added in v1.8.8

type KustomizeVersionNotRegisteredError struct {
	// Version is the Kustomize version that is not registered
	Version string
}

KustomizeVersionNotRegisteredError is an error type that indicates a requested Kustomize version is not registered in the Kustomize options in cd-cm.

func (KustomizeVersionNotRegisteredError) Error added in v1.8.8

type OIDCConfig added in v0.11.0

type OIDCConfig struct {
	Name                     string                 `json:"name,omitempty"`
	Issuer                   string                 `json:"issuer,omitempty"`
	ClientID                 string                 `json:"clientID,omitempty"`
	ClientSecret             string                 `json:"clientSecret,omitempty"`
	CLIClientID              string                 `json:"cliClientID,omitempty"`
	EnableUserInfoGroups     bool                   `json:"enableUserInfoGroups,omitempty"`
	UserInfoBaseURL          string                 `json:"userInfoBaseURL,omitempty"` // the URL (without path) where the userinfo endpoint is located
	UserInfoPath             string                 `json:"userInfoPath,omitempty"`
	UserInfoCacheExpiration  string                 `json:"userInfoCacheExpiration,omitempty"`
	RequestedScopes          []string               `json:"requestedScopes,omitempty"`
	RequestedIDTokenClaims   map[string]*oidc.Claim `json:"requestedIDTokenClaims,omitempty"`
	LogoutURL                string                 `json:"logoutURL,omitempty"`
	RootCA                   string                 `json:"rootCA,omitempty"`
	EnablePKCEAuthentication bool                   `json:"enablePKCEAuthentication,omitempty"`
	DomainHint               string                 `json:"domainHint,omitempty"`
	Azure                    *AzureOIDCConfig       `json:"azure,omitempty"`
	RefreshTokenThreshold    string                 `json:"refreshTokenThreshold,omitempty"`
}

type Repository added in v1.4.0

type Repository struct {
	// The URL to the repository
	URL string `json:"url,omitempty"`
	// the type of the repo, "git" or "helm", assumed to be "git" if empty or absent
	Type string `json:"type,omitempty"`
	// helm only
	Name string `json:"name,omitempty"`
	// Name of the secret storing the username used to access the repo
	UsernameSecret *corev1.SecretKeySelector `json:"usernameSecret,omitempty"`
	// Name of the secret storing the password used to access the repo
	PasswordSecret *corev1.SecretKeySelector `json:"passwordSecret,omitempty"`
	// Name of the secret storing the SSH private key used to access the repo. Git only
	SSHPrivateKeySecret *corev1.SecretKeySelector `json:"sshPrivateKeySecret,omitempty"`
	// Whether to connect the repository in an insecure way (deprecated)
	InsecureIgnoreHostKey bool `json:"insecureIgnoreHostKey,omitempty"`
	// Whether to connect the repository in an insecure way
	Insecure bool `json:"insecure,omitempty"`
	// Whether the repo is git-lfs enabled. Git only.
	EnableLFS bool `json:"enableLfs,omitempty"`
	// Name of the secret storing the TLS client cert data
	TLSClientCertDataSecret *corev1.SecretKeySelector `json:"tlsClientCertDataSecret,omitempty"`
	// Name of the secret storing the TLS client cert's key data
	TLSClientCertKeySecret *corev1.SecretKeySelector `json:"tlsClientCertKeySecret,omitempty"`
	// Whether the repo is helm-oci enabled. Git only.
	EnableOci bool `json:"enableOci,omitempty"`
	// Github App Private Key PEM data
	GithubAppPrivateKeySecret *corev1.SecretKeySelector `json:"githubAppPrivateKeySecret,omitempty"`
	// Github App ID of the app used to access the repo
	GithubAppId int64 `json:"githubAppID,omitempty"`
	// Github App Installation ID of the installed GitHub App
	GithubAppInstallationId int64 `json:"githubAppInstallationID,omitempty"`
	// Github App Enterprise base url if empty will default to https://api.github.com
	GithubAppEnterpriseBaseURL string `json:"githubAppEnterpriseBaseUrl,omitempty"`
	// Proxy specifies the HTTP/HTTPS proxy used to access the repo
	Proxy string `json:"proxy,omitempty"`
	// NoProxy specifies a list of targets where the proxy isn't used, applies only in cases where the proxy is applied
	NoProxy string `json:"noProxy,omitempty"`
	// GCPServiceAccountKey specifies the service account key in JSON format to be used for getting credentials to Google Cloud Source repos
	GCPServiceAccountKey *corev1.SecretKeySelector `json:"gcpServiceAccountKey,omitempty"`
	// ForceHttpBasicAuth determines whether Hanzo CD should force use of basic auth for HTTP connected repositories
	ForceHttpBasicAuth bool `json:"forceHttpBasicAuth,omitempty"` //nolint:revive //FIXME(var-naming)
	// UseAzureWorkloadIdentity specifies whether to use Azure Workload Identity for authentication
	UseAzureWorkloadIdentity bool `json:"useAzureWorkloadIdentity,omitempty"`
	// AzureActiveDirectoryEndpoint specifies the Azure Active Directory endpoint used for Service Principal authentication. If empty will default to https://login.microsoftonline.com
	AzureActiveDirectoryEndpoint string `json:"azureActiveDirectoryEndpoint,omitempty"`
	// AzureServicePrincipalClientId specifies the client ID of the Azure Service Principal used to access the repo
	AzureServicePrincipalClientId string `json:"azureServicePrincipalClientId,omitempty"`
	// AzureServicePrincipalClientSecret specifies the client secret of the Azure Service Principal used to access the repo
	AzureServicePrincipalClientSecret string `json:"azureServicePrincipalClientSecret,omitempty"`
	// AzureServicePrincipalTenantId specifies the tenant ID of the Azure Service Principal used to access the repo
	AzureServicePrincipalTenantId string `json:"azureServicePrincipalTenantId,omitempty"`
}

Credentials for accessing a Git repository

type RepositoryCredentials added in v1.4.0

type RepositoryCredentials struct {
	// The URL pattern the repository URL has to match
	URL string `json:"url,omitempty"`
	// Name of the secret storing the username used to access the repo
	UsernameSecret *corev1.SecretKeySelector `json:"usernameSecret,omitempty"`
	// Name of the secret storing the password used to access the repo
	PasswordSecret *corev1.SecretKeySelector `json:"passwordSecret,omitempty"`
	// Name of the secret storing the SSH private key used to access the repo. Git only
	SSHPrivateKeySecret *corev1.SecretKeySelector `json:"sshPrivateKeySecret,omitempty"`
	// Name of the secret storing the TLS client cert data
	TLSClientCertDataSecret *corev1.SecretKeySelector `json:"tlsClientCertDataSecret,omitempty"`
	// Name of the secret storing the TLS client cert's key data
	TLSClientCertKeySecret *corev1.SecretKeySelector `json:"tlsClientCertKeySecret,omitempty"`
	// Github App Private Key PEM data
	GithubAppPrivateKeySecret *corev1.SecretKeySelector `json:"githubAppPrivateKeySecret,omitempty"`
	// Github App ID of the app used to access the repo
	GithubAppId int64 `json:"githubAppID,omitempty"`
	// Github App Installation ID of the installed GitHub App
	GithubAppInstallationId int64 `json:"githubAppInstallationID,omitempty"`
	// Github App Enterprise base url if empty will default to https://api.github.com
	GithubAppEnterpriseBaseURL string `json:"githubAppEnterpriseBaseUrl,omitempty"`
	// EnableOCI specifies whether helm-oci support should be enabled for this repo
	EnableOCI bool `json:"enableOCI,omitempty"`
	// the type of the repositoryCredentials, "git" or "helm", assumed to be "git" if empty or absent
	Type string `json:"type,omitempty"`
	// GCPServiceAccountKey specifies the service account key in JSON format to be used for getting credentials to Google Cloud Source repos
	GCPServiceAccountKey *corev1.SecretKeySelector `json:"gcpServiceAccountKey,omitempty"`
	// ForceHttpBasicAuth determines whether Hanzo CD should force use of basic auth for HTTP connected repositories
	ForceHttpBasicAuth bool `json:"forceHttpBasicAuth,omitempty"` //nolint:revive //FIXME(var-naming)
	// UseAzureWorkloadIdentity specifies whether to use Azure Workload Identity for authentication
	UseAzureWorkloadIdentity bool `json:"useAzureWorkloadIdentity,omitempty"`
	// AzureActiveDirectoryEndpoint specifies the Azure Active Directory endpoint used for Service Principal authentication. If empty will default to https://login.microsoftonline.com
	AzureActiveDirectoryEndpoint string `json:"azureActiveDirectoryEndpoint,omitempty"`
	// AzureServicePrincipalClientId specifies the client ID of the Azure Service Principal used to access the repo
	AzureServicePrincipalClientId string `json:"azureServicePrincipalClientId,omitempty"`
	// AzureServicePrincipalClientSecret specifies the client secret of the Azure Service Principal used to access the repo
	AzureServicePrincipalClientSecret string `json:"azureServicePrincipalClientSecret,omitempty"`
	// AzureServicePrincipalTenantId specifies the tenant ID of the Azure Service Principal used to access the repo
	AzureServicePrincipalTenantId string `json:"azureServicePrincipalTenantId,omitempty"`
}

Credential template for accessing repositories

type ResourcesFilter added in v1.2.0

type ResourcesFilter struct {
	// ResourceExclusions holds the api groups, kinds per cluster to exclude from Hanzo CD's watch
	ResourceExclusions []FilteredResource
	// ResourceInclusions holds the only api groups, kinds per cluster that Hanzo CD will watch
	ResourceInclusions []FilteredResource
}

func (*ResourcesFilter) IsExcludedResource added in v1.2.0

func (rf *ResourcesFilter) IsExcludedResource(apiGroup, kind, cluster string) bool

Behavior of this function is as follows: +-------------+-------------+-------------+ | Inclusions | Exclusions | Result | +-------------+-------------+-------------+ | Empty | Empty | Allowed | +-------------+-------------+-------------+ | Present | Empty | Allowed | +-------------+-------------+-------------+ | Not Present | Empty | Not Allowed | +-------------+-------------+-------------+ | Empty | Present | Not Allowed | +-------------+-------------+-------------+ | Empty | Not Present | Allowed | +-------------+-------------+-------------+ | Present | Not Present | Allowed | +-------------+-------------+-------------+ | Not Present | Present | Not Allowed | +-------------+-------------+-------------+ | Not Present | Not Present | Not Allowed | +-------------+-------------+-------------+ | Present | Present | Not Allowed | +-------------+-------------+-------------+

type Settings added in v1.8.8

type Settings struct {
	// URL is the externally facing URL users will visit to reach Hanzo CD.
	// The value here is used when configuring SSO. Omitting this value will disable SSO.
	URL string `json:"url,omitempty"`
	// URLs is a list of externally facing URLs users will visit to reach Hanzo CD.
	// The value here is used when configuring SSO reachable from multiple domains.
	AdditionalURLs []string `json:"additionalUrls,omitempty"`
	// Indicates if status badge is enabled or not.
	StatusBadgeEnabled bool `json:"statusBadgeEnable"`
	// Indicates if status badge custom root URL should be used.
	StatusBadgeRootUrl string `json:"statusBadgeRootUrl,omitempty"` //nolint:revive //FIXME(var-naming)
	// DexConfig contains portions of a dex config yaml
	DexConfig string `json:"dexConfig,omitempty"`
	// OIDCConfigRAW holds OIDC configuration as a raw string
	OIDCConfigRAW string `json:"oidcConfig,omitempty"`
	// ServerSignature holds the key used to generate JWT tokens.
	ServerSignature []byte `json:"serverSignature,omitempty"`
	// Certificate holds the certificate/private key for the Hanzo CD API server.
	// If nil, will run insecure without TLS.
	Certificate *tls.Certificate `json:"-"`
	// CertificateIsExternal indicates whether Certificate was loaded from external secret
	CertificateIsExternal bool `json:"-"`
	// WebhookGitLabSecret holds the shared secret for authenticating GitHub webhook events
	WebhookGitHubSecret string `json:"webhookGitHubSecret,omitempty"`
	// WebhookGitLabSecret holds the shared secret for authenticating GitLab webhook events
	WebhookGitLabSecret string `json:"webhookGitLabSecret,omitempty"`
	// WebhookBitbucketUUID holds the UUID for authenticating Bitbucket webhook events
	WebhookBitbucketUUID string `json:"webhookBitbucketUUID,omitempty"`
	// WebhookBitbucketServerSecret holds the shared secret for authenticating BitbucketServer webhook events
	WebhookBitbucketServerSecret string `json:"webhookBitbucketServerSecret,omitempty"`
	// WebhookGogsSecret holds the shared secret for authenticating Gogs webhook events
	WebhookGogsSecret string `json:"webhookGogsSecret,omitempty"`
	// WebhookAzureDevOpsUsername holds the username for authenticating Azure DevOps webhook events
	WebhookAzureDevOpsUsername string `json:"webhookAzureDevOpsUsername,omitempty"`
	// WebhookAzureDevOpsPassword holds the password for authenticating Azure DevOps webhook events
	WebhookAzureDevOpsPassword string `json:"webhookAzureDevOpsPassword,omitempty"`
	// Secrets holds all secrets in cd-secret as a map[string]string
	Secrets map[string]string `json:"secrets,omitempty"`
	// KustomizeBuildOptions is a string of kustomize build parameters
	KustomizeBuildOptions string `json:"kustomizeBuildOptions,omitempty"`
	// Indicates if anonymous user is enabled or not
	AnonymousUserEnabled bool `json:"anonymousUserEnabled,omitempty"`
	// Specifies token expiration duration
	UserSessionDuration time.Duration `json:"userSessionDuration,omitempty"`
	// UiCssURL local or remote path to user-defined CSS to customize Hanzo CD UI
	UiCssURL string `json:"uiCssURL,omitempty"` //nolint:revive //FIXME(var-naming)
	// Content of UI Banner
	UiBannerContent string `json:"uiBannerContent,omitempty"` //nolint:revive //FIXME(var-naming)
	// URL for UI Banner
	UiBannerURL string `json:"uiBannerURL,omitempty"` //nolint:revive //FIXME(var-naming)
	// Make Banner permanent and not closeable
	UiBannerPermanent bool `json:"uiBannerPermanent,omitempty"` //nolint:revive //FIXME(var-naming)
	// Position of UI Banner
	UiBannerPosition string `json:"uiBannerPosition,omitempty"` //nolint:revive //FIXME(var-naming)
	// UiLoginButtonText is an optional override for the SSO login button label
	UiLoginButtonText string `json:"uiLoginButtonText,omitempty"` //nolint:revive //FIXME(var-naming)
	// PasswordPattern for password regular expression
	PasswordPattern string `json:"passwordPattern,omitempty"`
	// BinaryUrls contains the URLs for downloading cd binaries
	BinaryUrls map[string]string `json:"binaryUrls,omitempty"`
	// ServerRBACLogEnforceEnable temporary var indicates whether rbac will be enforced on logs
	ServerRBACLogEnforceEnable bool `json:"serverRBACLogEnforceEnable"`
	// MaxPodLogsToRender the maximum number of pod logs to render
	MaxPodLogsToRender int64 `json:"maxPodLogsToRender"`
	// ExecEnabled indicates whether the UI exec feature is enabled
	ExecEnabled bool `json:"execEnabled"`
	// ExecShells restricts which shells are allowed for `exec` and in which order they are tried
	ExecShells []string `json:"execShells"`
	// TrackingMethod defines the resource tracking method to be used
	TrackingMethod string `json:"application.resourceTrackingMethod,omitempty"`
	// OIDCTLSInsecureSkipVerify determines whether certificate verification is skipped when verifying tokens with the
	// configured OIDC provider (either external or the bundled Dex instance). Setting this to `true` will cause JWT
	// token verification to pass despite the OIDC provider having an invalid certificate. Only set to `true` if you
	// understand the risks.
	OIDCTLSInsecureSkipVerify bool `json:"oidcTLSInsecureSkipVerify"`
	// AppsInAnyNamespaceEnabled indicates whether applications are allowed to be created in any namespace
	AppsInAnyNamespaceEnabled bool `json:"appsInAnyNamespaceEnabled"`
	// ExtensionConfig configurations related to Hanzo CD proxy extensions. The keys are the extension name.
	// The value is a yaml string defined in extension.ExtensionConfigs struct.
	ExtensionConfig map[string]string `json:"extensionConfig,omitempty"`
	// ImpersonationEnabled indicates whether Application sync privileges can be decoupled from control plane
	// privileges using impersonation
	ImpersonationEnabled bool `json:"impersonationEnabled"`
	// RequireOverridePrivilegeForRevisionSync indicates whether giving an external revision during snyc is considered an override.
	// Up to revision 3.2, this was always false. It is now still false by default, in order to not breaking existing usage.
	RequireOverridePrivilegeForRevisionSync bool `json:"requireOverridePrivilegeForRevisionSync"`
}

Settings holds in-memory runtime configuration options.

func (*Settings) AzureGraphAPIEndpoint added in v1.8.8

func (a *Settings) AzureGraphAPIEndpoint() string

AzureGraphAPIEndpoint returns the Microsoft Graph API endpoint URL. Defaults to https://graph.microsoft.com/v1.0 for public cloud. Can be overridden for sovereign clouds (e.g., https://graph.microsoft.us/v1.0). Returns empty string if the configured endpoint fails validation, which disables the overage feature.

func (*Settings) AzureUserGroupOverageClaimCacheExpiration added in v1.8.8

func (a *Settings) AzureUserGroupOverageClaimCacheExpiration() time.Duration

AzureUserGroupOverageClaimCacheExpiration returns the cache duration for Azure groups overage claim results.

func (*Settings) AzureUserGroupOverageClaimEnabled added in v1.8.8

func (a *Settings) AzureUserGroupOverageClaimEnabled() bool

AzureUserGroupOverageClaimEnabled returns whether group claims should be fetched from the Microsoft Graph API when Azure AD returns a groups overage claim (user has 200+ group memberships). See https://learn.microsoft.com/en-us/entra/identity-platform/access-token-claims-reference#groups-overage-claim

func (*Settings) DexOAuth2ClientSecret added in v1.8.8

func (a *Settings) DexOAuth2ClientSecret() string

DexOAuth2ClientSecret calculates an arbitrary, but predictable OAuth2 client secret string derived from the server secret. This is called by the dex startup wrapper (cd-dex rundex), as well as the API server, such that they both independently come to the same conclusion of what the OAuth2 shared client secret should be.

func (*Settings) DexRedirectURL added in v1.8.8

func (a *Settings) DexRedirectURL() (string, error)

func (*Settings) GetServerEncryptionKey added in v1.8.8

func (a *Settings) GetServerEncryptionKey() ([]byte, error)

GetServerEncryptionKey generates a new server encryption key using the server signature as a passphrase

func (*Settings) GetWebhookAzureDevOpsPassword added in v1.8.8

func (a *Settings) GetWebhookAzureDevOpsPassword() string

GetWebhookAzureDevOpsPassword returns the resolved Azure DevOps webhook password

func (*Settings) GetWebhookAzureDevOpsUsername added in v1.8.8

func (a *Settings) GetWebhookAzureDevOpsUsername() string

GetWebhookAzureDevOpsUsername returns the resolved Azure DevOps webhook username

func (*Settings) GetWebhookBitbucketServerSecret added in v1.8.8

func (a *Settings) GetWebhookBitbucketServerSecret() string

GetWebhookBitbucketServerSecret returns the resolved Bitbucket Server webhook secret

func (*Settings) GetWebhookBitbucketUUID added in v1.8.8

func (a *Settings) GetWebhookBitbucketUUID() string

GetWebhookBitbucketUUID returns the resolved Bitbucket webhook UUID

func (*Settings) GetWebhookGitHubSecret added in v1.8.8

func (a *Settings) GetWebhookGitHubSecret() string

GetWebhookGitHubSecret returns the resolved GitHub webhook secret

func (*Settings) GetWebhookGitLabSecret added in v1.8.8

func (a *Settings) GetWebhookGitLabSecret() string

GetWebhookGitLabSecret returns the resolved GitLab webhook secret

func (*Settings) GetWebhookGogsSecret added in v1.8.8

func (a *Settings) GetWebhookGogsSecret() string

GetWebhookGogsSecret returns the resolved Gogs webhook secret

func (*Settings) IsDexConfigured added in v1.8.8

func (a *Settings) IsDexConfigured() bool

func (*Settings) IsSSOConfigured added in v1.8.8

func (a *Settings) IsSSOConfigured() bool

IsSSOConfigured returns whether or not single-sign-on is configured

func (*Settings) IssuerURL added in v1.8.8

func (a *Settings) IssuerURL() string

func (*Settings) OAuth2AllowedAudiences added in v1.8.8

func (a *Settings) OAuth2AllowedAudiences() []string

OAuth2AllowedAudiences returns a list of audiences that are allowed for the OAuth2 client. If the user has not explicitly configured the list of audiences (or has configured an empty list), then the OAuth2 client ID is returned as the only allowed audience. When using the bundled Dex, that client ID is always "Hanzo CD".

func (*Settings) OAuth2ClientID added in v1.8.8

func (a *Settings) OAuth2ClientID() string

func (*Settings) OAuth2ClientSecret added in v1.8.8

func (a *Settings) OAuth2ClientSecret() string

func (*Settings) OAuth2UsePKCE added in v1.8.8

func (a *Settings) OAuth2UsePKCE() bool

func (*Settings) OIDCConfig added in v1.8.8

func (a *Settings) OIDCConfig() *OIDCConfig

func (*Settings) OIDCTLSConfig added in v1.8.8

func (a *Settings) OIDCTLSConfig() *tls.Config

OIDCTLSConfig returns the TLS config for the OIDC provider. If an external provider is configured, returns a TLS config using the root CAs (if any) specified in the OIDC config. If an external OIDC provider is not configured, returns the API server TLS config, because the API server proxies requests to Dex.

func (*Settings) RedirectAdditionalURLs added in v1.8.8

func (a *Settings) RedirectAdditionalURLs() ([]string, error)

func (*Settings) RedirectURL added in v1.8.8

func (a *Settings) RedirectURL() (string, error)

func (*Settings) RedirectURLForRequest added in v1.8.8

func (a *Settings) RedirectURLForRequest(r *http.Request) (string, error)

func (*Settings) RefreshTokenThreshold added in v1.8.8

func (a *Settings) RefreshTokenThreshold() time.Duration

RefreshTokenThreshold returns the duration before token expiration that a token should be refreshed by the server

func (*Settings) RefreshTokenThresholdWithConfig added in v1.8.8

func (a *Settings) RefreshTokenThresholdWithConfig(oidcConfig *OIDCConfig) time.Duration

RefreshTokenThresholdWithConfig takes oidcConfig as param and returns the duration before token expiration that a token should be refreshed by the server

func (*Settings) SkipAudienceCheckWhenTokenHasNoAudience added in v1.8.8

func (a *Settings) SkipAudienceCheckWhenTokenHasNoAudience() bool

func (*Settings) TLSConfig added in v1.8.8

func (a *Settings) TLSConfig() *tls.Config

TLSConfig returns a tls.Config with the configured certificates

func (*Settings) URLForRequest added in v1.8.8

func (a *Settings) URLForRequest(r *http.Request) (string, error)

func (*Settings) UseAzureWorkloadIdentity added in v1.8.8

func (a *Settings) UseAzureWorkloadIdentity() bool

func (*Settings) UserInfoBaseURL added in v1.8.8

func (a *Settings) UserInfoBaseURL() string

func (*Settings) UserInfoCacheExpiration added in v1.8.8

func (a *Settings) UserInfoCacheExpiration() time.Duration

UserInfoCacheExpiration returns the expiry time of the UserInfo cache

func (*Settings) UserInfoGroupsEnabled added in v1.8.8

func (a *Settings) UserInfoGroupsEnabled() bool

UserInfoGroupsEnabled returns whether group claims should be fetch from UserInfo endpoint

func (*Settings) UserInfoPath added in v1.8.8

func (a *Settings) UserInfoPath() string

UserInfoPath returns the sub-path on which the IDP exposes the UserInfo endpoint

type SettingsManager

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

SettingsManager holds config info for a new manager with which to access Kubernetes ConfigMaps.

func NewSettingsManager

func NewSettingsManager(ctx context.Context, clientset kubernetes.Interface, namespace string, opts ...SettingsManagerOpts) *SettingsManager

NewSettingsManager generates a new SettingsManager pointer and returns it

func (*SettingsManager) AddAccount added in v1.5.0

func (mgr *SettingsManager) AddAccount(name string, account Account) error

AddAccount save an account with the given name and properties.

func (*SettingsManager) ApplicationFineGrainedRBACInheritanceDisabled added in v1.8.8

func (mgr *SettingsManager) ApplicationFineGrainedRBACInheritanceDisabled() (bool, error)

func (*SettingsManager) GetAccount added in v1.5.0

func (mgr *SettingsManager) GetAccount(name string) (*Account, error)

GetAccount return an account info by the specified name.

func (*SettingsManager) GetAccounts added in v1.5.0

func (mgr *SettingsManager) GetAccounts() (map[string]Account, error)

GetAccounts returns list of configured accounts

func (*SettingsManager) GetAllowedNodeLabels added in v1.8.8

func (mgr *SettingsManager) GetAllowedNodeLabels() []string

func (*SettingsManager) GetAppInstanceLabelKey added in v1.2.0

func (mgr *SettingsManager) GetAppInstanceLabelKey() (string, error)

func (*SettingsManager) GetClusterInformer added in v1.8.8

func (mgr *SettingsManager) GetClusterInformer() (*ClusterInformer, error)

GetClusterInformer returns the cluster cache for optimized cluster lookups.

func (*SettingsManager) GetCommitAuthorEmail added in v1.8.8

func (mgr *SettingsManager) GetCommitAuthorEmail() (string, error)

func (*SettingsManager) GetCommitAuthorName added in v1.8.8

func (mgr *SettingsManager) GetCommitAuthorName() (string, error)

func (*SettingsManager) GetConfigMapByName added in v1.2.0

func (mgr *SettingsManager) GetConfigMapByName(configMapName string) (*corev1.ConfigMap, error)

Returns the ConfigMap with the given name from the cluster. The ConfigMap must be labeled with "app.kubernetes.io/part-of: hanzocd" in order to be retrievable.

func (mgr *SettingsManager) GetDeepLinks(deeplinkType string) ([]DeepLink, error)

func (*SettingsManager) GetEnabledSourceTypes added in v1.8.8

func (mgr *SettingsManager) GetEnabledSourceTypes() (map[string]bool, error)

func (*SettingsManager) GetExcludeEventLabelKeys added in v1.8.8

func (mgr *SettingsManager) GetExcludeEventLabelKeys() []string

func (*SettingsManager) GetGlobalProjectsSettings added in v1.8.8

func (mgr *SettingsManager) GetGlobalProjectsSettings() ([]GlobalProjectSettings, error)

GetGlobalProjectsSettings loads the global project settings from cd-cm ConfigMap

func (*SettingsManager) GetGoogleAnalytics added in v1.2.0

func (mgr *SettingsManager) GetGoogleAnalytics() (*GoogleAnalytics, error)

func (*SettingsManager) GetHelmSettings added in v1.8.8

func (mgr *SettingsManager) GetHelmSettings() (*v1alpha1.HelmOptions, error)

GetHelmSettings returns helm settings

func (*SettingsManager) GetHelp added in v1.2.0

func (mgr *SettingsManager) GetHelp() (*Help, error)

func (*SettingsManager) GetHydratorReadmeTemplate added in v1.8.8

func (mgr *SettingsManager) GetHydratorReadmeTemplate() (string, error)

func (*SettingsManager) GetIgnoreResourceUpdatesOverrides added in v1.8.8

func (mgr *SettingsManager) GetIgnoreResourceUpdatesOverrides() (map[string]v1alpha1.ResourceOverride, error)

func (*SettingsManager) GetIncludeEventLabelKeys added in v1.8.8

func (mgr *SettingsManager) GetIncludeEventLabelKeys() []string

func (*SettingsManager) GetInstallationID added in v1.8.8

func (mgr *SettingsManager) GetInstallationID() (string, error)

func (*SettingsManager) GetIsIgnoreResourceUpdatesEnabled added in v1.8.8

func (mgr *SettingsManager) GetIsIgnoreResourceUpdatesEnabled() (bool, error)

func (*SettingsManager) GetKustomizeSettings added in v1.5.3

func (mgr *SettingsManager) GetKustomizeSettings() (*v1alpha1.KustomizeOptions, error)

GetKustomizeSettings loads the kustomize settings from cd-cm ConfigMap

func (*SettingsManager) GetMaxPodLogsToRender added in v1.8.8

func (mgr *SettingsManager) GetMaxPodLogsToRender() (int64, error)

func (*SettingsManager) GetMaxWebhookPayloadSize added in v1.8.8

func (mgr *SettingsManager) GetMaxWebhookPayloadSize() int64

func (*SettingsManager) GetNamespace added in v1.8.8

func (mgr *SettingsManager) GetNamespace() string

func (*SettingsManager) GetPasswordPattern added in v1.8.8

func (mgr *SettingsManager) GetPasswordPattern() (string, error)

func (*SettingsManager) GetResourceCompareOptions added in v1.8.8

func (mgr *SettingsManager) GetResourceCompareOptions() (DiffOptions, error)

GetResourceCompareOptions loads the resource compare options settings from the ConfigMap

func (*SettingsManager) GetResourceCustomLabels added in v1.8.8

func (mgr *SettingsManager) GetResourceCustomLabels() ([]string, error)

func (*SettingsManager) GetResourceOverrides added in v1.0.0

func (mgr *SettingsManager) GetResourceOverrides() (map[string]v1alpha1.ResourceOverride, error)

GetResourceOverrides loads Resource Overrides from cd-cm ConfigMap

func (*SettingsManager) GetResourcesFilter added in v1.2.0

func (mgr *SettingsManager) GetResourcesFilter() (*ResourcesFilter, error)

func (*SettingsManager) GetSecretByName added in v1.8.8

func (mgr *SettingsManager) GetSecretByName(secretName string) (*corev1.Secret, error)

GetSecretByName returns the Secret with the given name from the cluster.

func (*SettingsManager) GetSecretsInformer added in v1.8.8

func (mgr *SettingsManager) GetSecretsInformer() (cache.SharedIndexInformer, error)

func (*SettingsManager) GetSecretsLister added in v0.11.0

func (mgr *SettingsManager) GetSecretsLister() (v1listers.SecretLister, error)

func (*SettingsManager) GetSensitiveAnnotations added in v1.8.8

func (mgr *SettingsManager) GetSensitiveAnnotations() map[string]bool

func (*SettingsManager) GetSettings

func (mgr *SettingsManager) GetSettings() (*Settings, error)

GetSettings retrieves settings from the cd-cm ConfigMap and secret.

func (*SettingsManager) GetSourceHydratorCommitMessageTemplate added in v1.8.8

func (mgr *SettingsManager) GetSourceHydratorCommitMessageTemplate() (string, error)

func (*SettingsManager) GetTrackingMethod added in v1.8.8

func (mgr *SettingsManager) GetTrackingMethod() (string, error)

func (*SettingsManager) GetWebhookRefreshJitter added in v1.8.8

func (mgr *SettingsManager) GetWebhookRefreshJitter() time.Duration

func (*SettingsManager) GetWebhookRefreshJitterThreshold added in v1.8.8

func (mgr *SettingsManager) GetWebhookRefreshJitterThreshold() int

func (*SettingsManager) InitializeSettings added in v0.11.0

func (mgr *SettingsManager) InitializeSettings(insecureModeEnabled bool) (*Settings, error)

InitializeSettings is used to initialize empty admin password, signature, certificate etc if missing

func (*SettingsManager) IsImpersonationEnabled added in v1.8.8

func (mgr *SettingsManager) IsImpersonationEnabled() (bool, error)

IsImpersonationEnabled returns true if application sync with impersonation feature is enabled in cd-cm configmap

func (*SettingsManager) IsImpersonationEnforced added in v1.8.8

func (mgr *SettingsManager) IsImpersonationEnforced() (bool, error)

IsImpersonationEnforced returns true if impersonation enforcement is enabled (requires service account to be configured)

func (*SettingsManager) IsInClusterEnabled added in v1.8.8

func (mgr *SettingsManager) IsInClusterEnabled() (bool, error)

IsInClusterEnabled returns false if in-cluster is explicitly disabled in cd-cm configmap, true otherwise

func (*SettingsManager) RequireOverridePrivilegeForRevisionSync added in v1.8.8

func (mgr *SettingsManager) RequireOverridePrivilegeForRevisionSync() (bool, error)

func (*SettingsManager) RespectRBAC added in v1.8.8

func (mgr *SettingsManager) RespectRBAC() (int, error)

func (*SettingsManager) ResyncInformers added in v0.11.0

func (mgr *SettingsManager) ResyncInformers() error

func (*SettingsManager) SaveGPGPublicKeyData added in v1.8.8

func (mgr *SettingsManager) SaveGPGPublicKeyData(ctx context.Context, gpgPublicKeys map[string]string) error

func (*SettingsManager) SaveSSHKnownHostsData added in v1.2.0

func (mgr *SettingsManager) SaveSSHKnownHostsData(ctx context.Context, knownHostsList []string) error

Save the SSH known host data into the corresponding ConfigMap

func (*SettingsManager) SaveTLSCertificateData added in v1.2.0

func (mgr *SettingsManager) SaveTLSCertificateData(ctx context.Context, tlsCertificates map[string]string) error

func (*SettingsManager) Subscribe added in v0.4.4

func (mgr *SettingsManager) Subscribe(subCh chan<- *Settings)

Subscribe registers a channel in which to subscribe to settings updates

func (*SettingsManager) Unsubscribe added in v0.4.4

func (mgr *SettingsManager) Unsubscribe(subCh chan<- *Settings)

Unsubscribe unregisters a channel from receiving of settings updates

func (*SettingsManager) UpdateAccount added in v1.5.0

func (mgr *SettingsManager) UpdateAccount(name string, callback func(account *Account) error) error

UpdateAccount runs the callback function against an account that matches to the specified name and persist changes applied by the callback.

type SettingsManagerOpts added in v1.8.8

type SettingsManagerOpts func(mgs *SettingsManager)

func WithRepoOrClusterChangedHandler added in v1.8.8

func WithRepoOrClusterChangedHandler(handler func()) SettingsManagerOpts

type Token added in v1.5.0

type Token struct {
	ID        string `json:"id"`
	IssuedAt  int64  `json:"iat"`
	ExpiresAt int64  `json:"exp,omitempty"`
}

Token holds the information about the generated auth token.

Jump to

Keyboard shortcuts

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