Skip to content

Commit 1620509

Browse files
committed
feat(pkg): Recognize the --label flag when packaging a kernel
Signed-off-by: Alexander Jung <alex@unikraft.io>
1 parent c204c38 commit 1620509

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

internal/cli/kraft/pkg/packager_cli_kernel.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ func (p *packagerCliKernel) Pack(ctx context.Context, opts *PkgOptions, args ...
7676
opts.Env = append(opts.Env, envs...)
7777
}
7878

79+
labels := make(map[string]string)
80+
if len(opts.Labels) > 0 {
81+
for _, label := range opts.Labels {
82+
kv := strings.SplitN(label, "=", 2)
83+
if len(kv) != 2 {
84+
return nil, fmt.Errorf("invalid label format: %s", label)
85+
}
86+
87+
labels[kv[0]] = kv[1]
88+
}
89+
}
90+
7991
var result []pack.Package
8092
norender := log.LoggerTypeFromString(config.G[config.KraftKit](ctx).Log.Type) != log.FANCY
8193

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

101114
envs := opts.aggregateEnvs()

0 commit comments

Comments
 (0)