From 51b2fbba36c0ee3ec6f64d2d1dffaa37124eb60a Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Sun, 16 Oct 2022 15:11:49 +0200 Subject: [PATCH] Don't support legacy bootstrap format, we have to redo all bootstraps anyway --- go-workspace/src/bootstrap/hosts.go | 69 ----------------------------- 1 file changed, 69 deletions(-) diff --git a/go-workspace/src/bootstrap/hosts.go b/go-workspace/src/bootstrap/hosts.go index b15eef7..a4efef8 100644 --- a/go-workspace/src/bootstrap/hosts.go +++ b/go-workspace/src/bootstrap/hosts.go @@ -1,7 +1,6 @@ package bootstrap import ( - "errors" "fmt" "io/fs" "path/filepath" @@ -42,62 +41,6 @@ type Host struct { Garage *GarageHost `yaml:"garage,omitempty"` } -func loadHostsLegacy(bootstrapFS fs.FS) (map[string]Host, error) { - - hosts := map[string]Host{} - - readAsYaml := func(into interface{}, path string) error { - b, err := fs.ReadFile(bootstrapFS, path) - if err != nil { - return fmt.Errorf("reading file from fs: %w", err) - } - - return yaml.Unmarshal(b, into) - } - - { - globPath := "nebula/hosts/*.yml" - - nebulaHostFiles, err := fs.Glob(bootstrapFS, globPath) - if err != nil { - return nil, fmt.Errorf("listing nebula host files at %q in fs: %w", globPath, err) - } - - for _, nebulaHostPath := range nebulaHostFiles { - - hostName := filepath.Base(nebulaHostPath) - hostName = strings.TrimSuffix(hostName, filepath.Ext(hostName)) - - var nebulaHost NebulaHost - if err := readAsYaml(&nebulaHost, nebulaHostPath); err != nil { - return nil, fmt.Errorf("reading %q as yaml: %w", nebulaHostPath, err) - } - - hosts[hostName] = Host{ - Name: hostName, - Nebula: nebulaHost, - } - } - } - - for hostName, host := range hosts { - - garageHostPath := filepath.Join("garage/hosts", hostName+".yml") - - var garageHost GarageHost - if err := readAsYaml(&garageHost, garageHostPath); errors.Is(err, fs.ErrNotExist) { - continue - } else if err != nil { - return nil, fmt.Errorf("reading %q as yaml: %w", garageHostPath, err) - } - - host.Garage = &garageHost - hosts[hostName] = host - } - - return hosts, nil -} - func loadHosts(bootstrapFS fs.FS) (map[string]Host, error) { hosts := map[string]Host{} @@ -131,18 +74,6 @@ func loadHosts(bootstrapFS fs.FS) (map[string]Host, error) { hosts[hostName] = host } - if len(hosts) > 0 { - return hosts, nil - } - - // We used to have the bootstrap file laid out differently. If no hosts were - // found then the bootstrap file is probably in that format. - hosts, err = loadHostsLegacy(bootstrapFS) - - if err != nil { - return nil, fmt.Errorf("loading hosts in legacy layout from fs: %w", err) - } - if len(hosts) == 0 { return nil, fmt.Errorf("failed to load any hosts from fs") }