pagesproject

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package pagesproject implements the Controller for PagesProject CRD. It directly manages Cloudflare Pages projects.

Index

Constants

View Source
const (
	// DefaultHealthCheckTimeout is the default timeout for health checks.
	DefaultHealthCheckTimeout = 30 * time.Second
	// HealthCheckSuccessCode is the HTTP status code considered as healthy.
	HealthCheckSuccessCode = http.StatusOK
)
View Source
const (
	// FinalizerName is the finalizer for PagesProject resources.
	FinalizerName = "pagesproject.networking.cloudflare-operator.io/finalizer"

	// ManagedByLabel identifies resources managed by PagesProject controller.
	ManagedByLabel = "networking.cloudflare-operator.io/managed-by"

	// ManagedByNameLabel stores the PagesProject name that manages this deployment.
	ManagedByNameLabel = "networking.cloudflare-operator.io/managed-by-name"

	// ManagedByUIDLabel stores the PagesProject UID to prevent conflicts after deletion.
	ManagedByUIDLabel = "networking.cloudflare-operator.io/managed-by-uid"

	// VersionLabel stores the version name from ProjectVersion.
	VersionLabel = "networking.cloudflare-operator.io/version"

	// ManagedAnnotation marks a resource as managed by PagesProject.
	ManagedAnnotation = "networking.cloudflare-operator.io/managed"

	// ManagedByValue is the value for ManagedByLabel.
	ManagedByValue = "pagesproject"
)
View Source
const DefaultExternalSyncInterval = 5 * time.Minute

DefaultExternalSyncInterval is the default interval for external version sync.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoPromoteReconciler added in v0.36.0

type AutoPromoteReconciler struct {
	client.Client
	Scheme     *runtime.Scheme
	Recorder   record.EventRecorder
	Log        logr.Logger
	HTTPClient *http.Client
}

AutoPromoteReconciler handles the autoPromote version management policy. It automatically promotes preview deployments to production after they succeed, with optional delay and health check.

func NewAutoPromoteReconciler added in v0.36.0

func NewAutoPromoteReconciler(
	k8sClient client.Client,
	scheme *runtime.Scheme,
	recorder record.EventRecorder,
	log logr.Logger,
) *AutoPromoteReconciler

NewAutoPromoteReconciler creates a new AutoPromoteReconciler.

func (*AutoPromoteReconciler) GetRequeueAfter added in v0.36.0

func (*AutoPromoteReconciler) GetRequeueAfter() time.Duration

GetRequeueAfter returns the recommended requeue duration for autoPromote mode.

func (*AutoPromoteReconciler) Reconcile added in v0.36.0

func (r *AutoPromoteReconciler) Reconcile(
	ctx context.Context,
	project *networkingv1alpha2.PagesProject,
	apiClient *cf.API,
) (requeueAfter time.Duration, err error)

Reconcile handles the autoPromote version management workflow.

type ExternalReconciler added in v0.36.0

type ExternalReconciler struct {
	client.Client
	Scheme   *runtime.Scheme
	Recorder record.EventRecorder
	Log      logr.Logger
}

ExternalReconciler handles the external version management policy. It allows external systems to control versioning by updating the External config fields.

func NewExternalReconciler added in v0.36.0

func NewExternalReconciler(
	k8sClient client.Client,
	scheme *runtime.Scheme,
	recorder record.EventRecorder,
	log logr.Logger,
) *ExternalReconciler

NewExternalReconciler creates a new ExternalReconciler.

func (*ExternalReconciler) GetSyncInterval added in v0.36.0

GetSyncInterval returns the configured or default sync interval.

func (*ExternalReconciler) Reconcile added in v0.36.0

func (r *ExternalReconciler) Reconcile(
	ctx context.Context,
	project *networkingv1alpha2.PagesProject,
	apiClient *cf.API,
) (requeueAfter time.Duration, err error)

Reconcile handles the external version management workflow. External systems update spec.versionManagement.external.currentVersion and productionVersion. This reconciler ensures the corresponding deployments exist and production is promoted.

type GitOpsReconciler added in v0.36.0

type GitOpsReconciler struct {
	client.Client
	Scheme   *runtime.Scheme
	Recorder record.EventRecorder
	Log      logr.Logger
}

GitOpsReconciler handles the gitops version management policy. It manages preview and production deployments based on version names.

func NewGitOpsReconciler added in v0.36.0

func NewGitOpsReconciler(k8sClient client.Client, scheme *runtime.Scheme, recorder record.EventRecorder, log logr.Logger) *GitOpsReconciler

NewGitOpsReconciler creates a new GitOpsReconciler.

func (*GitOpsReconciler) Reconcile added in v0.36.0

func (r *GitOpsReconciler) Reconcile(
	ctx context.Context,
	project *networkingv1alpha2.PagesProject,
	apiClient *cf.API,
) error

Reconcile handles the GitOps version management workflow.

func (*GitOpsReconciler) UpdatePreviewDeploymentStatus added in v0.36.0

func (r *GitOpsReconciler) UpdatePreviewDeploymentStatus(
	ctx context.Context,
	project *networkingv1alpha2.PagesProject,
	deployment *networkingv1alpha2.PagesDeployment,
) error

UpdatePreviewDeploymentStatus updates the preview deployment info in project status.

func (*GitOpsReconciler) UpdateVersionMapping added in v0.36.0

func (r *GitOpsReconciler) UpdateVersionMapping(
	ctx context.Context,
	project *networkingv1alpha2.PagesProject,
) error

UpdateVersionMapping updates the version mapping in project status.

type LatestPreviewReconciler added in v0.36.0

type LatestPreviewReconciler struct {
	client.Client
	Scheme   *runtime.Scheme
	Recorder record.EventRecorder
	Log      logr.Logger
}

LatestPreviewReconciler handles the latestPreview version management policy. It automatically tracks the latest successful preview deployment and optionally auto-promotes.

func NewLatestPreviewReconciler added in v0.36.0

func NewLatestPreviewReconciler(
	k8sClient client.Client,
	scheme *runtime.Scheme,
	recorder record.EventRecorder,
	log logr.Logger,
) *LatestPreviewReconciler

NewLatestPreviewReconciler creates a new LatestPreviewReconciler.

func (*LatestPreviewReconciler) GetRequeueAfter added in v0.36.0

func (*LatestPreviewReconciler) GetRequeueAfter() time.Duration

GetRequeueAfter returns the recommended requeue duration for latestPreview mode.

func (*LatestPreviewReconciler) Reconcile added in v0.36.0

func (r *LatestPreviewReconciler) Reconcile(
	ctx context.Context,
	project *networkingv1alpha2.PagesProject,
	apiClient *cf.API,
) error

Reconcile handles the latestPreview version management workflow.

type PagesProjectReconciler

type PagesProjectReconciler struct {
	client.Client
	Scheme     *runtime.Scheme
	Recorder   record.EventRecorder
	APIFactory *common.APIClientFactory
	// contains filtered or unexported fields
}

PagesProjectReconciler reconciles a PagesProject object. It directly calls Cloudflare API and writes status back to the CRD.

func (*PagesProjectReconciler) Reconcile

func (r *PagesProjectReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

func (*PagesProjectReconciler) SetupWithManager

func (r *PagesProjectReconciler) SetupWithManager(mgr ctrl.Manager) error

type ResolvedVersions added in v0.31.0

type ResolvedVersions struct {
	Versions         []networkingv1alpha2.ProjectVersion
	ProductionTarget string
	// PreviewVersion is the version to deploy as preview (GitOps mode)
	PreviewVersion string
	// ProductionVersion is the version to deploy as production (GitOps mode)
	ProductionVersion string
	// Policy is the active version management policy
	Policy networkingv1alpha2.VersionPolicy
}

ResolvedVersions contains the resolved versions and production target.

type TemplateData added in v0.31.0

type TemplateData struct {
	Version string
}

TemplateData contains data for template execution.

type VersionIndex added in v0.36.0

type VersionIndex struct {
	client.Client
}

VersionIndex maintains a mapping of versionName -> deploymentId. This allows efficient lookup of deployments by version name.

func NewVersionIndex added in v0.36.0

func NewVersionIndex(k8sClient client.Client) *VersionIndex

NewVersionIndex creates a new VersionIndex.

func (*VersionIndex) BuildIndex added in v0.36.0

func (idx *VersionIndex) BuildIndex(
	ctx context.Context,
	project *networkingv1alpha2.PagesProject,
) (map[string]string, error)

BuildIndex builds a version index for the given project. Returns a map of versionName -> deploymentId.

func (*VersionIndex) FindDeploymentByID added in v0.36.0

func (idx *VersionIndex) FindDeploymentByID(
	ctx context.Context,
	project *networkingv1alpha2.PagesProject,
	deploymentID string,
) (*networkingv1alpha2.PagesDeployment, error)

FindDeploymentByID finds a PagesDeployment by Cloudflare deployment ID.

func (*VersionIndex) FindDeploymentByVersion added in v0.36.0

func (idx *VersionIndex) FindDeploymentByVersion(
	ctx context.Context,
	project *networkingv1alpha2.PagesProject,
	versionName string,
) (*networkingv1alpha2.PagesDeployment, error)

FindDeploymentByVersion finds a PagesDeployment by version name.

func (*VersionIndex) GetDeploymentID added in v0.36.0

func (idx *VersionIndex) GetDeploymentID(
	ctx context.Context,
	project *networkingv1alpha2.PagesProject,
	versionName string,
) (string, error)

GetDeploymentID returns the deployment ID for a version name.

func (*VersionIndex) ListVersions added in v0.36.0

func (idx *VersionIndex) ListVersions(
	ctx context.Context,
	project *networkingv1alpha2.PagesProject,
) ([]string, error)

ListVersions returns a list of all version names for a project.

func (*VersionIndex) ListVersionsWithInfo added in v0.36.0

func (idx *VersionIndex) ListVersionsWithInfo(
	ctx context.Context,
	project *networkingv1alpha2.PagesProject,
) ([]VersionInfo, error)

ListVersionsWithInfo returns detailed information about all versions.

type VersionInfo added in v0.36.0

type VersionInfo struct {
	// Name is the version name
	Name string
	// DeploymentID is the Cloudflare deployment ID
	DeploymentID string
	// DeploymentName is the K8s PagesDeployment name
	DeploymentName string
	// State is the deployment state
	State networkingv1alpha2.PagesDeploymentState
	// Environment is the deployment environment
	Environment string
	// IsProduction indicates if this is the current production deployment
	IsProduction bool
}

VersionInfo contains information about a version.

type VersionManager added in v0.29.0

type VersionManager struct {
	client.Client
	Scheme *runtime.Scheme
	// contains filtered or unexported fields
}

VersionManager manages declarative versions for PagesProject.

func NewVersionManager added in v0.29.0

func NewVersionManager(k8sClient client.Client, scheme *runtime.Scheme, log logr.Logger) *VersionManager

NewVersionManager creates a new VersionManager.

func (*VersionManager) GetPolicy added in v0.36.0

GetPolicy returns the effective version management policy.

func (*VersionManager) HasVersions added in v0.31.0

func (*VersionManager) HasVersions(project *networkingv1alpha2.PagesProject) bool

HasVersions checks if the project has any versions configured.

func (*VersionManager) IsGitOpsMode added in v0.36.0

func (*VersionManager) IsGitOpsMode(project *networkingv1alpha2.PagesProject) bool

IsGitOpsMode checks if the project is using GitOps version management.

func (*VersionManager) Reconcile added in v0.29.0

func (vm *VersionManager) Reconcile(ctx context.Context, project *networkingv1alpha2.PagesProject) error

Reconcile synchronizes the desired versions with actual PagesDeployment resources.

func (*VersionManager) ResolveVersions added in v0.31.0

func (vm *VersionManager) ResolveVersions(project *networkingv1alpha2.PagesProject) (*ResolvedVersions, error)

ResolveVersions resolves versions based on the version management configuration. Supports 8 modes: none, targetVersion, declarativeVersions, fullVersions, gitops, latestPreview, autoPromote, external.

Jump to

Keyboard shortcuts

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