Skip to content

Commit

Permalink
feat(pkg): Intelligently handle architecture in --plat flag
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Jung <alex@unikraft.io>
  • Loading branch information
nderjung committed Nov 21, 2024
1 parent 881f02b commit 5b3a40c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/cli/kraft/pkg/packager_cli_kernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package pkg
import (
"context"
"fmt"
"strings"

"kraftkit.sh/config"
"kraftkit.sh/internal/cli/kraft/utils"
Expand All @@ -29,12 +30,15 @@ func (p *packagerCliKernel) String() string {

// Packagable implements packager.
func (p *packagerCliKernel) Packagable(ctx context.Context, opts *PkgOptions, args ...string) (bool, error) {
if len(opts.Kernel) > 0 && len(opts.Architecture) > 0 && len(opts.Platform) > 0 {
if len(opts.Kernel) > 0 && len(opts.Platform) > 0 {
if len(opts.Architecture) == 0 && strings.Contains(opts.Platform, "/") {
opts.Platform, opts.Architecture, _ = strings.Cut(opts.Platform, "/")
}
return true, nil
}

if len(opts.Kernel) > 0 {
log.G(ctx).Warn("--kernel flag set but must be used in conjunction with -m|--arch and -p|--plat")
log.G(ctx).Warn("--kernel flag set but must be used in conjunction with -m|--arch and/or -p|--plat")
}

return false, fmt.Errorf("cannot package without path to -k|-kernel, -m|--arch and -p|--plat")
Expand Down

0 comments on commit 5b3a40c

Please sign in to comment.