appdef

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JsonFileName defines the file name of the app manifest,
	// that should appear in the root of each webkit dir.
	JsonFileName = "app.json"
)

Variables

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"`
	Domains     []Domain                `json:"domains,omitzero"`
	Commands    map[Command]CommandSpec `json:"commands,omitzero" jsonschema:"oneof_type=boolean;object;string"`
}

func (*App) Language

func (a *App) Language() string

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

func (a *App) ShouldUseNPM() bool

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.

const (
	AppTypeSvelteKit AppType = "svelte-kit"
	AppTypeGoLang    AppType = "golang"
	AppTypePayload   AppType = "payload"
)

AppType constants.

func (AppType) String

func (a AppType) String() string

String implements fmt.Stringer on the AppType.

type Build

type Build struct {
	Dockerfile string `json:"dockerfile"`
}

type Command

type Command string

Command defines the type of action that will be actioned.

const (
	CommandLint   Command = "lint"
	CommandTest   Command = "test"
	CommandFormat Command = "format"
	CommandBuild  Command = "build"
)

Command constants.

func (Command) String

func (c Command) String() string

String implements fmt.Stringer on Command.

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 Contact

type Contact struct {
	Email       string
	Phone       string
	Coordinates struct{ Latitude, Longitude string }
	Address     schemaorg.Address
}

type Definition

type Definition struct {
	WebkitVersion string     `json:"webkit_version"`
	Project       Project    `json:"project"`
	Shared        Shared     `json:"shared"`
	Resources     []Resource `json:"resources"`
	Apps          []App      `json:"apps"`
}

func Read

func Read(root afero.Fs) (*Definition, error)

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) 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) 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     string `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"
)

func (EnvSource) String

func (e EnvSource) String() string

String implements fmt.Stringer on the EnvSource.

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 EnvVar

type EnvVar map[string]EnvValue

EnvVar is a map of variable names to their configurations.

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

type GitHubRepo struct {
	Owner string `json:"owner"`
	Name  string `json:"name"`
}

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 MenuItem struct {
	Identifier string
	Name       string
	URL        string
	Weight     string
	Children   []MenuItem
	Params     map[string]any
}

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"`
}

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"

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 Shared

type Shared struct {
	Env Environment `json:"env"`
}

type Social

type Social struct {
	Twitter   string
	LinkedIn  string
	GitHub    string
	YouTube   string
	Facebook  string
	Instagram string
	TikTok    string
	Dribbble  string
}

Jump to

Keyboard shortcuts

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