talos/pkg/makefs/makefs.go
Andrey Smirnov 018086d1fa refactor: extract blockdevice library
Library `blockdevice` was extracted as `talos-systems/go-blockdevice`,
this PR finalizes the move by removing Talos copy of it.

Some functions around `mkfs`/`growfs` were extracted as `makefs`
package, as they depend on `cmd` package.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-10-05 11:18:43 -07:00

41 lines
933 B
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Package makefs provides function to format and grow filesystems.
package makefs
// Option to control makefs settings.
type Option func(*Options)
// Options for makefs.
type Options struct {
Label string
Force bool
}
// WithLabel sets the label for the filesystem to be created.
func WithLabel(label string) Option {
return func(o *Options) {
o.Label = label
}
}
// WithForce forces creation of a filesystem even if one already exists.
func WithForce(force bool) Option {
return func(o *Options) {
o.Force = force
}
}
// NewDefaultOptions builds options with specified setters applied.
func NewDefaultOptions(setters ...Option) Options {
var opt Options
for _, o := range setters {
o(&opt)
}
return opt
}