Skip to content

Commit

Permalink
don't use -al
Browse files Browse the repository at this point in the history
  • Loading branch information
dskiff committed Apr 27, 2024
1 parent 9b6d90e commit 0e8dfea
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .tko.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
build:
destination-path: /usr/local/bin
entrypoint: /usr/local/bin/tko
labels:
default-labels:
org.opencontainers.image.title: tko
org.opencontainers.image.url: github.com/dskiff/tko
org.opencontainers.image.source: github.com/dskiff/tko
23 changes: 16 additions & 7 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ build:
target-repo: repo/target
author: me
labels:
default-labels:
label1: value1
label2: value2
labels:
label3: value3
label4: value4
tmp: /tmp-dir
verbose: true
Expand All @@ -47,8 +50,10 @@ build:
assert.Equal(t, "repo/target", cli.Build.TargetRepo)

assert.Equal(t, "me", cli.Build.Author)
assert.Equal(t, "value1", cli.Build.Labels["label1"])
assert.Equal(t, "value2", cli.Build.Labels["label2"])
assert.Equal(t, "value1", cli.Build.DefaultLabels["label1"])
assert.Equal(t, "value2", cli.Build.DefaultLabels["label2"])
assert.Equal(t, "value3", cli.Build.Labels["label3"])
assert.Equal(t, "value4", cli.Build.Labels["label4"])

assert.Equal(t, "/tmp-dir", cli.Build.Tmp)
assert.Equal(t, true, cli.Build.Verbose)
Expand All @@ -73,8 +78,10 @@ func TestBuildArgs(t *testing.T) {
"-d", "/destination",
"-t", "repo/target",
"-a", "me",
"-l", "label1=value1",
"-l", "label2=value2",
"-L", "label1=value1",
"-L", "label2=value2",
"-l", "label3=value3",
"-l", "label4=value4",
"-T", "REMOTE",
"-v",
"--tmp", "/tmp-dir",
Expand All @@ -90,8 +97,10 @@ func TestBuildArgs(t *testing.T) {
assert.Equal(t, "repo/target", cli.Build.TargetRepo)

assert.Equal(t, "me", cli.Build.Author)
assert.Equal(t, "value1", cli.Build.Labels["label1"])
assert.Equal(t, "value2", cli.Build.Labels["label2"])
assert.Equal(t, "value1", cli.Build.DefaultLabels["label1"])
assert.Equal(t, "value2", cli.Build.DefaultLabels["label2"])
assert.Equal(t, "value3", cli.Build.Labels["label3"])
assert.Equal(t, "value4", cli.Build.Labels["label4"])

assert.Equal(t, "/tmp-dir", cli.Build.Tmp)
assert.Equal(t, true, cli.Build.Verbose)
Expand Down
10 changes: 5 additions & 5 deletions pkg/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ 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"`
Labels map[string]string `short:"l" help:"Labels to apply to the image" env:"TKO_LABELS" default:"" mapsep:"," sep:"="`
AdditionalLabels map[string]string `short:"al" help:"Additional labels to apply to the image" env:"TKO_ADDITIONAL_LABELS" default:"" mapsep:"," sep:"="`
Author string `short:"a" help:"Author of the build" env:"TKO_AUTHOR" default:"github.com/dskiff/tko"`
DefaultLabels map[string]string `short:"L" help:"Default labels to apply to the image" env:"TKO_DEFAULT_LABELS" default:"" mapsep:"," sep:"="`
Labels map[string]string `short:"l" help:"Additional labels to apply to the image. Can override default-labels." env:"LABELS" default:"" mapsep:"," sep:"="`

Tmp string `help:"Path where tko can write temporary files. Defaults to golang's tmp logic." env:"TKO_TMP" default:""`
Verbose bool `short:"v" help:"Enable verbose output"`
Expand All @@ -52,10 +52,10 @@ func (b *BuildCmd) Run(cliCtx *CliCtx) error {

// Labels would ideally be merged by kong, but this works too
labels := make(map[string]string)
for k, v := range b.Labels {
for k, v := range b.DefaultLabels {
labels[k] = v
}
for k, v := range b.AdditionalLabels {
for k, v := range b.Labels {
labels[k] = v
}

Expand Down

0 comments on commit 0e8dfea

Please sign in to comment.