privateservice

package
v0.25.0 Latest Latest
Warning

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

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

Documentation

Overview

Package privateservice provides the PrivateServiceService for managing Cloudflare PrivateService configuration.

Package privateservice provides types and service for PrivateService configuration management.

Index

Constants

View Source
const (
	// ResourceType is the SyncState resource type for PrivateService
	ResourceType = v1alpha2.SyncResourcePrivateService

	// PriorityPrivateService is the default priority for PrivateService configuration
	PriorityPrivateService = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PrivateServiceConfig

type PrivateServiceConfig struct {
	// Network is the CIDR notation for the route (e.g., "10.96.0.1/32")
	// Derived from the referenced Service's ClusterIP
	Network string `json:"network"`
	// TunnelID is the Cloudflare Tunnel ID to route traffic through
	TunnelID string `json:"tunnelId"`
	// TunnelName is the Cloudflare Tunnel name (for display purposes)
	TunnelName string `json:"tunnelName,omitempty"`
	// VirtualNetworkID is the Cloudflare Virtual Network ID
	VirtualNetworkID string `json:"virtualNetworkId,omitempty"`
	// ServiceIP is the ClusterIP of the referenced K8s Service
	ServiceIP string `json:"serviceIP"`
	// Comment is a user-provided comment for the route
	Comment string `json:"comment,omitempty"`
}

PrivateServiceConfig represents a PrivateService configuration. Each PrivateService K8s resource contributes one PrivateServiceConfig to its SyncState.

type RegisterOptions

type RegisterOptions struct {
	// AccountID is the Cloudflare Account ID
	AccountID string
	// RouteNetwork is the network CIDR that serves as the route identifier
	// Used as the CloudflareID in SyncState
	// For new routes, a placeholder is used until the route is created
	RouteNetwork string
	// VirtualNetworkID is the Virtual Network ID for this route
	VirtualNetworkID string
	// Source identifies the K8s resource contributing this configuration
	Source service.Source
	// Config contains the PrivateService configuration
	Config PrivateServiceConfig
	// CredentialsRef references the CloudflareCredentials to use
	CredentialsRef v1alpha2.CredentialsReference
}

RegisterOptions contains options for registering a PrivateService configuration.

type Service

type Service struct {
	*service.BaseService
}

Service handles PrivateService configuration registration. It implements the ConfigService interface for PrivateService resources.

func NewService

func NewService(c client.Client) *Service

NewService creates a new PrivateServiceService

func (*Service) GetSyncStatus

func (s *Service) GetSyncStatus(ctx context.Context, source service.Source, knownNetwork, virtualNetworkID string) (*SyncStatus, error)

GetSyncStatus returns the sync status for a PrivateService.

func (*Service) Register

func (s *Service) Register(ctx context.Context, opts RegisterOptions) error

Register registers a PrivateService configuration to SyncState. Each PrivateService K8s resource has its own SyncState, keyed by a generated ID based on the network CIDR and virtual network ID.

func (*Service) Unregister

func (s *Service) Unregister(ctx context.Context, network, virtualNetworkID string, source service.Source) error

Unregister removes a PrivateService's configuration from the SyncState. This is called when the PrivateService K8s resource is deleted.

func (*Service) UpdateRouteID

func (s *Service) UpdateRouteID(ctx context.Context, source service.Source, network, virtualNetworkID string) error

UpdateRouteID updates the SyncState to use the actual network CIDR as the ID after the route is created. This migrates from the pending placeholder.

type SyncResult

type SyncResult struct {
	// Network is the CIDR notation for the route
	Network string
	// TunnelID is the Cloudflare Tunnel ID
	TunnelID string
	// TunnelName is the Cloudflare Tunnel name
	TunnelName string
	// VirtualNetworkID is the Cloudflare Virtual Network ID
	VirtualNetworkID string
	// ServiceIP is the ClusterIP of the referenced K8s Service
	ServiceIP string
}

SyncResult contains the result of a successful PrivateService sync operation.

type SyncStatus

type SyncStatus struct {
	// IsSynced indicates whether the PrivateService has been synced to Cloudflare
	IsSynced bool
	// Network is the CIDR notation for the route
	Network string
	// AccountID is the Cloudflare Account ID
	AccountID string
	// SyncStateID is the name of the SyncState resource
	SyncStateID string
}

SyncStatus represents the sync status of a PrivateService.

Jump to

Keyboard shortcuts

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