Files
jpictl/pkg/zones/zones.go
T
amery 44ea514e15 zones: WIP
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-08-21 19:02:28 +00:00

40 lines
561 B
Go

package zones
import (
"io/fs"
"os"
)
// Zone represents one zone in a cluster
type Zone struct {
zones *Zones
id int
name string
}
// Zones represents all zones in a cluster
type Zones struct {
dir fs.FS
zones []Zone
}
// NewFS builds a [Zones] tree using the given directory
func NewFS(dir fs.FS) (*Zones, error) {
z := &Zones{
dir: dir,
}
if err := z.scan(); err != nil {
return nil, err
}
return z, nil
}
// New builds a [Zones] tree using the given directory
func New(dir string) (*Zones, error) {
return NewFS(os.DirFS(dir))
}