Monorepo for Tangled
tangled.org
1package microvm
2
3import (
4 "fmt"
5 "slices"
6)
7
8type manifestWorkflow struct {
9 Image string `yaml:"image"`
10 Services map[string]any `yaml:"services"`
11 Virtualisation map[string]any `yaml:"virtualisation"`
12 Dependencies []string `yaml:"dependencies"`
13 Registry map[string]any `yaml:"registry"`
14 Environment map[string]string `yaml:"environment"`
15 Caches map[string]string `yaml:"caches"`
16 Steps []struct {
17 Name string `yaml:"name"`
18 Command string `yaml:"command"`
19 Environment map[string]string `yaml:"environment"`
20 } `yaml:"steps"`
21}
22
23// flattens the caches map into sorted substituter URLs and trusted public keys
24func workflowCaches(caches map[string]string) (urls []string, keys []string, err error) {
25 for cacheURL, key := range caches {
26 urls = append(urls, cacheURL)
27 if key != "" {
28 keys = append(keys, key)
29 }
30 }
31 if _, err := parseCacheUpstreams(urls); err != nil {
32 return nil, nil, fmt.Errorf("caches: %w", err)
33 }
34 slices.Sort(urls)
35 slices.Sort(keys)
36 return urls, keys, nil
37}
38
39type manifestConfig struct {
40 Services map[string]any `yaml:"services" json:"services,omitempty"`
41 Virtualisation map[string]any `yaml:"virtualisation" json:"virtualisation,omitempty"`
42 Dependencies []string `yaml:"dependencies" json:"dependencies,omitempty"`
43 Registry map[string]any `yaml:"registry" json:"registry,omitempty"`
44}
45
46func (c manifestConfig) Enabled() bool {
47 return len(c.Services) > 0 || len(c.Virtualisation) > 0 || len(c.Dependencies) > 0 || len(c.Registry) > 0
48}