diff --git a/internal/cli/kraft/pkg/packager_cli_kernel.go b/internal/cli/kraft/pkg/packager_cli_kernel.go index b24d04ec3..a128c3a1d 100644 --- a/internal/cli/kraft/pkg/packager_cli_kernel.go +++ b/internal/cli/kraft/pkg/packager_cli_kernel.go @@ -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 @@ -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()