Documentation
¶
Index ¶
- Constants
- Variables
- func ParseResourceReference(value any) (resourceName, outputName string, ok bool)
- 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 Notifications
- 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 ¶
func ParseResourceReference ¶ added in v0.0.15
ParseResourceReference parses a resource reference string (e.g., "db.connection_url").
Resource references follow the format: "resource_name.output_name".
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" inline:"true"`
}
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) PrimaryDomain ¶ added in v0.0.19
PrimaryDomain returns the primary domain for this app. It first looks for a domain with type "primary" in the Domains array. If no primary domain is found, it returns the first domain in the array. If the Domains array is empty, it returns an empty string.
func (*App) ShouldRelease ¶ added in v0.0.10
ShouldRelease returns whether this app should be built and released in CI/CD. It defaults to true when the field is nil or explicitly set to true.
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"`
Notifications Notifications `json:"notifications"`
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 Domain ¶
type Domain struct {
Name string `json:"name"`
Type DomainType `json:"type"`
Zone string `json:"zone,omitempty"`
Wildcard bool `json:"wildcard,omitempty"`
}
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 defines the source type: "value", "resource", or "sops"
Source EnvSource `json:"source"`
// Value holds the actual value for different source types:
// - "value": A static string (e.g., "https://api.example.com")
// - "resource": A Terraform resource reference (e.g., "db.connection_url")
// - "sops": The variable name/key to lookup in the SOPS file (e.g., "API_KEY")
// Note: For SOPS, the file path is determined by environment (dev.yaml, staging.yaml, production.yaml)
Value any `json:"value,omitempty"`
}
EnvValue represents a single env variable configuration
type EnvWalkEntry ¶
type EnvWalkEntry struct {
Environment env.Environment
Key string
Value any
Source EnvSource
Map EnvVar
}
EnvWalkEntry holds the details of a single env variable during iteration.
type Environment ¶
type Environment struct {
Default EnvVar `json:"default,omitempty" inline:"true"`
Dev EnvVar `json:"dev,omitempty" inline:"true"`
Staging EnvVar `json:"staging,omitempty" inline:"true"`
Production EnvVar `json:"production,omitempty" inline:"true"`
}
Environment contains env-specific variable configurations.
func (Environment) GetVarsForEnvironment ¶ added in v0.0.25
func (e Environment) GetVarsForEnvironment(target env.Environment) (EnvVar, error)
GetVarsForEnvironment returns the EnvVar map for the specified environment. Returns an error if the environment is unknown.
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 Notifications ¶ added in v0.0.36
type Notifications struct {
WebhookURL string `json:"webhook_url,omitzero"`
}
Notifications defines alert and notification settings for the project. Provider-agnostic configuration supporting Slack, Discord, and other webhook-based services.
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.