config

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultHostPattern = `http://*.localhost:8001`
View Source
const DefaultSite = "main"
View Source
const SiteConfigName = "pageship"
View Source
const SitesConfigName = "sites"

Variables

View Source
var ErrConfigNotFound = errors.New("config not found")

Functions

func ClientConfigPath

func ClientConfigPath() (string, error)

func ValidateAppConfig

func ValidateAppConfig(conf *AppConfig) error

func ValidateDNSLabel

func ValidateDNSLabel(value string) bool

func ValidateDuration

func ValidateDuration(value string) bool

func ValidateSiteConfig

func ValidateSiteConfig(conf *SiteConfig) error

Types

type ACL

type ACL []ACLSubjectRule

func LoadACL

func LoadACL(r io.Reader) (ACL, error)

type ACLSubjectRule

type ACLSubjectRule struct {
	PageshipUser            string `json:"pageshipUser,omitempty" pageship:"max=100"`
	GitHubUser              string `json:"githubUser,omitempty" pageship:"max=100"`
	GitHubRepositoryActions string `json:"gitHubRepositoryActions,omitempty" pageship:"max=100"`
	IpRange                 string `json:"ipRange,omitempty" pageship:"omitempty,max=100,cidr"`
}

func (*ACLSubjectRule) String

func (c *ACLSubjectRule) String() string

type AccessLevel

type AccessLevel string
const (
	AccessLevelAdmin    AccessLevel = "admin"
	AccessLevelDeployer AccessLevel = "deployer"
	AccessLevelReader   AccessLevel = "reader"

	AccessLevelDefault = AccessLevelReader
)

func (AccessLevel) CanAccess

func (l AccessLevel) CanAccess(a AccessLevel) bool

func (AccessLevel) IsValid

func (l AccessLevel) IsValid() bool

type AccessRule

type AccessRule struct {
	ACLSubjectRule `mapstructure:",squash"`
	Access         AccessLevel `json:"access" pageship:"omitempty,accessLevel"`
}

func (*AccessRule) SetDefaults

func (r *AccessRule) SetDefaults()

type AppConfig

type AppConfig struct {
	ID          string               `json:"id" pageship:"required,dnsLabel"`
	DefaultSite string               `json:"defaultSite" pageship:"required,dnsLabel"`
	Sites       []AppSiteConfig      `json:"sites" pageship:"max=10,dive,required"`
	Deployments AppDeploymentsConfig `json:"deployments"`
	Team        []*AccessRule        `json:"team" pageship:"max=100,dive,required"`
	Domains     []AppDomainConfig    `json:"domains" pageship:"max=10,unique=Domain,unique=Site,dive,required"`
}

func DefaultAppConfig

func DefaultAppConfig() AppConfig

func (*AppConfig) ResolveDomain added in v0.5.0

func (c *AppConfig) ResolveDomain(domain string) (resolved AppDomainConfig, ok bool)

func (*AppConfig) ResolveSite

func (c *AppConfig) ResolveSite(site string) (resolved AppSiteConfig, ok bool)

func (*AppConfig) Scan

func (c *AppConfig) Scan(val any) error

func (*AppConfig) SetDefaults

func (c *AppConfig) SetDefaults()

func (*AppConfig) Value

func (c *AppConfig) Value() (driver.Value, error)

type AppDeploymentsConfig

type AppDeploymentsConfig struct {
	Access ACL    `json:"access" pageship:"omitempty"`
	TTL    string `json:"ttl" pageship:"omitempty,duration"`
}

func (*AppDeploymentsConfig) SetDefaults

func (c *AppDeploymentsConfig) SetDefaults()

type AppDomainConfig added in v0.5.0

type AppDomainConfig struct {
	Domain string `json:"domain" pageship:"required,max=200,hostname_rfc1123,lowercase"`
	Site   string `json:"site" pageship:"required,dnsLabel"`
}

type AppSiteConfig

type AppSiteConfig struct {
	Name    string `json:"name" pageship:"excluded_with=Pattern,dnsLabel"`
	Pattern string `json:"pattern,omitempty" pageship:"excluded_with=Name,max=100,regexp"`
}

func (*AppSiteConfig) CompilePattern

func (c *AppSiteConfig) CompilePattern() (*regexp.Regexp, error)

type ClientConfig

type ClientConfig struct {
	APIServer      string `json:"apiServer,omitempty"`
	GitHubUsername string `json:"githubUsername,omitempty"`
	SSHKeyFile     string `json:"sshKeyFile,omitempty"`
	AuthToken      string `json:"authToken,omitempty"`
}

func LoadClientConfig

func LoadClientConfig() (*ClientConfig, error)

func (*ClientConfig) Save

func (c *ClientConfig) Save() error

type Config

type Config struct {
	App  AppConfig  `json:"app"`
	Site SiteConfig `json:"site"`
}

func DefaultConfig

func DefaultConfig() Config

func (*Config) SetDefaults

func (c *Config) SetDefaults()

type HostIDScheme

type HostIDScheme string
const (
	HostIDSchemeSubdomain HostIDScheme = "subdomain"
	HostIDSchemeSuffix    HostIDScheme = "suffix"

	HostIDSchemeDefault = HostIDSchemeSubdomain
)

func (HostIDScheme) IsValid

func (s HostIDScheme) IsValid() bool

func (HostIDScheme) Make

func (s HostIDScheme) Make(main string, sub string) string

func (HostIDScheme) Split

func (s HostIDScheme) Split(hostID string) (main string, sub string)

type HostPattern

type HostPattern struct {
	Prefix        string
	Suffix        string
	LeadingScheme string
	TrailingPort  string
}

func NewHostPattern

func NewHostPattern(pattern string) *HostPattern

func (*HostPattern) MakeDomain

func (p *HostPattern) MakeDomain(value string) string

func (*HostPattern) MakeURL

func (p *HostPattern) MakeURL(value string) string

func (*HostPattern) MatchString

func (p *HostPattern) MatchString(s string) (string, bool)

type Loader

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

func NewLoader

func NewLoader(name string) *Loader

func (*Loader) Load

func (l *Loader) Load(fsys fs.FS, conf any) error

type SiteConfig

type SiteConfig struct {
	Public string `json:"public" pageship:"required"`
	Access ACL    `json:"access" pageship:"omitempty"`
}

func DefaultSiteConfig

func DefaultSiteConfig() SiteConfig

type SitesConfig

type SitesConfig struct {
	Sites map[string]SitesConfigEntry `json:"sites,omitempty"`
}

func DefaultSitesConfig

func DefaultSitesConfig() *SitesConfig

type SitesConfigEntry

type SitesConfigEntry struct {
	Context string `json:"context"`
	Domain  string `json:"domain"`
}

Jump to

Keyboard shortcuts

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