-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreset.go
More file actions
38 lines (33 loc) · 1.45 KB
/
Copy pathpreset.go
File metadata and controls
38 lines (33 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package deploykit
import "context"
// Preset describes a service template (e.g. PostgreSQL) that pre-fills the
// service draft form on the canvas with the right Docker image, icon, and
// the env vars the image needs to run.
type Preset struct {
ID string `json:"id"`
Name string `json:"name"`
Image string `json:"image"`
IconURL string `json:"icon_url"`
Ports []PortMapping `json:"ports,omitempty"`
EnvVars []PresetEnvVar `json:"env_vars"`
}
// PresetEnvVar is one env var on a Preset. Exactly one of Value or Generate
// must be set: Value is a literal default, Generate names a random-value
// generator that runs server-side at materialization time.
type PresetEnvVar struct {
Key string `json:"key"`
Value string `json:"value,omitempty"`
Generate string `json:"generate,omitempty"`
}
// PresetService exposes the curated set of service presets. Implementations
// are expected to load the catalog once at construction time.
type PresetService interface {
// List returns the preset specs (generators not run). Suitable for
// rendering a picker — the dialog only needs name/image/icon.
List(ctx context.Context) ([]*Preset, error)
// Get returns a copy of the preset with every Generate-typed env var
// replaced by a freshly generated literal Value. Each call produces
// fresh random values.
// Returns ENOTFOUND if id does not match any preset.
Get(ctx context.Context, id string) (*Preset, error)
}