domain

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package domain provides core domain models for Moley.

Package domain provides core domain models for Moley.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FQDN

func FQDN(subdomain, zone string) string

Types

type Access

type Access struct {
	Policies []Policy `yaml:"policies,omitempty"`
}

func (*Access) HasPolicies

func (a *Access) HasPolicies() bool

func (*Access) PolicyByName

func (a *Access) PolicyByName(name string) (Policy, bool)

type AccessConfig

type AccessConfig struct {
	Providers []string       `yaml:"providers,omitempty" json:"providers,omitempty"`
	Raw       map[string]any `yaml:",remain" json:"-"`
}

AccessConfig holds the raw Cloudflare Access application configuration. Fields match the CF API shape and are passed through with minimal transformation. Only `providers` is processed by Moley (resolved to IdP UUIDs); everything else is forwarded to the Cloudflare API as-is.

func (AccessConfig) MarshalJSON

func (a AccessConfig) MarshalJSON() ([]byte, error)

MarshalJSON inlines Raw so policy changes are reflected in the input hash.

type AppConfig

type AppConfig struct {
	Target   TargetConfig  `yaml:"target" json:"target" validate:"required"`
	Expose   ExposeConfig  `yaml:"expose" json:"expose" validate:"required"`
	Access   *AccessConfig `yaml:"access,omitempty" json:"access,omitempty" validate:"omitempty"`
	Policies []string      `yaml:"policies,omitempty" json:"policies,omitempty"`
}

type ExposeConfig

type ExposeConfig struct {
	Subdomain string `yaml:"subdomain" json:"subdomain" validate:"required"`
}

type Ingress

type Ingress struct {
	Zone string      `yaml:"zone" json:"zone" validate:"required"`
	Apps []AppConfig `yaml:"apps" json:"apps" validate:"required,dive"`
	Mode IngressMode `yaml:"mode" json:"mode" validate:"required,oneof=wildcard subdomain"`
}

func (*Ingress) HasAccessConfig

func (i *Ingress) HasAccessConfig() bool

type IngressMode

type IngressMode string
const (
	// IngressModeWildcard — best for development and frequently changing apps; one DNS record covers all subdomains.
	IngressModeWildcard IngressMode = "wildcard"
	// IngressModeSubdomain — best for production; each app gets its own explicit DNS record.
	IngressModeSubdomain IngressMode = "subdomain"
)

type Policy

type Policy struct {
	Name  string         `yaml:"name"    json:"name"  validate:"required"`
	Extra map[string]any `yaml:",remain" json:"-"`
}

Policy is a named, reusable Cloudflare Access policy. Name is the reference key; all other fields are CF API fields passed through as-is.

func (Policy) MarshalJSON

func (p Policy) MarshalJSON() ([]byte, error)

MarshalJSON inlines Extra so the full CF policy body is produced on serialization.

type TargetConfig

type TargetConfig struct {
	Port     int            `yaml:"port" json:"port" validate:"required,min=1,max=65535"`
	Hostname string         `yaml:"hostname" json:"hostname" validate:"required"`
	Protocol TargetProtocol `yaml:"protocol" json:"protocol" validate:"required,oneof=http https tcp"`
}

func (*TargetConfig) GetTargetURL

func (t *TargetConfig) GetTargetURL() string

type TargetProtocol

type TargetProtocol string
const (
	ProtocolTCP   TargetProtocol = "tcp"
	ProtocolHTTP  TargetProtocol = "http"
	ProtocolHTTPS TargetProtocol = "https"
)

type Tunnel

type Tunnel struct {
	// Deprecated: Use Name instead.
	ID         string `yaml:"id" json:"-" validate:"-"`
	Name       string `yaml:"name" json:"name" validate:"-"`
	Persistent bool   `yaml:"persistent" json:"persistent" validate:"-"`
}

func NewTunnel

func NewTunnel(name string) (*Tunnel, error)

func (*Tunnel) GetName

func (t *Tunnel) GetName() string

func (*Tunnel) Ref added in v2.5.1

func (t *Tunnel) Ref() string

Ref returns ID if set, otherwise Name. This allows both "id" and "name" YAML keys.

Jump to

Keyboard shortcuts

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