Skip to content

Commit

Permalink
allow passing labels
Browse files Browse the repository at this point in the history
  • Loading branch information
dskiff committed Apr 27, 2024
1 parent e7f5ea9 commit 84c5505
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pkg/build/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type BuildSpec struct {
Target BuildSpecTarget

Author string
Labels map[string]string
}

type BuildContext struct {
Expand Down Expand Up @@ -116,6 +117,10 @@ func mutateConfig(img v1.Image, spec BuildSpec, metadata BaseImageMetadata) (v1.
imgCfg.Config.Labels["org.opencontainers.image.base.name"] = metadata.name
imgCfg.Config.Labels["org.opencontainers.image.base.digest"] = metadata.imageDigest

for k, v := range spec.Labels {
imgCfg.Config.Labels[k] = v
}

return mutate.ConfigFile(img, imgCfg)
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ type BuildCmd struct {
TargetRepo string `short:"t" help:"Target repository" env:"TKO_TARGET_REPO" required:"true"`
TargetType string `short:"T" help:"Target type" env:"TKO_TARGET_TYPE" default:"REMOTE" enum:"REMOTE,LOCAL_DAEMON,LOCAL_FILE"`

Author string `short:"a" help:"Author of the build" env:"TKO_AUTHOR" default:"github.com/dskiff/tko"`
Author string `short:"a" help:"Author of the build" env:"TKO_AUTHOR" default:"github.com/dskiff/tko"`
Labels map[string]string `short:"l" help:"Labels to apply to the image" env:"TKO_LABELS" default:"" mapsep:"," sep:"="`

Verbose bool `short:"v" help:"Enable verbose output"`
}
Expand Down Expand Up @@ -61,6 +62,7 @@ func (b *BuildCmd) Run(cliCtx *CliCtx) error {
},

Author: b.Author,
Labels: b.Labels,
}

out, err := yaml.Marshal(cfg)
Expand Down

0 comments on commit 84c5505

Please sign in to comment.