wisski-cloud-distillery/internal/cli/requirements.go
Tom 6362b2887b go1.20+: Refuse to work if cgo is enabled
On go1.20+ it is no longer possible to directly copy a cgo-enabled
library into a docker container. For this reason, this commit adds a
flag to commands that automatically make them fail with an appropriate
message if cgo is enabled.
2023-04-27 11:13:47 +02:00

29 lines
881 B
Go

package cli
import (
"github.com/tkw1536/goprogram"
"github.com/tkw1536/goprogram/meta"
)
// Requirements are requirements for the WissKI Distillery
type Requirements struct {
// Do we need an installed distillery?
NeedsDistillery bool
// Automatically fail when cgo is enabled?
FailOnCgo bool
}
// AllowsFlag checks if the provided flag may be passed to fullfill this requirement
// By default it is used only for help page generation, and may be inaccurate.
func (r Requirements) AllowsFlag(flag meta.Flag) bool {
return r.NeedsDistillery
}
// Validate validates if this requirement is fullfilled for the provided global flags.
// It should return either nil, or an error of type exit.Error.
//
// Validate does not take into account AllowsOption, see ValidateAllowedOptions.
func (r Requirements) Validate(arguments goprogram.Arguments[Flags]) error {
return nil
}