Skip to content

Commit

Permalink
feat(pkg): Recognize the --label flag when packaging a kernel
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 c204c38 commit ac8dabf
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/cli/kraft/pkg/packager_cli_kernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ func (p *packagerCliKernel) Pack(ctx context.Context, opts *PkgOptions, args ...
opts.Env = append(opts.Env, envs...)
}

var labels = make(map[string]string)
if len(opts.Labels) > 0 {
for _, label := range opts.Labels {
kv := strings.SplitN(label, "=", 2)
if len(kv) != 2 {
return nil, fmt.Errorf("invalid label format: %s", label)
}

labels[kv[0]] = kv[1]
}
}

var result []pack.Package
norender := log.LoggerTypeFromString(config.G[config.KraftKit](ctx).Log.Type) != log.FANCY

Expand All @@ -96,6 +108,7 @@ func (p *packagerCliKernel) Pack(ctx context.Context, opts *PkgOptions, args ...
packmanager.PackKConfig(!opts.NoKConfig),
packmanager.PackName(opts.Name),
packmanager.PackOutput(opts.Output),
packmanager.PackLabels(labels),
)

envs := opts.aggregateEnvs()
Expand Down

0 comments on commit ac8dabf

Please sign in to comment.