Documentation
¶
Index ¶
- Constants
- Variables
- type App
- type AppType
- type Build
- type Command
- type CommandSpec
- type Contact
- type Definition
- func (d *Definition) ApplyDefaults() error
- func (d *Definition) ContainsGo() bool
- func (d *Definition) ContainsJS() bool
- func (d *Definition) FilterTerraformManaged() (*Definition, SkippedItems)
- func (d *Definition) GetAppsByType(appType AppType) []App
- func (d *Definition) GithubLabels() []string
- func (d *Definition) HasAppType(appType AppType) bool
- func (d *Definition) MergeAllEnvironments() Environment
- type Domain
- type DomainType
- type EnvSource
- type EnvValue
- type EnvVar
- type EnvWalkEntry
- type Environment
- type EnvironmentWalker
- type EnvironmentWalkerE
- type GitHubRepo
- type Infra
- type MenuItem
- type Project
- type Resource
- type ResourceBackupConfig
- type ResourceProvider
- type ResourceType
- type Shared
- type SkippedItems
- type Social
Constants ¶
const ( // JsonFileName defines the file name of the app manifest, // that should appear in the root of each webkit dir. JsonFileName = "app.json" )
Variables ¶
var Commands = []Command{ CommandFormat, CommandLint, CommandTest, CommandBuild, }
Commands defines all the Commands available that should be run in order.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
Name string `json:"name"`
Title string `json:"title"`
Type AppType `json:"type"`
Description string `json:"description,omitempty"`
Path string `json:"path"`
Build Build `json:"build"`
Infra Infra `json:"infra"`
Env Environment `json:"env"`
UsesNPM *bool `json:"usesNPM"`
TerraformManaged *bool `json:"terraformManaged,omitempty"`
Domains []Domain `json:"domains,omitzero"`
Commands map[Command]CommandSpec `json:"commands,omitzero" jsonschema:"oneof_type=boolean;object;string"`
}
func (*App) IsTerraformManaged ¶ added in v0.0.8
IsTerraformManaged returns whether this app should be managed by Terraform. It defaults to true when the field is nil or explicitly set to true.
func (*App) Language ¶
Language determines what language ecosystem a given app is. Either "go" or "js".
func (*App) MergeEnvironments ¶
func (a *App) MergeEnvironments(shared Environment) Environment
MergeEnvironments merges the shared env with the apps, with the app specific variables taking precedence.
func (*App) OrderedCommands ¶
func (a *App) OrderedCommands() []CommandSpec
OrderedCommands returns the app's commands in canonical order with Name populated.
func (*App) ShouldUseNPM ¶
ShouldUseNPM returns whether this app should be included in pnpm workspace. It checks the UsesNPM field first, and if not set, defaults based on Language().
type AppType ¶
type AppType string
AppType defines the type of application being run.
type Command ¶
type Command string
Command defines the type of action that will be actioned.
type CommandSpec ¶
type CommandSpec struct {
Name string `json:"-"`
Cmd string `json:"command,omitempty"`
SkipCI bool `json:"skip_ci,omitempty"`
Timeout string `json:"timeout,omitempty"`
Disabled bool `json:"-"` // Set during unmarshal
}
CommandSpec defines an action for an App, this can run in CI or locally.
func (*CommandSpec) JSONSchemaOneOf ¶
func (*CommandSpec) JSONSchemaOneOf() []interface{}
JSONSchemaOneOf returns the polymorphic schema options.
func (*CommandSpec) UnmarshalJSON ¶
func (c *CommandSpec) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler to
type Definition ¶
type Definition struct {
WebkitVersion string `json:"webkit_version"`
Project Project `json:"project"`
Resources []Resource `json:"resources"`
Apps []App `json:"apps"`
}
func (*Definition) ApplyDefaults ¶
func (d *Definition) ApplyDefaults() error
ApplyDefaults ensures all required defaults are set on the Definition. This should be called after unmarshaling and before validation.
func (*Definition) ContainsGo ¶
func (d *Definition) ContainsGo() bool
ContainsGo returns true if any of the apps are marked as Go.
func (*Definition) ContainsJS ¶
func (d *Definition) ContainsJS() bool
ContainsJS returns true if any of the apps are marked as JS.
func (*Definition) FilterTerraformManaged ¶ added in v0.0.8
func (d *Definition) FilterTerraformManaged() (*Definition, SkippedItems)
FilterTerraformManaged creates a filtered copy of the Definition containing only apps and resources that are managed by Terraform.
Returns the filtered definition and information about what was skipped.
func (*Definition) GetAppsByType ¶ added in v0.0.8
func (d *Definition) GetAppsByType(appType AppType) []App
GetAppsByType returns all apps of the specified type from the definition.
func (*Definition) GithubLabels ¶
func (d *Definition) GithubLabels() []string
GithubLabels returns the labels that will appear on the GitHub repository by looking at the application types.
func (*Definition) HasAppType ¶ added in v0.0.8
func (d *Definition) HasAppType(appType AppType) bool
HasAppType checks if the definition contains an app of the specified type.
func (*Definition) MergeAllEnvironments ¶
func (d *Definition) MergeAllEnvironments() Environment
MergeAllEnvironments merges shared env variables with all apps' environments. App-specific values take precedence over shared ones. If multiple apps define the same variable, the last app in the list wins.
type DomainType ¶
type DomainType string
DomainType defines the type of domain that should be provisioned.
const ( DomainTypePrimary DomainType = "primary" DomainTypeAlias DomainType = "alias" DomainTypeUnmanaged DomainType = "unmanaged" )
DomainType constants.
func (DomainType) String ¶
func (d DomainType) String() string
String implements fmt.Stringer on the DomainType.
type EnvSource ¶
type EnvSource string
EnvSource defines the type of application being run.
const ( // EnvSourceValue is a static string value (default). // Example: "https://api.example.com" EnvSourceValue EnvSource = "value" // EnvSourceResource references a Terraform resource output. // Example: "db.connection_url" EnvSourceResource EnvSource = "resource" // EnvSourceSOPS is an encrypted secret stored in a SOPS file. // Example: "secrets/production.yaml:API_KEY" EnvSourceSOPS EnvSource = "sops" )
type EnvValue ¶
type EnvValue struct {
Source EnvSource `json:"source"` // See below
Value any `json:"value,omitempty"` // Used for "value" and "resource" sources
Path string `json:"path,omitempty"` // Used for "sops" source (format: "file:key")
}
EnvValue represents a single env variable configuration
type EnvWalkEntry ¶
type EnvWalkEntry struct {
Environment env.Environment
Key string
Value any
Source EnvSource
Path string
Map EnvVar
}
EnvWalkEntry holds the details of a single env variable during iteration.
type Environment ¶
type Environment struct {
Dev EnvVar `json:"dev,omitempty"`
Staging EnvVar `json:"staging,omitempty"`
Production EnvVar `json:"production,omitempty"`
}
Environment contains env-specific variable configurations.
func (Environment) Walk ¶
func (e Environment) Walk(fn EnvironmentWalker)
Walk iterates over all environments and calls fn for each env variable.
func (Environment) WalkE ¶
func (e Environment) WalkE(fn EnvironmentWalkerE) error
WalkE iterates over all environments and calls fn for each env variable. If fn returns an error, iteration stops and the error is returned.
type EnvironmentWalker ¶
type EnvironmentWalker func(entry EnvWalkEntry)
EnvironmentWalker defines a function that processes one env entry.
type EnvironmentWalkerE ¶
type EnvironmentWalkerE func(entry EnvWalkEntry) error
EnvironmentWalkerE defines a function that processes one env entry and may return an error.
type GitHubRepo ¶
GitHubRepo defines the metadata for GitHub repositories within an app declaration.
type Infra ¶
type Infra struct {
Provider ResourceProvider `json:"provider"`
// TODO, we need to define this as a AppResourceType or something.
Type string `json:"type"`
Config map[string]any `json:"config"`
}
type Project ¶
type Project struct {
Name string `json:"name"`
Title string `json:"title"`
Description string `json:"description"`
Repo GitHubRepo `json:"repo"`
}
Project defines root metadata about the project such as business names and descriptions.
type Resource ¶
type Resource struct {
Name string `json:"name"`
Type ResourceType `json:"type"`
Provider ResourceProvider `json:"provider"`
Config map[string]any `json:"config"` // Conforms to Terraform
Backup ResourceBackupConfig `json:"backup,omitempty"`
TerraformManaged *bool `json:"terraformManaged,omitempty"`
}
Resource represents an infrastructure component that an application depends on, such as databases, storage buckets or caches.
func (*Resource) GitHubSecretName ¶
func (r *Resource) GitHubSecretName(environment env.Environment, output string) string
GitHubSecretName returns the GitHub secret name for a resource output. Format: TF_{ENVIRONMENT}_{RESOURCE_NAME}_{OUTPUT_NAME} (uppercase)
Example:
resource.GitHubSecretName(env.Production, "connection_url") ↓ "TF_PROD_DB_CONNECTION_URL"
func (*Resource) IsTerraformManaged ¶ added in v0.0.8
IsTerraformManaged returns whether this resource should be managed by Terraform. It defaults to true when the field is nil or explicitly set to true.
type ResourceBackupConfig ¶
type ResourceBackupConfig struct {
Enabled bool `json:"enabled"`
}
ResourceBackupConfig defines optional backup behavior for a resource. Backup is enabled by default.
type ResourceProvider ¶
type ResourceProvider string
ResourceProvider defines a provider of cloud infra.
const ( ResourceProviderDigitalOcean ResourceProvider = "digitalocean" ResourceProviderBackBlaze ResourceProvider = "backblaze" )
ResourceProvider constants.
func (ResourceProvider) String ¶
func (r ResourceProvider) String() string
String implements fmt.Stringer on the ResourceProvider.
type ResourceType ¶
type ResourceType string
ResourceType defines the type of resource to be provisioned.
const ( ResourceTypePostgres ResourceType = "postgres" ResourceTypeS3 ResourceType = "s3" )
ResourceType constants.
func (ResourceType) Outputs ¶
func (r ResourceType) Outputs() []string
Outputs returns the required outputs for a resource type for Terraform.
These should always be exported to GitHub secrets regardless of user config defined in the app definition.
func (ResourceType) String ¶
func (r ResourceType) String() string
String implements fmt.Stringer on the ResourceType.
type SkippedItems ¶ added in v0.0.8
SkippedItems contains information about apps and resources that were filtered out due to not being Terraform managed.