Add global --experimental flag to gatekeep some features
This commit adds a global --experiemntal flag so we can start gatekeeping some features where we know beforehand that the UX will very likely change. It also refactors the current --platform flag to be avaiable under this experimental flag for the moment Signed-off-by: Marcos Lilljedahl <marcosnils@gmail.com>
This commit is contained in:
parent
d80acf805b
commit
8969507db6
5
ci.cue
5
ci.cue
@ -14,11 +14,6 @@ import (
|
||||
)
|
||||
|
||||
dagger.#Plan & {
|
||||
// FIXME: Ideally we would want to automatically set the platform's arch identical to the host
|
||||
// to avoid the performance hit caused by qemu (linter goes from <3s to >3m when arch is x86)
|
||||
// Uncomment if running locally on Mac M1 to bypass qemu
|
||||
// platform: "linux/aarch64"
|
||||
// platform: "linux/amd64"
|
||||
|
||||
client: filesystem: ".": read: exclude: [
|
||||
"bin",
|
||||
|
@ -97,12 +97,12 @@ func NewClient(ctx context.Context) *client.Client {
|
||||
lg.Fatal().Err(err).Msg("unable to parse --cache-from options")
|
||||
}
|
||||
|
||||
ep := viper.GetString("experimental-platform")
|
||||
ep := viper.GetString("platform")
|
||||
var p *specs.Platform
|
||||
if len(ep) > 0 {
|
||||
pp, err := platforms.Parse(ep)
|
||||
if err != nil {
|
||||
lg.Fatal().Err(err).Msg("invalid value for --experimental-platform")
|
||||
lg.Fatal().Err(err).Msg("invalid value for --platform")
|
||||
}
|
||||
p = &pp
|
||||
}
|
||||
|
@ -42,6 +42,11 @@ var doCmd = &cobra.Command{
|
||||
err error
|
||||
)
|
||||
|
||||
switch !viper.GetBool("experimental") {
|
||||
case len(viper.GetString("platform")) > 0:
|
||||
lg.Fatal().Err(err).Msg("--platform requires --experimental flag")
|
||||
}
|
||||
|
||||
if f := viper.GetString("log-format"); f == "tty" || f == "auto" && term.IsTerminal(int(os.Stdout.Fd())) {
|
||||
tty, err = logger.NewTTYOutput(os.Stderr)
|
||||
if err != nil {
|
||||
@ -157,7 +162,7 @@ func init() {
|
||||
doCmd.Flags().StringArrayP("with", "w", []string{}, "")
|
||||
doCmd.Flags().StringP("plan", "p", ".", "Path to plan (defaults to current directory)")
|
||||
doCmd.Flags().Bool("no-cache", false, "Disable caching")
|
||||
doCmd.Flags().String("experimental-platform", "", "Set target build platform (experimental)")
|
||||
doCmd.Flags().String("platform", "", "Set target build platform (requires experimental)")
|
||||
doCmd.Flags().StringArray("cache-to", []string{},
|
||||
"Cache export destinations (eg. user/app:cache, type=local,dest=path/to/dir)")
|
||||
doCmd.Flags().StringArray("cache-from", []string{},
|
||||
|
@ -23,6 +23,7 @@ var rootCmd = &cobra.Command{
|
||||
func init() {
|
||||
rootCmd.PersistentFlags().String("log-format", "auto", "Log format (auto, plain, tty, json)")
|
||||
rootCmd.PersistentFlags().StringP("log-level", "l", "info", "Log level")
|
||||
rootCmd.PersistentFlags().Bool("experimental", false, "Enable experimental features")
|
||||
|
||||
rootCmd.PersistentPreRun = func(cmd *cobra.Command, _ []string) {
|
||||
go checkVersion()
|
||||
|
@ -109,7 +109,8 @@ func (p *Plan) Action() *Action {
|
||||
// configPlatform load the platform specified in the context
|
||||
// Buildkit will then run every operation using that platform
|
||||
// If platform is not define, context keep default platform
|
||||
// FIXME: `platform` field temporarily disabled
|
||||
// FIXME: `platform` field temporarily disabled until we decide the proper
|
||||
// DX for multi-platform builds
|
||||
// func (p *Plan) configPlatform() error {
|
||||
// platformField := p.source.Lookup("platform")
|
||||
|
||||
|
@ -85,7 +85,6 @@ func (s *Solver) AddCredentials(target, username, secret string) {
|
||||
}
|
||||
|
||||
func (s *Solver) Marshal(ctx context.Context, st llb.State, co ...llb.ConstraintsOpt) (*bkpb.Definition, error) {
|
||||
// FIXME: do not hardcode the platform
|
||||
def, err := st.Marshal(ctx, co...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -232,13 +232,19 @@ setup() {
|
||||
cd "$TESTDIR"
|
||||
|
||||
# Run with invalid platform format
|
||||
run "$DAGGER" "do" --experimental-platform invalid -p./plan/platform/platform.cue test
|
||||
run "$DAGGER" "do" --experimental --platform invalid -p./plan/platform/platform.cue test
|
||||
assert_failure
|
||||
assert_output --partial "unknown operating system or architecture: invalid argument"
|
||||
|
||||
|
||||
# Require --experimental flag
|
||||
run "$DAGGER" "do" --platform linux/arm64 -p./plan/platform/platform.cue test
|
||||
assert_failure
|
||||
assert_output --partial "--platform requires --experimental flag"
|
||||
|
||||
|
||||
# Run with non-existing platform
|
||||
run "$DAGGER" "do" --experimental-platform invalid/invalid -p./plan/platform/platform.cue test
|
||||
run "$DAGGER" "do" --experimental --platform invalid/invalid -p./plan/platform/platform.cue test
|
||||
assert_failure
|
||||
assert_output --partial "no match for platform in manifest"
|
||||
}
|
||||
|
Reference in New Issue
Block a user