app

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 27 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package app discovers the shape of an Impulse application from its code.

There is no manifest: everything the tool needs is read from files that are already load-bearing for the application itself — the generator program, go.mod, the browser apps' angular.json, the Procfile, the test harnesses, and the config struct tags.

This is the reader other tools import: bedrock derives an application's infrastructure from what Discover reports. The dependency points one way: impulse imports nothing from those tools, so an application stays deployable by hand with impulse alone.

Index

Constants

View Source
const (
	SuperAdministratorsNone    = "none"
	SuperAdministratorsChecked = "checked"
)

The forms of the argument that tells an Auth who its super administrators are: session.NoSuperAdministrators(), which says the application has none, and session.SuperAdministratorsBy(...), which hands the Auth a check that answers who holds the role.

View Source
const (
	MethodPassword = "password"
	MethodAzure    = "azure"
	MethodGoogle   = "google"
	MethodWorkOS   = "workos"
	MethodOIDC     = "oidc"
	MethodPersona  = "persona"
)

The sign-in methods, as the session library names them: the password method of the root package, the redirect methods of the azure, google and workos packages, and the two registrations of the library's generic OpenID Connect method (the oidc package): against an organization's own identity provider, such as Okta or Keycloak (MethodOIDC), and against the persona provider of the test environments (MethodPersona). Both call oidc.SignIn, and the scan tells them apart by the registration's configuration (oidcKind).

View Source
const (
	AuthorityDirectory   = "directory"
	AuthorityApplication = "application"
)

The authorities for a directory method's role membership, read from the registration's RoleSync slot: signin.RoleSync or google.RoleSync makes the directory's role claims or groups the authority, DisableRoleSync leaves membership to the application. The password method has no slot and is the application's by nature.

View Source
const (
	TenantsOne      = "one"
	TenantsListed   = "listed"
	TenantsAny      = "any"
	TenantsPersonal = "personal"
)

The tenant shapes of a Microsoft registration, read from the slot function its configuration's Tenants slot calls: one tenant (azure.Tenant or azure.NamedTenant alone), listed tenants (azure.Tenants of several, or a tenant built in a loop), any tenant (azure.AnyTenant, alone or beside listed tenants) and Microsoft personal accounts alone (azure.PersonalAccounts). Personal accounts beside tenants are Method.PersonalAccounts.

View Source
const (
	WorkspacesOne      = "one"
	WorkspacesListed   = "listed"
	WorkspacesAny      = "any"
	WorkspacesAccounts = "accounts"
)

The Workspace shapes of a Google registration, read from the building blocks its configuration's Workspaces slot is made of: one Workspace (google.Workspace alone), listed Workspaces (google.Workspaces of several, or a Workspace built in a loop), any Workspace (google.AnyWorkspace, alone or beside listed Workspaces) and any Google account alone (google.AnyGoogleAccount). Any Google account beside Workspaces is Method.GoogleAccounts.

View Source
const (
	DefaultSessionTable    = "Sessions"
	DefaultUserTable       = "SessionUsers"
	DefaultIdentitiesTable = "SessionIdentities"
	DefaultPendingTable    = "SessionPendingSignIns"
	DefaultAttemptsTable   = "SessionSignInAttempts"
	DefaultMailLinksTable  = "SessionMailLinks"
	// DefaultSignInMethodsTable is the table an administrator's choice for each sign-in
	// method is kept in (open to sign-up, or invite only), which every sign-in reads.
	DefaultSignInMethodsTable = "SessionSignInMethods"
	// The tokens and device codes tables, read when a machine outlet names the Auth as
	// the issuer of its tokens (Tokens in the generator program).
	DefaultTokensTable      = "SessionTokens"
	DefaultDeviceCodesTable = "SessionDeviceCodes"
	// The sign-in codes and trusted devices tables, the second factor's, read when the
	// Auth sends mail, since the code is mailed.
	DefaultFactorCodesTable    = "SessionFactorCodes"
	DefaultTrustedDevicesTable = "SessionTrustedDevices"
	// DefaultImpersonationTable is the session library's impersonation table name.
	DefaultImpersonationTable = "SessionImpersonations"
	// DefaultAuthEventsTable is the name the library's schema creates the auth events table
	// under; the storage takes the name explicitly (NewAuthEventsTable).
	DefaultAuthEventsTable = "SessionAuthEvents"
)

The session library's default table names for an Auth, which the library's schema sets create under those names (schema/spanner/migrations and schema/spanner/auth/migrations).

View Source
const DefaultOutletName = "default"

DefaultOutletName is the reserved name of the outlet GenerateRoutes declares.

View Source
const FeaturesFile = "features.go"

FeaturesFile is the file impulse declares feature flags in, inside a resources package.

View Source
const FileStoreVariable = "APP_FILE_STORE"

FileStoreVariable is the environment variable the data level opens the default file store from (resource/filestore): the tag impulse add files declares, and the one the profile reports the option by.

View Source
const PasswordRegistration = "password"

PasswordRegistration is the name the password method is always registered under.

View Source
const ProvesGrantFunc = "provesGrant"

ProvesGrantFunc is the harness helper a test case calls to name the conditional grant it proves: provesGrant(t, <auth>.Roles(), role, permission, resource, condition). The helper parses the auth's embedded role file at test time and fails unless a grant with that role, permission, and resource carries exactly that condition text; the conditions-proven check reads the call, so the two hold the case and the file together from both sides.

View Source
const RolesFileName = "roles.json"

RolesFileName is the role file an auth package embeds beside its source: the release's default roles for that auth, which the package exports through Roles().

View Source
const ThisReleaseIdent = "ThisRelease"

ThisReleaseIdent is the generation package's identifier naming the server's own release as an outlet's oldest answered release (generation.ThisRelease).

Variables

View Source
var ErrNoAnchor = errors.New("no anchor for the edit")

ErrNoAnchor reports a source edit whose anchor (a type, a function, a literal) the file does not have. A transition records it as work left to the agent rather than failing.

View Source
var FeatureNameRE = regexp.MustCompile(`^[a-z][a-z0-9_]{0,63}$`)

FeatureNameRE is the shape of a flag's name, as the resource package validates it: lowercase letters, digits and underscores, opening with a letter, at most 64 characters.

Functions

func AddAuthMethod

func AddAuthMethod(rel string, src []byte, importPath, name, declaration string) (out []byte, edited int, err error)

AddAuthMethod returns the program's source with a sign-in method declaration appended to every Auth option naming importPath (on GenerateRoutes or a WithRouterOutlet), and how many were edited. declaration is the method as a program writes it (generation.GoogleMethod("directory").Labeled("Company directory"), see MethodDeclaration). An Auth option already declaring a method of that registration name is left alone and not counted. The edit is textual, so the rest of the file's comments and layout survive; the result is formatted.

func AddFeatureConstant

func AddFeatureConstant(rel string, src []byte, pkg, constant, name string) ([]byte, error)

AddFeatureConstant returns the file's source with a resource.Feature constant appended: the doc stub and the constant, with the resource import added when the file lacks it. An empty src starts the file, in the package pkg.

func AddImport

func AddImport(rel string, src []byte, importPath string) ([]byte, error)

AddImport adds an import path to the file's first import block, or an import declaration after the package clause when the file has none. The result is formatted.

func AddInterfaceLine

func AddInterfaceLine(rel string, src []byte, typeName, line string) ([]byte, error)

AddInterfaceLine appends a method or an embedded interface to the named interface type. A method or an embedded interface the type declares already, by name, is not added again: the source comes back unchanged.

func AddLiteralElement

func AddLiteralElement(rel string, src []byte, funcName, typeName, element string) ([]byte, error)

AddLiteralElement appends "key: value" to the first composite literal of the named type (an identifier, or package-qualified: members.Settings) inside the named function. An element whose key the literal sets already is not added again: the source comes back unchanged.

func AddLiteralElementOfType

func AddLiteralElementOfType(rel string, src []byte, typeName, element string) ([]byte, error)

AddLiteralElementOfType appends "key: value" to the first composite literal of the named type anywhere in the file, for a literal whose function the caller does not know (a test harness building its configurer). An element whose key the literal sets already is not added again.

func AddMethodLiteralElement

func AddMethodLiteralElement(rel string, src []byte, recvType, funcName, typeName, element string) ([]byte, error)

AddMethodLiteralElement appends "key: value" to the first composite literal of the named type inside the named method of recvType (a pointer or a value receiver), or inside the named function when recvType is empty. An element whose key the literal sets already is not added again: the source comes back unchanged.

func AddNamedImport

func AddNamedImport(rel string, src []byte, name, importPath string) ([]byte, error)

AddNamedImport adds an import path under the given name, an alias the file refers to the package by, or under the package's own name when the name is empty, to the file's first import block, or as an import declaration after the package clause when the file has none; a path the file imports already, under whatever name, is left as it is. The result is formatted.

func AddStatementsBeforeCall

func AddStatementsBeforeCall(rel string, src []byte, typeName, funcName, callee, statements string) ([]byte, error)

AddStatementsBeforeCall inserts statements before the first top-level statement of the named function that calls callee, a dotted name as the source writes it (deploy.SeedDevelopmentData, c.spannerClient.Close); typeName names the receiver type of a method, and is empty for a function.

func AddStatementsBeforeConstruction

func AddStatementsBeforeConstruction(rel string, src []byte, funcName, typeName, statements string) ([]byte, error)

AddStatementsBeforeConstruction inserts statements before the statement of the named function that builds the first "&Type{...}" literal: the plain "return &Type{...}, nil" of a fresh constructor, or the "v := &Type{...}" an earlier edit (WrapReturn) left in its place.

func AddStructField

func AddStructField(rel string, src []byte, typeName, field string) ([]byte, error)

AddStructField appends a field ("name Type", with any comment lines above it) to the named struct type. A field the struct declares already, by name, is not added again: the source comes back unchanged, so a transition run over an application that wired the field by hand adds nothing twice.

func AppendCallArgument

func AppendCallArgument(rel string, src []byte, funcName, callee, argument string) ([]byte, error)

AppendCallArgument adds an argument after the last one of the first call to callee, a dotted name as the source writes it, inside the named function, and renders the call one argument per line with a trailing comma, the shape a list of registrations keeps as it grows. The result is formatted.

func AuthPackageName

func AuthPackageName(file string) string

AuthPackageName returns the auth an authenticator construction belongs to, from its file's place in the tree (a package directly under an auth directory), or empty.

func BindOutletAuth

func BindOutletAuth(rel string, src []byte, outlet, declaration string) (out []byte, replaced bool, err error)

BindOutletAuth returns the program's source with the outlet's Auth option set to declaration (generation.Auth("<import path>", generation.PasswordMethod()), as a program writes it), and whether an Auth option was there to replace: the one the outlet declared is replaced, or the declaration is added after the outlet's prefix when it declared none. outlet is the outlet's name: the reserved default names the GenerateRoutes declaration, any other a WithRouterOutlet. The edit is textual, so the rest of the file's comments and layout survive; the result is formatted.

func ChainMethodFlag

func ChainMethodFlag(rel string, src []byte, importPath, name, flag string) (out []byte, edited int, err error)

ChainMethodFlag returns the program's source with a flag chained on the declaration of the method registered under name in every Auth option naming importPath, and how many declarations were edited. flag is the flag's method as the generation package spells it (SyncsRoles), appended after whatever the declaration chains already (generation.GoogleMethod("directory").Labeled("Company directory").SyncsRoles()). A declaration chaining the flag is left alone and not counted, so the edit is safe to run twice. The edit is textual, so the rest of the file's comments and layout survive; the result is formatted.

func CopyMethod

func CopyMethod(rel string, src []byte, recvType, name string, rename func(text string) string) ([]byte, error)

CopyMethod writes a copy of the named method of recvType (a pointer or a value receiver) after it, its doc comment included, as rename renders the copy's text: a method written for one auth, copied for another under the other's name. The result is formatted.

func DeclaresType

func DeclaresType(rel string, src []byte, name string) (bool, error)

DeclaresType reports whether the file declares the named type.

func ExtendCall

func ExtendCall(rel string, src []byte, funcName, callee, arguments string) ([]byte, error)

ExtendCall appends arguments to the first call to callee, a dotted name as the source writes it, inside the named function. The result is formatted.

func ExtendMethodCall

func ExtendMethodCall(rel string, src []byte, typeName, funcName, callee, arguments string) ([]byte, error)

ExtendMethodCall appends arguments to the first call to callee inside the named method of the type, or the named function when typeName is empty.

func FeatureConstant

func FeatureConstant(name string) string

FeatureConstant is the Go identifier a flag of the name takes when impulse declares it: the name in PascalCase (cargo_manifest becomes CargoManifest).

func HasCall

func HasCall(rel string, src []byte, typeName, funcName, callee string) (bool, error)

HasCall reports whether the named function, or the named method of the type when typeName is set, calls callee, a dotted name as the source writes it (scheduled.FromEnvironment). A function the file lacks is ErrNoAnchor.

func HasImport

func HasImport(rel string, src []byte, importPath string) (bool, error)

HasImport reports whether the file imports the path.

func ImportName

func ImportName(rel string, src []byte, importPath string) (string, error)

ImportName returns the name the file refers to the import path by, its alias or the path's last element, or empty when the file does not import it.

func InsertOptions

func InsertOptions(rel string, src []byte, after string, options []string) ([]byte, error)

InsertOptions returns the program's source with option calls added after the last option named after, or after the last option when after is empty. Each option is written as source text against the generation package under its own name (generation.WithRouterOutlet(...)), and is adjusted to the file's local import name. The edit is textual, so the file's comments and layout survive; the result is formatted.

func MethodConstructor

func MethodConstructor(kind string) string

MethodConstructor returns the generation package's constructor for a sign-in method (PasswordMethod for password, GoogleMethod for google), or empty for a method the generated router does not compose.

func MethodDeclaration

func MethodDeclaration(kind, name, label string) string

MethodDeclaration writes a new sign-in method's declaration as a generator program carries it, package-qualified: generation.PasswordMethod(), or generation.GoogleMethod("directory"), with .Labeled(label) when the label is set. A declaration read from a program is written back by AuthMethodArg.Declaration, which keeps the flags chained on it.

func MethodNames

func MethodNames(rel string, src []byte, typeName string) ([]string, error)

MethodNames lists the methods the file declares on the named type, through a pointer or a value receiver, in source order.

func MoveDefaultOutlet

func MoveDefaultOutlet(rel string, src []byte, prefix, mount string) ([]byte, error)

MoveDefaultOutlet returns the program's source with the default outlet's declaration moved: GenerateRoutes' prefix becomes prefix, and the mount path of its WebApp option, when it declares one, becomes mount. The edit is textual, so the rest of the file's comments and layout survive; the result is formatted.

func OptionText

func OptionText(rel string, src []byte, name, first string) (string, error)

OptionText returns the source text of the last option call named name whose first argument is the string literal first, or empty when the program has none.

func PackageName

func PackageName(rel string, src []byte) (string, error)

PackageName returns the file's package clause.

func RemoveFeatureAnnotations

func RemoveFeatureAnnotations(rel string, src []byte, constant string) (out []byte, removed int, err error)

RemoveFeatureAnnotations returns the Go source without every @feature(<constant>) annotation: a comment line that is the annotation alone goes whole, and the annotation leaves a line it shares with other text. The count says how many went.

func RemoveFeatureConstant

func RemoveFeatureConstant(rel string, src []byte, constant string) (out []byte, empty bool, err error)

RemoveFeatureConstant returns the file's source without the named constant (its doc comment and its line, or the whole declaration when it stood alone), dropping the resource import when nothing reads it any more, and reports whether the file declares nothing else now, so the caller deletes it.

func RemoveOptions

func RemoveOptions(rel string, src []byte, name, first string) (out []byte, removed int, err error)

RemoveOptions returns the program's source with every option call named name whose first argument is the string literal first removed, along with the comment lines that introduce it, and how many were removed. The edit is textual, so the rest of the file's comments and layout survive; the result is formatted.

func ReplaceNilArgument

func ReplaceNilArgument(rel string, src []byte, funcName, callee, replacement string) ([]byte, error)

ReplaceNilArgument rewrites, inside the named method or function, the first call to a function or method named callee that passes the identifier nil as an argument, so that the first such argument reads replacement. The result is formatted.

func RoleWriters

func RoleWriters(rel string, src []byte, authName string) []int

RoleWriters returns the lines of the file that assign or remove roles in the named auth's store: a role-writer call whose receiver reaches the auth's user manager through its accessor (<Name>()) or its variable (<name>Auth), and a call handing that user manager to a function of the same file whose body calls a role writer. A file that cannot be parsed has none.

func SpreadIntoCall added in v0.5.0

func SpreadIntoCall(rel string, src []byte, funcName, callee string, fixed int, slice string) ([]byte, error)

SpreadIntoCall adds a slice to the variadic arguments of the first call to callee, a dotted name as the source writes it, inside the named function. fixed is how many of the call's leading arguments are not variadic, and slice the expression that yields the slice. A call that passes no variadic argument yet gains the slice spread (f(a, slice...)); one that already passes some keeps them after the slice's, in one append (f(a, x) becomes f(a, append(slice, x)...)), since a call cannot spread a slice beside other variadic arguments. The result is formatted.

func StructFieldOfType

func StructFieldOfType(rel string, src []byte, structName, importPath, typeName string) (string, error)

StructFieldOfType returns the name of the first field of the named struct whose type is a pointer to typeName from the package at importPath, or empty.

func StructFieldOfValueType

func StructFieldOfValueType(rel string, src []byte, structName, importPath, typeName string) (string, error)

StructFieldOfValueType returns the name of the first field of the named struct whose type is typeName from the package at importPath itself, not a pointer to it (an interface such as jobs.Starter), or empty.

func WrapReturn

func WrapReturn(rel string, src []byte, funcName, typeName, varName, call, wrapErr string) ([]byte, error)

WrapReturn rewrites the "return &Type{...}, nil" of the named function so the literal is assigned to varName, the call runs against it, and its error is returned wrapped by wrapErr (an expression over err), before varName is returned.

Types

type AngularProject

type AngularProject struct {
	Name string
	// ProjectType is "application" or "library"; an entry naming neither is read as an
	// application.
	ProjectType string
	// Root and SourceRoot are the project's directories relative to the workspace.
	Root       string
	SourceRoot string
	// ProxyConfig is the serve option's proxy configuration file relative to the
	// workspace, or empty.
	ProxyConfig string
	// ServePath is the serve option's path the dev server serves the application
	// under, empty when unset (the dev server then serves at /).
	ServePath string
	// DevPort is the development serve configuration's port, 0 when unset.
	DevPort int
	// TestBuilder is the test target's builder, empty when the project has no test
	// target.
	TestBuilder string
	// TestTsConfig is the test target's tsConfig option relative to the workspace,
	// empty when the target names none (the builder then reads tsconfig.spec.json from
	// the project root).
	TestTsConfig string
	// Index is the build option's entry document relative to the workspace (a path, or
	// the input of the object form), empty when unset.
	Index string
	// AssetDirs are the inputs of the build option's assets entries, the directories the
	// build copies into the bundle root (public in a fresh workspace), relative to the
	// workspace; a string entry is taken as given.
	AssetDirs []string
	// BaseHref is the build option's base href, empty when unset (the build then writes /).
	BaseHref string
	// ServiceWorker is the production configuration's serviceWorker option as a path
	// relative to the workspace: the path it names, ngsw-config.json in the project root
	// when it is true, and empty when it is unset or false.
	ServiceWorker string
	// Defines are the global identifiers the production build defines (the define
	// option): the build options' entries with the production configuration's over them.
	Defines map[string]string
}

AngularProject is one project of a browser workspace's angular.json.

func ProjectFor

func ProjectFor(projects []AngularProject, rel string) (AngularProject, bool)

ProjectFor returns the project whose source root (or root) contains the workspace-relative path, preferring the deepest match, or false.

type App

type App struct {
	// Root is the absolute path of the application root (the directory holding go.mod).
	Root string
	// GoMod is the parsed root go.mod.
	GoMod *modfile.File
	// Generators are the resource generator programs found in the tree, one per site
	// plus the shared generator in the sites layout.
	Generators []*Generator
	// WebApps are the browser applications: every directory holding an angular.json.
	WebApps []WebApp
	// EmulatorImages are the Spanner emulator image tags named by process files
	// (Procfile, process-compose.yaml).
	EmulatorImages []EmulatorRef
	// EmulatorHarnesses are the Spanner emulator versions requested by test harnesses
	// through initiator.NewSpannerContainer.
	EmulatorHarnesses []EmulatorRef
	// FirestoreEmulatorImages are the Firestore emulator versions named by process files
	// and test harnesses through the Cloud SDK emulators image tag
	// (google-cloud-cli:<version>-emulators), and by test harnesses through
	// initiator.NewFirestoreContainer, which takes the same version: the emulator the live
	// pages run on in development.
	FirestoreEmulatorImages []EmulatorRef
	// EnvTags are the env struct tags declared by the application's Go code.
	EnvTags []EnvTag
	// EnvTemplate is the root-relative path of the development environment template
	// (.envrc.template or similar), or empty when the application has none.
	EnvTemplate string
	// DomainResources are the structs the application's own code annotates
	// @permissionScope(domain): the tenant-scoped resources.
	DomainResources []DomainResource
	// TenantRecords are the structs the application's own code annotates @tenant: each
	// resource package's tenant record, the global resource whose rows are the tenants.
	TenantRecords []TenantRecord
	// TenantDirectories are the structs the application's own code annotates
	// @tenantDirectory: each resource package's directories record, the tenant-scoped
	// resource whose rows are the directories a tenant admits its people through.
	TenantDirectories []DirectoryRecord
	// RosterConstructions are the constructions of a tenant roster outside tests: the
	// calls to a generated New<Record>Roster constructor, with what each is handed.
	RosterConstructions []RosterConstruction
	// Features are the feature flags the application declares: the resource.Feature
	// constants of its resources packages, in file order.
	Features []FeatureFlag
	// FeatureGates are the @feature annotations in the application's own code: the
	// resources, methods and fields behind a flag.
	FeatureGates []FeatureGate
	// DefaultRoles are the calls to access.WithDefaultRoles outside tests: where a
	// release hands its default roles, an auth package's embedded role file, to the
	// permission engine.
	DefaultRoles []DefaultRoles
	// PolicyChecks are the calls to CheckPolicy outside tests: the deploy step that
	// prints what the store holds that the release cannot use as written.
	PolicyChecks []PolicyCheck
	// RoleValidations are the calls to access.ValidateRoles in the application's tests:
	// where a role file's warnings are pinned in code.
	RoleValidations []RoleValidation
	// GrantProofs are the calls to the harness helper provesGrant in the application's
	// tests: where a test case names the conditional grant it proves.
	GrantProofs []GrantProof
	// OutletMembers are the structs the application's own code annotates @outlet: the
	// resources attached to router outlets other than, or in addition to, the default.
	OutletMembers []OutletMember
	// Auths are the session Auth constructions outside tests: the tables each reads and
	// the sign-in methods registered on it.
	Auths []Auth
	// UnattachedMethods are the sign-in methods registered on an Auth the scan cannot
	// find: the first argument names no construction in the file, and the package
	// constructs none or several.
	UnattachedMethods []Method
	// GoGenerate are the //go:generate directives in the tree.
	GoGenerate []Directive
	// CI is the application's //impulse:ci line, or nil without one: what its CI
	// workflow does where the code alone does not decide (which jobs run on the larger
	// runner, whether Go's test cache is used). At most one in the tree.
	CI *CIDirective
	// MainPackages are the root-relative directories holding a package main.
	MainPackages []string
	// AuthPackages are the auths: the packages under an auth directory constructing a
	// session Auth, with every reference to them, sorted by name.
	AuthPackages []AuthPackage
	// Engines are the permission engine constructions outside tests: every access.New
	// call, with whether it hands the engine a change signal (access.WithChangeSignal).
	Engines []Engine
	// SecretHolders are the packages carrying a generated list of the resources that
	// store a secret (zz_gen_secret_holders.go), and SecretRetirements the calls outside
	// tests that retire a version of the application secret
	// (resource.RetireSecretVersion), each with the packages whose list it is handed.
	SecretHolders     []SecretHolders
	SecretRetirements []SecretRetirement
	// contains filtered or unexported fields
}

App is the discovered shape of one Impulse application rooted at a Go module.

func Discover

func Discover(dir string) (*App, error)

Discover reads the application rooted at dir. dir must hold a go.mod.

func (*App) Abs

func (a *App) Abs(rel string) string

Abs returns the absolute path of a root-relative path.

func (*App) FeatureByName

func (a *App) FeatureByName(name string) []FeatureFlag

FeatureByName finds the declarations of the flag named name.

func (*App) FeatureUses

func (a *App) FeatureUses() ([]FeatureUse, error)

FeatureUses finds every hand-written reference to a declared flag's constant: in Go, the identifier in the declaring package or the qualified selector from another package, outside the declaration itself (an annotation is a comment and never an identifier); in the browser applications, Feature.<Constant> in TypeScript and templates. Generated files and build products are not read. The tree is opened as a root, so the walk stays inside it.

func (*App) GatesOf

func (a *App) GatesOf(constant string) []FeatureGate

GatesOf lists the gates naming the constant.

func (*App) GoFiles

func (a *App) GoFiles() []string

GoFiles lists the non-test Go files of the application, root-relative.

func (*App) ModuleDir

func (a *App) ModuleDir(importPath string) (string, bool)

ModuleDir returns the root-relative directory an import path names inside the application's module, or false for a path outside it (or when the module path is not known).

func (*App) Profile

func (a *App) Profile() Profile

Profile reads the option set in force from the generator programs.

func (*App) ProgramDir

func (a *App) ProgramDir(g *Generator) string

ProgramDir is the root-relative directory go run runs the generator program from: the target of the //go:generate directive that runs it, when one does, since a program declared in a package of its own runs through the main package beside it, and the program's own directory otherwise.

func (*App) ReadAngular

func (a *App) ReadAngular(webDir string) ([]AngularProject, error)

ReadAngular reads the projects of the browser workspace at the root-relative directory, sorted by name.

func (*App) Rel

func (a *App) Rel(abs string) string

Rel returns the root-relative, slash-separated form of an absolute path under Root.

func (*App) RunsGenerator

func (a *App) RunsGenerator(g *Generator) (Directive, bool)

RunsGenerator reports whether a //go:generate directive runs the generator program: `go run` of the program's own directory, relative to the directive's file or as an import path under the module, or `go run` of a main package in the module that imports the program's package. The second is the layout an application takes when tests run the declaration in-process (a main package cannot be imported), so the declaration lives in a package of its own and the runner beside it calls it; go generate runs the program through the runner.

func (*App) SharedGenerators

func (a *App) SharedGenerators() []*Generator

SharedGenerators returns the generators that emit no handlers: the shared resource generators of an application in the sites layout.

func (*App) SiteGenerators

func (a *App) SiteGenerators() []*Generator

SiteGenerators returns the generators that emit handlers: one per site.

func (*App) WebAppFor

func (a *App) WebAppFor(rel string) (WebApp, bool)

WebAppFor returns the browser application whose directory contains the root-relative path, or false when no browser application contains it.

type Arg

type Arg struct {
	Kind ArgKind
	// Str holds a string literal's value, for ArgIdent the identifier, and for
	// ArgConstructor the call.
	Str  string
	Bool bool
	Int  int64
	List []string
	// Map holds string- and bool-valued maps; bool values are rendered as "true"/"false".
	Map map[string]string
	// Call is set for ArgCall: a nested option such as generation.GenerateEnums().
	Call *Call
	// Method is set for ArgAuthMethod: the sign-in method declared.
	Method *AuthMethodArg
	// Text is the source text of an argument the tool cannot interpret.
	Text string
}

Arg is one literal argument of an option call.

type ArgKind

type ArgKind int

ArgKind classifies an option argument.

const (
	ArgOther ArgKind = iota
	ArgString
	ArgBool
	ArgStringList
	ArgStringMap
	ArgBoolMap
	ArgCall
	ArgComposite
	// ArgIdent is a qualified identifier of the generation package (generation.ThisRelease);
	// Str holds the identifier.
	ArgIdent
	// ArgInt is a whole number: an integer literal, or a constant expression of integer
	// literals (2<<20); Int holds the value.
	ArgInt
	// ArgConstructor is a call to one of the generation package's value constructors, a
	// request log word or a trace setting, with its MinSeverity floor when one is chained;
	// Str holds the call without the package qualifier, as
	// LogSampled(0.1).MinSeverity(logging.Warning).
	ArgConstructor
	// ArgAuthMethod is a sign-in method declaration, a call to one of the generation
	// package's method constructors with its label when one is chained; Method holds it.
	ArgAuthMethod
)

The argument kinds a generator program may use. Anything else is ArgOther, which the tool cannot interpret and reports as a problem.

type Auth

type Auth struct {
	File string
	Line int
	// Var is the identifier the construction is assigned to (x, err := session.NewAuth(...)),
	// which the method registrations name as their first argument; empty when the
	// construction is not assigned to one.
	Var string
	// SessionTable is the sessions table the Auth reads: WithSessionTableName or the
	// library default.
	SessionTable string
	// UserTable is the users table: WithUserTableName or the library default.
	UserTable string
	// IdentitiesTable is the identity links table: WithIdentitiesTableName or the library
	// default.
	IdentitiesTable string
	// PendingTable is the pending sign-ins table: WithPendingSignInsTableName or the
	// library default.
	PendingTable string
	// AttemptsTable is the sign-in attempts table the password method's attempt limiter
	// counts in: WithSignInAttemptsTableName or the library default.
	AttemptsTable string
	// SignInMethodsTable is the table that keeps what an administrator chose for each
	// sign-in method, open to sign-up or invite only, which every sign-in reads:
	// WithSignInMethodsTableName or the library default.
	SignInMethodsTable string
	// MailLinksTable is the mail links table the Auth's invitations, address
	// verifications and sign-ups are kept in: WithMailLinksTableName or the library
	// default. Read when the Auth sends mail (Mail).
	MailLinksTable string
	// Mail reports an Auth constructed with session.WithMail: it mails invitations,
	// address verifications, sign-up links and sign-in codes, and reads the mail links,
	// sign-in codes and trusted devices tables.
	Mail bool
	// FactorCodesTable is the sign-in codes table the second factor's mailed codes are
	// kept in, and TrustedDevicesTable the browsers people asked to be remembered after
	// a code: WithFactorCodesTableName and WithTrustedDevicesTableName or the library
	// defaults. Read when the Auth sends mail (Mail), since the code is mailed.
	FactorCodesTable    string
	TrustedDevicesTable string
	// TokensTable is the tokens table the bearer tokens the Auth issues are kept in,
	// and DeviceCodesTable the device authorizations command-line clients wait on:
	// WithTokensTableName and WithDeviceCodesTableName or the library defaults. Read
	// when a machine outlet names the Auth as the issuer of its tokens.
	TokensTable      string
	DeviceCodesTable string
	// AuthEventsTable is the auth events table the storage attaches
	// (sessionstorage.WithAuthEvents over NewAuthEventsTable), when its name is a literal
	// or a constant of the file; empty when the storage attaches none or the name does
	// not read.
	AuthEventsTable string
	// AuthEvents reports a storage constructed with sessionstorage.WithAuthEvents.
	AuthEvents bool
	// ExtraTables are the custom session and user data tables the storage attaches
	// (sessionstorage.NewCustomSessionData and NewCustomUserData), when their names are
	// literals.
	ExtraTables []string
	// CookieName is the WithCookieName argument, or empty for the library default.
	CookieName string
	// XSRFCookieName is the WithXSRFCookieName argument, or empty for the library default.
	XSRFCookieName string
	// TrustedDeviceCookieName is the WithTrustedDeviceCookieName argument, the cookie a
	// remembered browser carries its token in, or empty for the library default.
	TrustedDeviceCookieName string
	// Impersonation reports a storage constructed with sessionstorage.WithImpersonation.
	Impersonation bool
	// ImpersonationTable is the impersonation table's name when the code states it: a
	// literal or a constant of the file, given to NewImpersonationTable inside the storage
	// constructor or assigned to the identifier WithImpersonation takes. Empty otherwise
	// (the library default is then assumed).
	ImpersonationTable string
	// OptionsForwarded reports a variadic pass-through (opts...) in the call: options
	// the callers add are not visible here, so the tables are the defaults as far as
	// this construction shows.
	OptionsForwarded bool
	// SuperAdministrators is what the construction tells the Auth about its super
	// administrators: the argument session.NewAuth takes after the cookie key.
	SuperAdministrators SuperAdministrators
	// Methods are the sign-in methods registered on the Auth, in source order: the
	// password method (session.PasswordSignIn) and the redirect methods (azure.SignIn,
	// google.SignIn, workos.SignIn, and oidc.SignIn, the persona method) whose first
	// argument names this construction.
	Methods []Method
}

Auth is one construction of a session Auth (session.NewAuth): the users store it opens, the tables it reads, its cookies, and the sign-in methods registered on it.

type AuthMethodArg

type AuthMethodArg struct {
	// Kind is the method: password, google, azure, workos, oidc, or persona.
	Kind string
	// Name is the registration name; password for the password method.
	Name string
	// Label is the label the declaration chains (.Labeled), or empty for the generation
	// package's default.
	Label string
	// SyncsRoles is set when the declaration chains .SyncsRoles(): the directory writes
	// the user's roles at every sign-in (its role groups, or the token's application
	// roles), as the registration's RoleSync does, so the generated management shows them
	// as the directory's and never writes them.
	SyncsRoles bool
	// UsernameIsEmail is set when the declaration chains .UsernameIsEmail(): the
	// password method's sign-in name is the person's email address, so the users
	// surface derives the address from the username.
	UsernameIsEmail bool
}

AuthMethodArg is a sign-in method as an outlet's Auth option declares it.

func (*AuthMethodArg) Declaration

func (m *AuthMethodArg) Declaration() string

Declaration writes the declaration as a generator program carries it, package-qualified: the constructor with its registration name, then .Labeled(label), .SyncsRoles() and .UsernameIsEmail() for what is set. Empty for a method the generated router does not compose.

type AuthPackage

type AuthPackage struct {
	// Name is the auth's name, the package's directory name.
	Name string
	// Dir is the package's root-relative directory.
	Dir string
	// Path is the package's import path.
	Path string
	// Refs are the files referencing the package, with the identifiers they take from it.
	Refs []AuthRef
}

AuthPackage is one auth: a package under an auth directory constructing a session authenticator, with every reference to it from the rest of the application.

func (*AuthPackage) References

func (p *AuthPackage) References(name string, excluding func(file string) bool) []string

References reports whether some file outside the excluded directories uses the identifier.

type AuthRef

type AuthRef struct {
	File string
	// Names are the package-level identifiers the file uses, sorted and without repeats.
	Names []string
}

AuthRef is one file's references to an auth package.

type CIDirective

type CIDirective struct {
	File string
	Line int
	// LargeRunner lists the jobs the line puts on the larger runner, by job id; empty
	// (and non-nil) for large-runner=none, nil when the line does not set it.
	LargeRunner []string
	// TestCache is the test-cache value, on or off; nil when the line does not set it.
	TestCache *bool
	// DefaultBranch is the default-branch value, a branch name; empty when the line
	// does not set it (main and master need no setting).
	DefaultBranch string
}

CIDirective is the //impulse:ci line: a comment line in any non-test Go file of the application, of the form

//impulse:ci large-runner=go-test,go-test-skipauth,image test-cache=on

with each setting at most once and in any order (a directive in Go's sense, which gofmt keeps as written and, at the end of a doc comment, sets off with a blank // line). large-runner lists the CI jobs that run on the larger runner the variable CI_LARGE_RUNNER names (or none, for no job); test-cache is on or off; default-branch names the repository's default branch when it is neither main nor master, so the cache-filling workflow runs on it. A setting the line leaves out keeps impulse's default (the ci package states them); a line with a setting it does not know, or a second line in the tree, is an error at discovery.

type Call

type Call struct {
	// Name is the option constructor's name, without the package qualifier.
	Name string
	// Pos is the call's position as file:line.
	Pos string
	// Args are the call's arguments in order.
	Args []Arg
}

Call is one option call such as generation.GenerateHandlers("app").

func (Call) String

func (c Call) String() string

String renders a call as source-like text for messages.

type DefaultRoles

type DefaultRoles struct {
	File string
	Line int
	// RolesPackage is the import path of the package whose Roles() the call hands over:
	// the file's own package when the argument is Roles() unqualified, the imported
	// package when it is <auth>.Roles(), or empty when the argument reads some other way.
	RolesPackage string
}

DefaultRoles is one call to access.WithDefaultRoles outside tests: a release handing a role file to the permission engine.

type Directive

type Directive struct {
	File string
	Line int
	// Command is the directive's command line.
	Command string
}

Directive is one //go:generate directive.

type DirectoryRecord

type DirectoryRecord struct {
	File string
	Line int
	Name string
	// DefaultSeatField is the field annotated @directoryDefaultSeat; empty when the
	// record carries none.
	DefaultSeatField string
	// DefaultSeatName is the default seat field's name on the wire, which the role files
	// grant it by: its json tag, or the field's name in camel case, as the generator
	// writes it.
	DefaultSeatName string
}

DirectoryRecord is one struct annotated @tenantDirectory: the directories record, the tenant-scoped resource whose rows are the directories a tenant admits its people through, one row per declaration, with the column naming a stranger's default seat when the record carries one: the role a stranger the directory vouches for is seated with at their first sign-in, NULL where the tenant admits them by invitation only.

type DomainResource

type DomainResource struct {
	File string
	Line int
	Name string
}

DomainResource is one struct annotated @permissionScope(domain).

type EmulatorRef

type EmulatorRef struct {
	File    string
	Line    int
	Version string
}

EmulatorRef is one place an emulator version is named.

type Engine

type Engine struct {
	File string
	Line int
	// Package is the root-relative directory of the package constructing the engine.
	Package string
	// ChangeSignal reports an access.WithChangeSignal option among the call's arguments:
	// the engine is handed the signal that carries policy changes between the
	// application's instances.
	ChangeSignal bool
	// OptionsForwarded reports a variadic pass-through (opts...) in the call: options the
	// callers add are not visible here.
	OptionsForwarded bool
}

Engine is one construction of a permission engine outside tests: a call to access.New.

type EnvTag

type EnvTag struct {
	File       string
	Line       int
	Name       string
	Required   bool
	HasDefault bool
	// Secret reports the field's secret tag, secret:"true", secret:"generated" or
	// secret:"versioned": the variable holds a credential that the infrastructure mounts
	// from a secret store. Generated reports the last two: a value the tooling makes and
	// nobody types. Versioned reports the last: a generated secret kept in versions,
	// every enabled one of which is handed to the service, each in a variable of its own
	// named by Name, an underscore and the version's number (VersionedName); no variable
	// is named Name itself.
	Secret    bool
	Generated bool
	Versioned bool
	// Origin names the framework settings struct that declares the variable when the
	// application embeds one instead of declaring the field itself, as import path and
	// type name (github.com/impulseframework/impulse/cloud/gcp.Settings); the tag stands at the
	// embedding's line. Empty for a field the application declares.
	Origin string
}

EnvTag is one env struct tag declared in the application's Go code.

func (EnvTag) VersionedName added in v0.5.0

func (t EnvTag) VersionedName(version int) string

VersionedName is the variable one version of a versioned secret is handed over in: the declared name, an underscore and the version's number (APP_SECRET_KEY_2).

type FeatureFlag

type FeatureFlag struct {
	File string
	Line int
	// Constant is the constant's identifier: what @feature(<Constant>) names, and the key
	// of the browser's generated Feature constants (Feature.<Constant>).
	Constant string
	// Name is the constant's value, the flag's name.
	Name string
	// Description is the constant's doc comment on one line, as the generator reads it.
	Description string
	// Package is the import path of the package declaring the constant.
	Package string
}

FeatureFlag is one feature flag declaration: a constant of type resource.Feature in a resources package, whose identifier @feature names, whose value is the flag's name as the FeatureFlags table holds it, and whose doc comment is the description the flags dialog shows.

type FeatureGate

type FeatureGate struct {
	File string
	Line int
	// Constant is the identifier the annotation names.
	Constant string
	// Target is what the annotation gates: the struct's name, or Struct.Field for a
	// field.
	Target string
}

FeatureGate is one @feature(<Constant>) annotation: a resource, method or field put behind a flag.

type FeatureUse

type FeatureUse struct {
	File string
	Line int
	// Constant is the flag's constant.
	Constant string
	// Test reports a reference in a Go test file or a browser spec.
	Test bool
}

FeatureUse is one hand-written reference to a flag's constant outside its declaration and its gates: Go code reading the flag (resources.Debriefs) or browser code reading the generated constant (Feature.Debriefs).

type Generator

type Generator struct {
	// File is the root-relative path of the Go file holding the program.
	File string
	// ResourcePackageDir is the first positional argument: the resource package directory.
	ResourcePackageDir string
	// MigrationSources is the second positional argument: the migration source URLs.
	MigrationSources []string
	// LocalPackages are the import paths the WithImports calls name, in order: paths the
	// generated code may reference beyond what the generator derives from the packages it
	// loads and writes (each one a generator gap the application carries until it is
	// fixed).
	LocalPackages []string
	// Options are the option calls passed after the positional arguments, in order.
	Options []Call
	// Problems are the places the program could not be read as literal configuration:
	// unknown options, non-literal arguments, wrong arities.
	Problems []Problem
	// ReadsWarnings reports that the program reads Warnings() after it generates: a call
	// in the program's own package, or in the main package of the module that imports it
	// (the runner beside a declaring package). A program that never reads them lets the
	// schema warnings a generation raises go unseen.
	ReadsWarnings bool
}

Generator is one resource generator program: a call to generation.NewResourceGenerator with its positional arguments and option calls.

func ParseGenerator

func ParseGenerator(rel string, src []byte) (*Generator, error)

ParseGenerator reads one Go source file and returns the generator program it holds, or nil when the file makes no generation.NewResourceGenerator call. Discover reads the programs in the tree; this reads one from elsewhere, such as an earlier version of the file held by version control.

func (*Generator) EmulatorVersion

func (g *Generator) EmulatorVersion() string

EmulatorVersion is the WithSpannerEmulatorVersion argument, or empty.

func (*Generator) HandlerTestsDir

func (g *Generator) HandlerTestsDir() string

HandlerTestsDir is the GenerateHandlerTests target directory, or empty.

func (*Generator) HandlersDir

func (g *Generator) HandlersDir() string

HandlersDir is the GenerateHandlers target directory, or empty when the generator emits no handlers (a shared generator).

func (*Generator) IdentityDir added in v0.3.0

func (g *Generator) IdentityDir() string

IdentityDir is the GenerateIdentity tree, the directory the generator writes the management of every declared auth into and owns whole, or empty.

func (*Generator) MountedRoutes

func (g *Generator) MountedRoutes() []MountedRoutes

MountedRoutes returns every WithMountedRoutes declaration, in order.

func (*Generator) Option

func (g *Generator) Option(name string) (Call, bool)

Option returns the first option call with the name, or false.

func (*Generator) OptionsNamed

func (g *Generator) OptionsNamed(name string) []Call

OptionsNamed returns every option call with the name, in order.

func (*Generator) RPCDir

func (g *Generator) RPCDir() string

RPCDir is the WithRPC package directory, or empty.

func (*Generator) RequestLog

func (g *Generator) RequestLog() string

RequestLog is the WithRequestLog word, the application's request log default, as the program declares it (LogOnEvent().MinSeverity(logging.Warning)), or empty when the program declares none and every request's entry is written.

func (*Generator) RoutesDir

func (g *Generator) RoutesDir() string

RoutesDir is the GenerateRoutes target directory, or empty.

func (*Generator) TypesDirs

func (g *Generator) TypesDirs() []string

TypesDirs are the WithTypes package directories, in option order; the option may be given more than once.

func (*Generator) TypescriptTargets

func (g *Generator) TypescriptTargets() []TSTarget

TypescriptTargets returns every GenerateTypescript target, in order.

type GrantProof

type GrantProof struct {
	File string
	Line int
	// RolesPackage is the import path of the auth package whose Roles() the call hands
	// the helper: the role file the proof is about.
	RolesPackage string
	Role         string
	Permission   string
	Resource     string
	Condition    string
	// Problem says why the call cannot be read, or is empty: the wrong number of
	// arguments, a role file that is not an imported package's Roles() call, or a
	// coordinate that is neither a literal nor a constant of the file.
	Problem string
}

GrantProof is one call to the harness helper in a test file: a case's claim that it proves the named conditional grant of a role file.

type Layout

type Layout int

Layout is how an application's sites are laid out in the tree.

const (
	// LayoutFlat has one site at the application root: app/, pkg/, web/.
	LayoutFlat Layout = iota
	// LayoutSites has every site under apps/<site>/, with the shared packages at the root.
	LayoutSites
)

The layouts. An application starts flat and is promoted to LayoutSites when it grows a second site: the site's packages move under apps/<site>/ and the shared packages stay at the root.

func (Layout) String

func (l Layout) String() string

type Method

type Method struct {
	File string
	Line int
	// Kind is the method: password, azure, google, workos, oidc, or persona.
	Kind string
	// Name is the registration name: the segment of the method's login and callback
	// routes (user/<name>/login). The password method is always registered as password.
	Name string
	// Authority is who owns role membership for a directory method: AuthorityDirectory
	// when the registration's RoleSync is signin.RoleSync or google.RoleSync,
	// AuthorityApplication for DisableRoleSync, and empty for the password method or a
	// slot the scan does not read.
	Authority string
	// Tenants is the tenant shape of a Microsoft registration, read from the slot
	// function its configuration's Tenants slot calls (readTenants): TenantsOne for
	// azure.Tenant or azure.NamedTenant alone, TenantsListed for azure.Tenants of several
	// tenants or a tenant built in a loop, TenantsAny for azure.AnyTenant (alone or beside
	// listed tenants) and TenantsPersonal for azure.PersonalAccounts alone. Empty for
	// another method, and for a slot written any other way, which bedrock refuses.
	Tenants string
	// PersonalAccounts reports a Microsoft registration admitting Microsoft personal
	// accounts (azure.PersonalAccounts), alone (TenantsPersonal) or beside the tenants
	// Tenants describes.
	PersonalAccounts bool
	// Workspaces is the Workspace shape of a Google registration, read from the building
	// blocks its configuration's Workspaces slot is made of (readWorkspaces):
	// WorkspacesOne for google.Workspace alone, WorkspacesListed for google.Workspaces of
	// several Workspaces or a Workspace built in a loop, WorkspacesAny for
	// google.AnyWorkspace (alone or beside listed Workspaces) and WorkspacesAccounts for
	// google.AnyGoogleAccount alone. Empty for another method, and for a slot written any
	// other way.
	Workspaces string
	// GoogleAccounts reports a Google registration admitting any Google account
	// (google.AnyGoogleAccount), alone (WorkspacesAccounts) or beside the Workspaces
	// Workspaces describes.
	GoogleAccounts bool
	// SeveralDomains reports a Google registration that names a Workspace with more
	// than one domain, or with a spread of them (google.Workspace(name, domains...)).
	// It changes nothing of Workspaces, which counts Workspaces: such a registration
	// may still read WorkspacesOne. It is for a rule that counts organizations as the
	// sign-in does, which lists a Workspace by each of its domains
	// (signin.Audience.OneOrganization), so one Workspace of two domains is not one
	// organization to it.
	SeveralDomains bool
	// AuthVar is the identifier the registration's first argument names: the Auth it is
	// registered on. The scan attaches the method to that construction, or to the only
	// Auth of its package when the identifier does not resolve.
	AuthVar string
	// UsernameIsEmail reports a password method registered with
	// session.UsernameIsEmail(): the sign-in name is the person's email address, and the
	// outlet's declaration chains .UsernameIsEmail() so the generated management says so.
	UsernameIsEmail bool
}

Method is one sign-in method registered on an Auth.

func (*Method) Directory

func (m *Method) Directory() bool

Directory reports a method whose people sign in through a directory or an identity provider the browser is sent to: every kind but the password method.

type MountedRoutes

type MountedRoutes struct {
	Prefix     string
	RequestLog string
	Traces     string
	// Pos is the position of the WithMountedRoutes call.
	Pos string
}

MountedRoutes is one WithMountedRoutes declaration: a path prefix the application mounts routes under by hand, with the request log word and the trace setting declared for it, as the program writes them (LogOnEvent(), TracesOff()).

type Outlet

type Outlet struct {
	Name   string
	Prefix string
	// ServesSessions reports a session outlet: the ServesSessions option, a session Auth,
	// or the default outlet.
	ServesSessions bool
	// Auth is the outlet's Auth option under the generated router, nil when it declares
	// none.
	Auth *OutletAuth
	// Tokens is the Tokens option's import path: the auth package whose Auth issues the
	// tokens a machine outlet's requests carry, under the generated router. Empty when
	// the outlet declares none.
	Tokens string
	// APIKey reports the APIKey option, the retired form of a machine outlet, which the
	// generator refuses: the check names Tokens as its replacement.
	APIKey bool
	// WebApp is the WebApp option's mount path, empty when the outlet serves none.
	WebApp string
	// OldestAnswered is the OldestAnswered option's release, the oldest release of the
	// browser application the outlet still answers: a semantic version as written,
	// ThisRelease for the server's own release, or empty when the outlet declares none
	// (every release that sends one is answered).
	OldestAnswered string
	// RequestLog is the OutletRequestLog word as the program writes it
	// (LogNever()), empty when the outlet declares none and takes the application's.
	RequestLog string
	// Traces is the OutletTraces setting as the program writes it (TracesOff()), empty
	// when the outlet declares none and its spans follow the front end.
	Traces string
	// Programs are the ShipsProgram declarations, in order: the programs the release
	// ships and a machine outlet serves to their installed copies. A session outlet
	// declares none; the shipped-programs check names Tokens for one that does.
	Programs []Program
	// Pos is the position of the declaring call.
	Pos string
}

Outlet is one outlet declaration: GenerateRoutes for the default outlet, a WithRouterOutlet call for an additional one.

func (*Outlet) Machine

func (o *Outlet) Machine() bool

Machine reports a machine outlet: one that declares Tokens, or the retired APIKey.

type OutletAuth

type OutletAuth struct {
	ImportPath string
	Methods    []AuthMethodArg
}

OutletAuth is one Auth option: the auth package the outlet binds to and the sign-in methods it declares on it, in declaration order, as the generation package names them.

func (OutletAuth) Directory

func (a OutletAuth) Directory() bool

Directory reports whether any declared method sends the browser to a directory or an identity provider: every method but the password method.

func (OutletAuth) Method

func (a OutletAuth) Method(name string) *AuthMethodArg

Method returns the declared method registered under the name, or nil.

type OutletMember

type OutletMember struct {
	File string
	Line int
	Name string
	// Outlets are the outlet names the annotation lists.
	Outlets []string
}

OutletMember is one struct annotated @outlet(...).

type PolicyCheck

type PolicyCheck struct {
	File string
	Line int
}

PolicyCheck is one call to CheckPolicy outside tests: the deploy step printing what the store holds that the release cannot use as written.

type Problem

type Problem struct {
	Pos     string
	Message string
}

Problem is one place a generator program departs from literal configuration.

func (Problem) String

func (p Problem) String() string

type Profile

type Profile struct {
	Layout Layout
	// Sites are the generators that emit handlers, one per site, in generator order.
	Sites []Site
	// Shared are the generators that emit no handlers: the shared resource generators of
	// an application in the sites layout.
	Shared []*Generator
	// FileStore is the env tag that wires the framework's file store, APP_FILE_STORE
	// (impulse add files), nil when the application has none: the data level opens the
	// store from it and builds the resource client over it.
	FileStore *EnvTag
}

Profile is the option set in force across an application: the axes of the composed skeleton — layout, sites, tenancy, outlets — as the generator programs declare them, tenancy from the resource package's tenant record (@tenant). It is read, never recorded: a transition that adds an option is done when the profile shows it.

func (Profile) OutletNames

func (p Profile) OutletNames() []string

OutletNames lists every outlet name declared by any site, sorted and without repeats.

func (Profile) SiteNames

func (p Profile) SiteNames() []string

SiteNames lists the sites' names in order.

type Program

type Program struct {
	// Dir is the root-relative directory of the program's main package: cmd/corral.
	Dir string
	// Name is the program's name, the directory's base: corral.
	Name string
	// Platforms are the platforms the release compiles the program for, each <os>/<arch>
	// as the Platforms option names them, in declaration order.
	Platforms []string
	// Pos is the position of the declaring call.
	Pos string
}

Program is one ShipsProgram declaration: a program the release ships, which the image build compiles for each platform and the declaring machine outlet serves to the copies installed on machines, behind its token check.

type RoleValidation

type RoleValidation struct {
	File string
	Line int
	// RolesPackages are the import paths of the packages whose Roles() the file calls,
	// sorted and without repeats; the role files the call validates.
	RolesPackages []string
}

RoleValidation is one call to access.ValidateRoles in a test file: the role files it validates are the auth packages whose Roles() the file calls.

type RosterConstruction

type RosterConstruction struct {
	File string
	Line int
	// Package is the root-relative directory of the package constructing the roster.
	Package string
	// Constructor is the constructor's name (NewTenantRoster for a record named Tenant).
	Constructor string
	// Holder is the name the construction's result is bound to: the variable of a
	// definition or assignment (the field's name when the left side is a selector), or
	// the key of a composite literal element; empty when the result is used some other
	// way, such as returned.
	Holder string
	// Signals reports a resource.WithTenantSignals option among the call's arguments:
	// the roster reloads on the tenants signal, not at its backstop alone.
	Signals bool
}

RosterConstruction is one call outside tests to a generated tenant roster constructor (New<Record>Roster).

type SecretHolders added in v0.5.0

type SecretHolders struct {
	// File is the generated file, root-relative, and Package the import path of the
	// package it is in.
	File    string
	Package string
	// Stored reports that the list names a resource: the package stores a secret.
	Stored bool
}

SecretHolders is one resources package's generated list of the resources that store a secret: the SecretHolders() the generator writes into zz_gen_secret_holders.go.

type SecretRetirement added in v0.5.0

type SecretRetirement struct {
	File string
	Line int
	// Packages are the import paths of the packages whose SecretHolders() the call is
	// handed, in the call or through a variable of its function, sorted.
	Packages []string
	// Unread reports holders the call takes from where the scan does not read: a
	// parameter, a function of the application's own, a list written by hand.
	Unread bool
}

SecretRetirement is one call to resource.RetireSecretVersion outside tests: where a version of the application secret is retired, and what it reads.

type Site

type Site struct {
	// Name is the site's directory name under apps/ in the sites layout, or the
	// module path's last element in the flat layout.
	Name string
	// Dir is the root-relative directory holding the site's packages: apps/<site> in the
	// sites layout, "." in the flat layout.
	Dir       string
	Generator *Generator
	// TenantRecord is the @tenant struct of the site's resource package, nil when the
	// site is not tenanted: the generator derives the tenant segment and its route
	// parameter from the record and emits the constructor of the roster the application
	// builds over it.
	TenantRecord *TenantRecord
	// Directories is the @tenantDirectory struct of the site's resource package, nil
	// when the tenant record declares no directories: the directories record, whose rows
	// are the directories a tenant admits its people through.
	Directories *DirectoryRecord
	// ConcealedDomains reports WithConcealedDomains.
	ConcealedDomains bool
	// GeneratedRouter reports GenerateRouter: the router is generated from the outlet
	// declarations instead of hand-written.
	GeneratedRouter bool
	// Default is the outlet GenerateRoutes declares, with the outlet options it carries;
	// its Name is the reserved default.
	Default Outlet
	// Outlets are the WithRouterOutlet declarations, in order. The default outlet
	// GenerateRoutes declares is Default, not listed here.
	Outlets []Outlet
}

Site is one site: the generator program that emits its handlers and what that program declares about it.

func (*Site) AllOutlets

func (s *Site) AllOutlets() []Outlet

AllOutlets lists the site's outlets, the default first.

func (*Site) Tenanted

func (s *Site) Tenanted() bool

Tenanted reports whether the site's resource package declares a tenant record.

type SuperAdministrators added in v0.5.0

type SuperAdministrators struct {
	// Form is SuperAdministratorsNone or SuperAdministratorsChecked, or empty when the
	// argument reads some other way (a parameter of the enclosing function, say).
	Form string
	// EngineLine is the line of the permission engine's construction (access.New) the
	// check is built over, when the enclosing function opens the engine itself and the
	// check takes its user manager (x.UserManager(), with x, err := access.New(...)
	// before it); zero when the engine is opened somewhere the function does not show.
	EngineLine int
	// RolesPackage is the import path of the package whose Roles() that engine is
	// handed (access.WithDefaultRoles among the construction's arguments), which says
	// whose engine it is: the file's own package for Roles() unqualified, the imported
	// package for <auth>.Roles(). Empty when no engine reads or its roles read some
	// other way.
	RolesPackage string
	// Packages are the import paths of the packages the check's expression names up
	// to the engine, sorted and without repeats: the session library's own, and
	// another auth package's when the check is taken from one.
	Packages []string
}

SuperAdministrators is what one Auth construction is told about its super administrators, read from the argument session.NewAuth takes after the cookie key, written in the call or assigned to the identifier the call takes.

type TSTarget

type TSTarget struct {
	// Dir is the root-relative target directory.
	Dir string
	// Outlet is the ForOutlet name, or empty for the default outlet.
	Outlet string
	// Pos is the position of the GenerateTypescript call.
	Pos string
}

TSTarget is one GenerateTypescript target.

type TenantRecord

type TenantRecord struct {
	File string
	Line int
	Name string
}

TenantRecord is one struct annotated @tenant: the tenant record, the global resource whose rows are the tenants, whose route name is the segment tenant-scoped routes are served under, and whose generated constructor builds the application's tenant roster.

type WebApp

type WebApp struct {
	// Dir is the root-relative directory holding angular.json.
	Dir string
}

WebApp is one browser application.

Jump to

Keyboard shortcuts

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