Skip to content

Commit

Permalink
enhance: add link, host, and custom labeling
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrupper committed Nov 20, 2024
1 parent 0e69356 commit 90a6a81
Show file tree
Hide file tree
Showing 6 changed files with 413 additions and 218 deletions.
18 changes: 18 additions & 0 deletions cmd/vela-kaniko/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,21 @@ func main() {
Name: "label.url",
Usage: "direct url of the repository",
},
&cli.StringFlag{
EnvVars: []string{"VELA_BUILD_LINK"},
Name: "label.build_link",
Usage: "direct Vela link to the build",
},
&cli.StringFlag{
EnvVars: []string{"VELA_BUILD_HOST"},
Name: "label.host",
Usage: "host that the image is built on",
},
&cli.StringSliceFlag{
EnvVars: []string{"VELA_BUILD_CUSTOM_LABELS"},
Name: "label.custom",
Usage: "custom labels to add to the image in the form LABEL_NAME=ENV_KEY",
},
&cli.StringSliceFlag{
EnvVars: []string{"VELA_REPO_TOPICS"},
Name: "label.topics",
Expand Down Expand Up @@ -436,6 +451,9 @@ func run(c *cli.Context) error {
Number: c.Int("label.number"),
Topics: c.StringSlice("label.topics"),
URL: c.String("label.url"),
BuildURL: c.String("label.build_link"),
Host: c.String("label.host"),
CustomSet: c.StringSlice("label.custom"),
},
Labels: c.StringSlice("repo.labels"),
},
Expand Down
18 changes: 9 additions & 9 deletions cmd/vela-kaniko/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,6 @@ func (p *Plugin) Command() *exec.Cmd {
flags = append(flags, fmt.Sprintf("--destination=%s:%s", p.Repo.Name, tag))
}

// add predefined labels to user provided labels
p.Repo.Labels = append(p.Repo.Labels, p.Repo.AddLabels()...)

// iterate through all repo labels
for _, label := range p.Repo.Labels {
// add flag for tag from provided repo tag
flags = append(flags, "--label", label)
}

// add flag for dockerfile from provided image dockerfile
flags = append(flags, fmt.Sprintf("--dockerfile=%s", p.Image.Dockerfile))

Expand Down Expand Up @@ -188,6 +179,15 @@ func (p *Plugin) Command() *exec.Cmd {
// add flag for logging verbosity
flags = append(flags, fmt.Sprintf("--verbosity=%s", logrus.GetLevel()))

// add predefined labels to user provided labels
p.Repo.Labels = append(p.Repo.Labels, p.Repo.AddLabels()...)

// iterate through all repo labels
for _, label := range p.Repo.Labels {
// add flag for tag from provided repo tag
flags = append(flags, fmt.Sprintf("--label=%s", label))
}

return exec.Command(kanikoBin, flags...)
}

Expand Down
Loading

0 comments on commit 90a6a81

Please sign in to comment.