This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

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