Documentation
¶
Index ¶
- func BaseRule() *validate.Rule
- func ContainsJSWhitespace(s string) bool
- func DescriptionDefaultsToName(obj any, h *validate.Helper) (any, error)
- func DescriptionRule() *validate.Rule
- func DomainIsValid(domain string, minSegments int) bool
- func ErrorAtKey(h *validate.Helper, key, typ, format string, args ...any) *validate.Error
- func ExpandImageLink(value, org, gvc string) (string, error)
- func ExpandLocalLink(value, org, gvc string) (string, error)
- func ExpandOrgLocalLink(link, org string) string
- func GetPart(href string, part int) string
- func HostnameCustom(value any, h *validate.Helper) (any, error)
- func HostnameRule() *validate.Rule
- func IPRule(versions []string, cidr string) *validate.Rule
- func ImageLinkRule() *validate.Rule
- func IsInternalLink(v string) bool
- func IsValidKind(s string) bool
- func JSString(v any) string
- func KindsJSON(kinds []string) string
- func LastPart(href string) string
- func LinkKindOK(value string, kinds []string, org, gvc string) bool
- func LinkRule() *validate.Rule
- func LinksRule() *validate.Rule
- func LocalLinkRule() *validate.Rule
- func LocalLinkShapeRule() *validate.Rule
- func MarshalExtras(v any, extras Extras) ([]byte, error)
- func MemoryToMiB(memory string) float64
- func RegexRule() *validate.Rule
- func ToKind(kinds ...string) validate.CustomFn
- func UnmarshalExtras(b []byte, v any, extras *Extras) error
- type ApiError
- type Base
- type BaseTags
- type CloudProvider
- type Extras
- type GenericList
- type ImageLink
- type Kind
- type Link
- type Links
- type List
- type ListItemKind
- type ListKind
- type LocalLink
- type MultiZoneOptions
- type Name
- type Regex
- type Tags
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BaseRule ¶
BaseRule ports Base = Joi.object({id, name, kind, version, description, tags, created, lastModified, links}). Resources compose it via Reflect(self) plus their spec/status keys.
func ContainsJSWhitespace ¶
ContainsJSWhitespace reports whether s contains a character JavaScript's `\s` matches.
func DescriptionDefaultsToName ¶
DescriptionDefaultsToName ports the common createSchema fork `description: DescriptionRule().Default(Joi.ref('name'))`: when description is absent/empty, default it to the name. Shared across kinds, so it reads the two fields by json name; attach with `.CustomTyped(base.DescriptionDefaultsToName)` on a resource's ValidationRule.
func DescriptionRule ¶
DescriptionRule ports description: Joi.string().trim().max(250).allow(”).
func DomainIsValid ¶
DomainIsValid ports @hapi/address analyzeDomain (the no-tlds path): the shared predicate behind Joi's string.domain and string.hostname. minSegments is Joi's minDomainSegments (2 by default, 1 for hostname()).
func ErrorAtKey ¶
ErrorAtKey anchors an error at a CHILD key of the object a container custom runs on, for the Joi error types whose context carries no `value` (any.required, any.unknown). Helper.ErrorAt always stamps one, so the stamp is dropped here — without this, a hand-raised `"provider" is required` either blamed the whole object (path []) or carried a context key Joi does not emit.
func ExpandImageLink ¶
ExpandImageLink ports base.ts:199-238 ImageLink.custom (the coercion half). A literal image (no leading "/") passes through unchanged; a link expands like a LocalLink but only workload/identity are gvc-scoped for images.
func ExpandLocalLink ¶
ExpandLocalLink ports base.ts:152-195 LocalLink.custom: lowercase-check, then route the `//kind/name` link to org- or gvc-expansion (gvc-scoped kinds need the request gvc), passing through internal + already-absolute same-org links.
func ExpandOrgLocalLink ¶
ExpandOrgLocalLink ports base.ts expandOrgLocalLink: a `//`-prefixed link is rewritten under the org; an absolute link passes through.
func HostnameCustom ¶
HostnameCustom is HostnameRule's check, exported for the leaf types that chain a second custom after it (orgLogging's EsAmazonHost).
func HostnameRule ¶
HostnameRule ports Joi.string().hostname(): a domain with at least one segment, or an IP literal. The error is Joi's `string.hostname`, quoting the LABEL.
func IPRule ¶
IPRule ports Joi.string().ip({version, cidr}). versions may be empty (Joi's "all versions" default, which reports string.ip rather than string.ipVersion); cidr is "optional" (Joi's default) | "required" | "forbidden".
The error is Joi's, down to the context: string.ipVersion carries {cidr, version} and string.ip carries {cidr}; the label — not the value — is what the message quotes, so the caller can see WHICH field is wrong.
func ImageLinkRule ¶
ImageLinkRule ports ImageLink = Joi.string().trim().custom(expand).custom(kind).
func IsInternalLink ¶
IsInternalLink reports a cpln://internal/<alias> link.
func IsValidKind ¶
IsValidKind reports whether s is one of the Kind enum values (base.ts:252 Kind.valid). Exported so callers can validate a kind against the FULL enum — e.g. /admin/org/-addPolicy, which accepts any Kind (bb.Kind.validate), not only the subset a normal org bootstrap seeds builtin policies for.
func JSString ¶
JSString is `${v}` — JavaScript's ToString:
- nil -> "null" (an undefined value renders as "undefined"; callers that distinguish the two pass JSUndefined explicitly)
- bool -> "true" / "false"
- number -> the shortest round-tripping form ("1", "1.5", "1e+21")
- string -> itself
- array/slice -> Array.prototype.toString: elements joined by "," with null/undefined rendering as the empty string (recursively)
- anything else -> "[object Object]"
func LinkKindOK ¶
LinkKindOK ports base.ts:80 toKind for an ALREADY-expanded (absolute or internal) link: valid if it points at one of the listed kinds in the same org/gvc.
func LocalLinkRule ¶
LocalLinkRule ports LocalLink = Joi.string().trim().regex(...).custom(expand). Expansion + the lowercase check delegate to linkalgebra.go.
func LocalLinkShapeRule ¶
LocalLinkShapeRule is the SHAPE half of LocalLinkRule — the trim + pattern, without the expansion custom. The central pre-schema link pass (data-service links.go) uses it so a value that is not link-shaped answers with Joi's `string.pattern.base`, as it does in TS where expansion happens INSIDE the schema and so never sees a value the pattern already rejected.
func MarshalExtras ¶
MarshalExtras encodes v (which MUST be a defined-type alias of the real struct, so this does not recurse through its MarshalJSON) and splices the extras back in. A named property always wins over an extra of the same name.
func MemoryToMiB ¶
MemoryToMiB ports convertMemoryStringToNumber, which TS keeps three copies of (workload.ts, volumeSet.ts, nodelibs/misc resources.ts) — here it is one.
Types ¶
type Base ¶
type Base struct {
Id string `json:"id,omitzero"`
Name Name `json:"name,omitzero"`
Kind Kind `json:"kind,omitzero"`
Version *float64 `json:"version,omitzero"`
Description string `json:"description,omitzero"`
Tags BaseTags `json:"tags,omitzero"`
Created string `json:"created,omitzero"`
LastModified string `json:"lastModified,omitzero"`
Links Links `json:"links,omitzero"`
}
func (Base) ValidationRule ¶
ValidationRule makes the canonical Base type self-validating.
type CloudProvider ¶
type CloudProvider string
const ( CloudProviderAws CloudProvider = "aws" CloudProviderGcp CloudProvider = "gcp" CloudProviderAzure CloudProvider = "azure" CloudProviderNgs CloudProvider = "ngs" )
func (CloudProvider) ValidationRule ¶
func (CloudProvider) ValidationRule() *validate.Rule
ValidationRule ports CloudProvider = Joi.string().valid('aws','gcp','azure','ngs').
type Extras ¶
Extras holds the unnamed properties of an `unknown(true)` object.
func (Extras) ExtrasMarker ¶
func (Extras) ExtrasMarker()
ExtrasMarker tells the validate engine's decoder that allowed unknown keys of the enclosing struct belong here.
type GenericList ¶
type GenericList[T any] struct { Kind ListKind `json:"kind,omitzero"` ItemKind ListItemKind `json:"itemKind,omitzero"` Items []T `json:"items,omitzero"` Links []Link `json:"links,omitzero"` }
type ImageLink ¶
type ImageLink string
func (ImageLink) ValidationRule ¶
ValidationRule makes the canonical ImageLink type self-validating.
type Kind ¶
type Kind string
const ( KindOrg Kind = "org" KindCloudaccount Kind = "cloudaccount" KindPolicy Kind = "policy" KindUser Kind = "user" KindGroup Kind = "group" KindResource Kind = "resource" KindTask Kind = "task" KindPermissions Kind = "permissions" KindServiceaccount Kind = "serviceaccount" KindSecret Kind = "secret" KindLocation Kind = "location" KindGvc Kind = "gvc" KindWorkload Kind = "workload" KindQuota Kind = "quota" KindIdentity Kind = "identity" KindDeployment Kind = "deployment" KindEvent Kind = "event" KindDomain Kind = "domain" KindImage Kind = "image" KindIpset Kind = "ipset" KindResourcepolicy Kind = "resourcepolicy" KindAgent Kind = "agent" KindAccessreport Kind = "accessreport" KindPolicymembership Kind = "policymembership" KindDbcluster Kind = "dbcluster" KindAuditctx Kind = "auditctx" KindMemcachecluster Kind = "memcachecluster" KindSpicedbcluster Kind = "spicedbcluster" KindTenant Kind = "tenant" KindMk8S Kind = "mk8s" KindCommand Kind = "command" KindImagesummary Kind = "imagesummary" KindVolumeset Kind = "volumeset" KindSandboximage Kind = "sandboximage" KindCertificategenerator Kind = "certificategenerator" )
func (Kind) ValidationRule ¶
ValidationRule ports Kind = Joi.string().valid(...).
type Link ¶
func (Link) ValidationRule ¶
ValidationRule makes the canonical Link type self-validating.
type Links ¶
type Links []Link
func (Links) ValidationRule ¶
ValidationRule makes the canonical Links type self-validating.
type List ¶
type List struct {
Kind ListKind `json:"kind,omitzero"`
ItemKind ListItemKind `json:"itemKind,omitzero"`
Items []any `json:"items"`
Links []Link `json:"links"`
}
type ListItemKind ¶
type ListItemKind string
const ( ListItemKindOrg ListItemKind = "org" ListItemKindCloudaccount ListItemKind = "cloudaccount" ListItemKindPolicy ListItemKind = "policy" ListItemKindUser ListItemKind = "user" ListItemKindGroup ListItemKind = "group" ListItemKindResource ListItemKind = "resource" ListItemKindTask ListItemKind = "task" ListItemKindPermissions ListItemKind = "permissions" ListItemKindServiceaccount ListItemKind = "serviceaccount" ListItemKindSecret ListItemKind = "secret" ListItemKindLocation ListItemKind = "location" ListItemKindGvc ListItemKind = "gvc" ListItemKindWorkload ListItemKind = "workload" ListItemKindQuota ListItemKind = "quota" ListItemKindIdentity ListItemKind = "identity" ListItemKindDeployment ListItemKind = "deployment" ListItemKindEvent ListItemKind = "event" ListItemKindAccount ListItemKind = "account" ListItemKindDomain ListItemKind = "domain" ListItemKindImage ListItemKind = "image" ListItemKindIpset ListItemKind = "ipset" ListItemKindResourcepolicy ListItemKind = "resourcepolicy" ListItemKindAccessreport ListItemKind = "accessreport" ListItemKindAgent ListItemKind = "agent" ListItemKindAuditctx ListItemKind = "auditctx" ListItemKindDbcluster ListItemKind = "dbcluster" ListItemKindMemcachecluster ListItemKind = "memcachecluster" ListItemKindSpicedbcluster ListItemKind = "spicedbcluster" ListItemKindTenant ListItemKind = "tenant" ListItemKindMk8S ListItemKind = "mk8s" ListItemKindCommand ListItemKind = "command" ListItemKindPolicymembership ListItemKind = "policymembership" ListItemKindPrimitive ListItemKind = "primitive" ListItemKindForeign ListItemKind = "foreign" ListItemKindLink ListItemKind = "link" ListItemKindImagesummary ListItemKind = "imagesummary" ListItemKindVolumeset ListItemKind = "volumeset" ListItemKindSandboximage ListItemKind = "sandboximage" ListItemKindCertificategenerator ListItemKind = "certificategenerator" )
type LocalLink ¶
type LocalLink string
func (LocalLink) ValidationRule ¶
ValidationRule makes the canonical LocalLink type self-validating.
type MultiZoneOptions ¶
type MultiZoneOptions struct {
Enabled *bool `json:"enabled,omitzero"`
}
type Name ¶
type Name string
func (Name) ValidationRule ¶
ValidationRule ports Name = Joi.string().regex(...).meta({unmodifiable}).max(64).
type Regex ¶
type Regex string
func (Regex) ValidationRule ¶
ValidationRule makes the canonical Regex type self-validating.