connectionsecret

package
v2.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProjectLabelKey      = "atlas.mongodb.com/project-id"
	TargetLabelKey       = "atlas.mongodb.com/target-name"
	TypeLabelKey         = "atlas.mongodb.com/type"
	DatabaseUserLabelKey = "atlas.mongodb.com/database-user-name"
	ConnectionTypelKey   = "atlas.mongodb.com/connection-type"
	CredLabelVal         = "credentials"
)

Variables

View Source
var (
	ConnectionSecretGoFieldOwner = client.FieldOwner("connectionsecret")
	ErrInternalFormatErr         = errors.New("identifiers could not be loaded from internal format")
	ErrK8SFormatErr              = errors.New("identifiers could not be loaded from k8s format")
	ErrMissingPairing            = errors.New("missing user/connectionTarget")
	ErrAmbiguousPairing          = errors.New("multiple users/connectionTargets with the same name found")
	ErrUnresolvedProjectID       = errors.New("could not resolve the project id")
)

Functions

func ComputeHash

func ComputeHash(projectID, targetName, userName, connectionTargetType string) string

ComputeHash generates a hash based on key connection metadata for immutable secret naming

func CreateURL

func CreateURL(hostname, username, password string) (string, error)

CreateURL creates the connection urls given a hostname, user, and password

func K8sConnectionSecretName

func K8sConnectionSecretName(projectID, targetName, userName, connectionTargetType string) string

Types

type ConnectionSecretData

type ConnectionSecretData struct {
	DBUserName            string
	Password              string
	ConnectionURL         string
	SrvConnectionURL      string
	PrivateConnectionURLs []PrivateLinkConnectionURLs
}

ConnectionData contains all connection information required to populate the Kubernetes Secret, including standard and SRV URLs and optional Private Link URLs.

type ConnectionSecretIdentifiers

type ConnectionSecretIdentifiers struct {
	ProjectID        string
	TargetName       string
	DatabaseUsername string
	ConnectionType   string
}

ConnnSecretIdentifiers stores all the necessary information that will be needed to identiy and get a K8s connection secret

type ConnectionSecretReconciler

type ConnectionSecretReconciler struct {
	reconciler.AtlasReconciler
	Scheme                *runtime.Scheme
	EventRecorder         record.EventRecorder
	GlobalPredicates      []predicate.Predicate
	ConnectionTargetKinds []ConnectionTarget
}

func NewConnectionSecretReconciler

func NewConnectionSecretReconciler(
	c cluster.Cluster,
	predicates []predicate.Predicate,
	atlasProvider atlas.Provider,
	logger *zap.Logger,
	globalSecretRef types.NamespacedName,
) *ConnectionSecretReconciler

func (*ConnectionSecretReconciler) For

func (*ConnectionSecretReconciler) Reconcile

func (*ConnectionSecretReconciler) SetupWithManager

func (r *ConnectionSecretReconciler) SetupWithManager(mgr ctrl.Manager, skipNameValidation bool) error

type ConnectionTarget

type ConnectionTarget interface {
	GetConnectionTargetType() string
	GetName() string
	IsReady() bool
	GetScopeType() akov2.ScopeType
	GetProjectID(ctx context.Context) (string, error)
	SelectorByProjectID(projectID string) fields.Selector
	BuildConnectionData(ctx context.Context, user *akov2.AtlasDatabaseUser) (ConnectionSecretData, error)
}

Each connectionTarget would have to implement this interface (e.g. AtlasDeployment, AtlasDataFederation)

type DataFederationConnectionTarget

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

func (DataFederationConnectionTarget) BuildConnectionData

BuildConnectionData builds the ConnectionSecretData for this connectionTarget type

func (DataFederationConnectionTarget) GetConnectionTargetType

func (e DataFederationConnectionTarget) GetConnectionTargetType() string

GetConnectionTargetType returns the connectionTarget type

func (DataFederationConnectionTarget) GetName

GetName resolves the connectionTargets name from the spec

func (DataFederationConnectionTarget) GetProjectID

GetProjectID resolves parent project's id (only ProjectRef)

func (DataFederationConnectionTarget) GetScopeType

GetScopeType returns the scope type of the connectionTarget to match with the ones from AtlasDatabaseUser

func (DataFederationConnectionTarget) IsReady

IsReady returns true if the connectionTarget is ready

func (DataFederationConnectionTarget) SelectorByProjectID

func (DataFederationConnectionTarget) SelectorByProjectID(projectID string) fields.Selector

Defines the selector to use for indexer when trying to retrieve all connectionTargets by project

type DeploymentConnectionTarget

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

func (DeploymentConnectionTarget) BuildConnectionData

BuildConnectionData defines the specific function/way for building the ConnectionSecretData given this type of connectionTarget AtlasDeployment stores connection strings in the status field

func (DeploymentConnectionTarget) GetConnectionTargetType

func (e DeploymentConnectionTarget) GetConnectionTargetType() string

GetConnectionTargetType returns the connectionTarget type

func (DeploymentConnectionTarget) GetName

func (e DeploymentConnectionTarget) GetName() string

GetName resolves the connectionTargets name from the spec

func (DeploymentConnectionTarget) GetProjectID

func (e DeploymentConnectionTarget) GetProjectID(ctx context.Context) (string, error)

GetProjectID resolves parent project's id (ProjectRef or ExternalRef)

func (DeploymentConnectionTarget) GetScopeType

func (e DeploymentConnectionTarget) GetScopeType() akov2.ScopeType

GetScopeType returns the scope type of the connectionTarget to match with the ones from AtlasDatabaseUser

func (DeploymentConnectionTarget) IsReady

func (e DeploymentConnectionTarget) IsReady() bool

IsReady returns true if the connectionTarget is ready

func (DeploymentConnectionTarget) SelectorByProjectID

func (DeploymentConnectionTarget) SelectorByProjectID(projectID string) fields.Selector

Defines the selector to use for indexer when trying to retrieve all connectionTargets by project

type PrivateLinkConnectionURLs

type PrivateLinkConnectionURLs struct {
	ConnectionURL      string
	SrvConnectionURL   string
	ShardConnectionURL string
}

Jump to

Keyboard shortcuts

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