Documentation
¶
Index ¶
- Constants
- Variables
- func CompleteDockerComposeYaml(maintainer, appName string, inputCompose []byte, dataMap map[string]string) ([]byte, error)
- func IsWgEasyApp(maintainer, appName string) bool
- func ReadBody[T any](w http.ResponseWriter, r *http.Request) (*T, bool)
- func Validate(fieldName, validationTag, fieldValue string) error
- func ValidateStruct(inputStructure any) error
- type ComposeConsistencyValidator
- type ComposeConsistencyValidatorImpl
- type ComposeSyntaxValidator
- type ComposeSyntaxValidatorImpl
- type ComposeValidator
- type ComposeValidatorImpl
- type ServiceValidator
- type ServiceValidatorImpl
- func (s *ServiceValidatorImpl) ValidateContainerName(serviceName string, serviceMap map[string]any, maintainerName, appName string) error
- func (f *ServiceValidatorImpl) ValidateDeploySection(serviceMap map[string]any) error
- func (s *ServiceValidatorImpl) ValidateImage(serviceName string, serviceMap map[string]any) error
- func (s *ServiceValidatorImpl) ValidateLabels(appName string, serviceName string, serviceMap map[string]any) error
- func (s *ServiceValidatorImpl) ValidateNoTzEnvironment(serviceMap map[string]any) error
- func (s *ServiceValidatorImpl) ValidatePorts(serviceMap map[string]any) error
- func (s *ServiceValidatorImpl) ValidateServiceKeys(serviceMap map[string]any) error
- func (s *ServiceValidatorImpl) ValidateServiceName(serviceName string) error
- func (s *ServiceValidatorImpl) ValidateServiceVolumes(maintainerName, appName, serviceName string, serviceMap map[string]any) error
- func (f *ServiceValidatorImpl) ValidateUrl(rawUrl string) bool
- type ValidationFunc
- func NewEmailTextValidator(allowNewlines bool, maxLength int) ValidationFunc
- func NewGenericRegex(regexString, humanReadableMessageTemplate string) ValidationFunc
- func NewOpaqueStringValidator(allowEmpty bool, maxLength int) ValidationFunc
- func NewSimpleRegex(allowedSymbols string, minLength, maxLength int) ValidationFunc
- type VersionValidator
- type VersionValidatorImpl
Constants ¶
View Source
const ( LabelField = "label" ServiceField = "service" VolumeField = "volume" VolumeNameField = "volume_name" MaintainerField = "maintainer" AppField = "app" KeyField = "key" ImageField = "image" ActualContainerName = "actual_container_name" ExpectedContainerName = "expected_container_name" PortField = "port" ExpectedPrefixField = "expected_prefix" ExpectedPartCount = "expected_part_count" ActualPartCount = "actual_part_count" )
View Source
const ( FieldDefault = "default" FieldUsername = "username" FieldIgnore = "ignore" FieldVersionName = "version_name" FieldFileName = "file_name" FieldSearchTerm = "search_term" FieldPassword = "password" FieldEmail = "email" FieldEmailOrEmpty = "email_or_empty" FieldNumber = "number" FieldHost = "host" FieldKnownHosts = "known_hosts" FieldResticBackupID = "restic_backup_id" FieldRemoteHost = "remote_host" FieldSecret = "secret" FieldType = "type" FieldDefaultOrEmpty = "default_or_empty" FieldLoose = "loose" FieldDomain = "domain" FieldDomainPath = "domain_path" FieldOidcSubject = "oidc_subject" FieldOidcClaim = "oidc_claim" FieldCredential = "credential" FieldComposeSecret = "compose_secret_name" FieldSshPublicKey = "ssh_public_key" FieldEmailSubject = "email_subject" FieldEmailBody = "email_body" )
View Source
const ( AppDefinitionLicenseNotice = appDefinitionLicenseNoticePrefix + "\n" MissingAppDefinitionLicenseNotice = "app definition must start with: " + appDefinitionLicenseNoticeMessage )
Variables ¶
View Source
var (
SystemAppNamesAreAlreadyReserved = "system app names are not allowed"
)
View Source
var ValidationMap = map[string]ValidationFunc{ FieldDefault: defaultRegex, FieldUsername: NewSimpleRegex("a-z0-9_-", 3, 20), FieldVersionName: NewSimpleRegex("a-z0-9.", 3, 20), FieldFileName: NewSimpleRegex("a-zA-Z0-9._-", 1, 100), FieldSearchTerm: NewSimpleRegex("a-z0-9", 0, 20), FieldPassword: NewSimpleRegex("a-zA-Z0-9._-", 8, 30), FieldEmail: NewGenericRegex(emailRegex, "Invalid input. The content of the field %s must be a valid email address."), FieldEmailOrEmpty: NewGenericRegex(emailOrEmptyRegex, "Invalid input. The content of the field %s must be empty or be a valid email address."), FieldNumber: NewSimpleRegex("0-9", 1, 20), FieldHost: NewSimpleRegex("a-zA-Z0-9:._-", 0, 64), FieldKnownHosts: NewGenericRegex(`^[A-Za-z0-9.:,/_+=#@\[\]| \r\n-]{0,}$`, "Invalid input. The content of the field %s must contain valid SSH known_hosts entries."), FieldResticBackupID: NewSimpleRegex("a-f0-9", 64, 64), FieldRemoteHost: NewSimpleRegex("a-zA-Z0-9._-", 0, 64), FieldSecret: simpleSecretRegex, FieldDefaultOrEmpty: NewGenericRegex(`^$|^[a-z0-9]{3,20}$`, "Invalid input. The content of the field %s must be empty or be between 3 and 20 characters long. Allowed symbols are: a-z0-9."), FieldLoose: NewGenericRegex(`^[A-Za-z0-9!@#$%^&*()_\-+=\.,:;\/\?\[\]\{\}\|~<>]{1,128}$`, "Invalid input. The content of the field %s contains unsupported symbols."), FieldDomain: NewGenericRegex(domainRegex, "Invalid input. The content of the field %s must be a valid domain without scheme, port, path, query, or fragment."), FieldDomainPath: NewGenericRegex(domainPathRegex, "Invalid input. The content of the field %s must be a valid domain with optional path, without scheme, port, query, or fragment."), FieldOidcSubject: NewOpaqueStringValidator(false, 512), FieldOidcClaim: NewOpaqueStringValidator(true, 1024), FieldCredential: NewOpaqueStringValidator(false, 1024), FieldComposeSecret: NewGenericRegex(`^SECRET_[A-Z0-9_]{1,128}$`, "Invalid input. The content of the field %s must be a valid compose secret name."), FieldSshPublicKey: NewGenericRegex(`^ssh-ed25519 [A-Za-z0-9+/=]{68}( [A-Za-z0-9._@+-]{1,64})?$`, "Invalid input. The content of the field %s must be a valid ed25519 SSH public key."), FieldEmailSubject: NewEmailTextValidator(false, 120), FieldEmailBody: NewEmailTextValidator(true, 5000), }
Functions ¶
func IsWgEasyApp ¶ added in v1.3.22
IsWgEasyApp reports whether the identity refers to the official wg-easy app.
func ValidateStruct ¶
Types ¶
type ComposeConsistencyValidatorImpl ¶
type ComposeConsistencyValidatorImpl struct{}
func (*ComposeConsistencyValidatorImpl) ValidateServiceReferences ¶
func (v *ComposeConsistencyValidatorImpl) ValidateServiceReferences(compose map[string]any) error
func (*ComposeConsistencyValidatorImpl) ValidateVolumeMappings ¶
func (v *ComposeConsistencyValidatorImpl) ValidateVolumeMappings(compose map[string]any) error
type ComposeSyntaxValidator ¶ added in v1.3.1
func NewComposeSyntaxValidator ¶ added in v1.3.1
func NewComposeSyntaxValidator() ComposeSyntaxValidator
type ComposeSyntaxValidatorImpl ¶ added in v1.3.1
type ComposeSyntaxValidatorImpl struct{}
func (*ComposeSyntaxValidatorImpl) ValidateComposeSyntax ¶ added in v1.3.1
func (v *ComposeSyntaxValidatorImpl) ValidateComposeSyntax(composeFileBytes []byte) error
type ComposeValidator ¶
type ComposeValidator interface {
ValidateComposePlaceholders(composeFileBytes []byte) error
ValidateComposeMap(compose map[string]any, maintainerName, appName string) error
}
func NewComposeValidator ¶
func NewComposeValidator(serviceValidator ServiceValidator) ComposeValidator
type ComposeValidatorImpl ¶
type ComposeValidatorImpl struct {
ServiceValidator ServiceValidator
ComposeConsistencyValidator ComposeConsistencyValidator
}
func (*ComposeValidatorImpl) ValidateComposeMap ¶
func (f *ComposeValidatorImpl) ValidateComposeMap(compose map[string]any, maintainerName, appName string) error
func (*ComposeValidatorImpl) ValidateComposePlaceholders ¶
func (f *ComposeValidatorImpl) ValidateComposePlaceholders(composeFileBytes []byte) error
type ServiceValidator ¶
type ServiceValidator interface {
ValidateServiceKeys(serviceMap map[string]any) error
ValidateImage(serviceName string, serviceMap map[string]any) error
ValidateContainerName(serviceName string, serviceMap map[string]any, maintainerName, appName string) error
ValidatePorts(serviceMap map[string]any) error
ValidateServiceVolumes(maintainerName, appName, serviceName string, serviceMap map[string]any) error
ValidateDeploySection(serviceMap map[string]any) error
ValidateServiceName(name string) error
ValidateUrl(url string) bool
ValidateLabels(appName string, serviceName string, serviceMap map[string]any) error
ValidateNoTzEnvironment(serviceMap map[string]any) error
}
type ServiceValidatorImpl ¶
type ServiceValidatorImpl struct{}
func (*ServiceValidatorImpl) ValidateContainerName ¶
func (*ServiceValidatorImpl) ValidateDeploySection ¶
func (f *ServiceValidatorImpl) ValidateDeploySection(serviceMap map[string]any) error
func (*ServiceValidatorImpl) ValidateImage ¶
func (s *ServiceValidatorImpl) ValidateImage(serviceName string, serviceMap map[string]any) error
func (*ServiceValidatorImpl) ValidateLabels ¶
func (*ServiceValidatorImpl) ValidateNoTzEnvironment ¶
func (s *ServiceValidatorImpl) ValidateNoTzEnvironment(serviceMap map[string]any) error
func (*ServiceValidatorImpl) ValidatePorts ¶
func (s *ServiceValidatorImpl) ValidatePorts(serviceMap map[string]any) error
func (*ServiceValidatorImpl) ValidateServiceKeys ¶
func (s *ServiceValidatorImpl) ValidateServiceKeys(serviceMap map[string]any) error
func (*ServiceValidatorImpl) ValidateServiceName ¶
func (s *ServiceValidatorImpl) ValidateServiceName(serviceName string) error
func (*ServiceValidatorImpl) ValidateServiceVolumes ¶
func (s *ServiceValidatorImpl) ValidateServiceVolumes(maintainerName, appName, serviceName string, serviceMap map[string]any) error
func (*ServiceValidatorImpl) ValidateUrl ¶
func (f *ServiceValidatorImpl) ValidateUrl(rawUrl string) bool
type ValidationFunc ¶
func NewEmailTextValidator ¶ added in v1.3.8
func NewEmailTextValidator(allowNewlines bool, maxLength int) ValidationFunc
func NewGenericRegex ¶
func NewGenericRegex(regexString, humanReadableMessageTemplate string) ValidationFunc
func NewOpaqueStringValidator ¶ added in v1.2.4
func NewOpaqueStringValidator(allowEmpty bool, maxLength int) ValidationFunc
func NewSimpleRegex ¶
func NewSimpleRegex(allowedSymbols string, minLength, maxLength int) ValidationFunc
type VersionValidator ¶
type VersionValidator interface {
Validate(composeFileBytes []byte, maintainerName, appName string) error
}
func NewVersionValidator ¶
func NewVersionValidator(requireLicenseNotice bool) VersionValidator
NewVersionValidator creates a validator; requireLicenseNotice=false is deprecated and kept only for compatibility.
type VersionValidatorImpl ¶
type VersionValidatorImpl struct {
ComposeValidator ComposeValidator
ComposeSyntaxValidator ComposeSyntaxValidator
RequireLicenseNotice bool
}
Click to show internal directories.
Click to hide internal directories.