Skip to content

Commit

Permalink
parameters + tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrupper committed Nov 20, 2024
1 parent 90a6a81 commit 7796ac7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
25 changes: 23 additions & 2 deletions cmd/vela-kaniko/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ func main() {
Name: "label.host",
Usage: "host that the image is built on",
},
&cli.StringSliceFlag{
EnvVars: []string{"VELA_BUILD_CUSTOM_LABELS"},
&cli.StringFlag{
EnvVars: []string{"VELA_BUILD_CUSTOM_LABELS", "PARAMETER_CUSTOM_LABELS"},
Name: "label.custom",
Usage: "custom labels to add to the image in the form LABEL_NAME=ENV_KEY",
},
Expand Down Expand Up @@ -396,6 +396,27 @@ func run(c *cli.Context) error {
}
}

// target type for custom labels
var customLabels []string

labelsStr := c.String("label.custom")
if len(labelsStr) > 0 {
customLabelsMap := make(map[string]string)

// attempt to unmarshal to map
err := json.Unmarshal([]byte(labelsStr), &customLabelsMap)
if err != nil {
// fall back on splitting the string
customLabels = strings.Split(labelsStr, ",")

Check failure on line 410 in cmd/vela-kaniko/main.go

View workflow job for this annotation

GitHub Actions / diff-review

ineffectual assignment to customLabels (ineffassign)

Check failure on line 410 in cmd/vela-kaniko/main.go

View workflow job for this annotation

GitHub Actions / diff-review

ineffectual assignment to customLabels (ineffassign)

Check failure on line 410 in cmd/vela-kaniko/main.go

View workflow job for this annotation

GitHub Actions / full-review

ineffectual assignment to customLabels (ineffassign)

Check failure on line 410 in cmd/vela-kaniko/main.go

View workflow job for this annotation

GitHub Actions / full-review

ineffectual assignment to customLabels (ineffassign)

Check failure on line 410 in cmd/vela-kaniko/main.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] cmd/vela-kaniko/main.go#L410

ineffectual assignment to customLabels (ineffassign)
Raw output
cmd/vela-kaniko/main.go:410:4: ineffectual assignment to customLabels (ineffassign)
			customLabels = strings.Split(labelsStr, ",")
			^
} else {
// iterate through the custom labels map
for key, value := range customLabelsMap {
// add the custom label to the custom labels
customLabels = append(customLabels, fmt.Sprintf("%s=%s", key, value))

Check failure on line 415 in cmd/vela-kaniko/main.go

View workflow job for this annotation

GitHub Actions / diff-review

SA4010: this result of append is never used, except maybe in other appends (staticcheck)

Check failure on line 415 in cmd/vela-kaniko/main.go

View workflow job for this annotation

GitHub Actions / diff-review

SA4010: this result of append is never used, except maybe in other appends (staticcheck)

Check failure on line 415 in cmd/vela-kaniko/main.go

View workflow job for this annotation

GitHub Actions / full-review

SA4010: this result of append is never used, except maybe in other appends (staticcheck)

Check failure on line 415 in cmd/vela-kaniko/main.go

View workflow job for this annotation

GitHub Actions / full-review

SA4010: this result of append is never used, except maybe in other appends (staticcheck)

Check failure on line 415 in cmd/vela-kaniko/main.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] cmd/vela-kaniko/main.go#L415

SA4010: this result of append is never used, except maybe in other appends (staticcheck)
Raw output
cmd/vela-kaniko/main.go:415:20: SA4010: this result of append is never used, except maybe in other appends (staticcheck)
				customLabels = append(customLabels, fmt.Sprintf("%s=%s", key, value))
				               ^
}
}
}

// create the plugin
p := &Plugin{
// build configuration
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ require (

require (
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/google/go-cmp v0.6.0
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
golang.org/x/sys v0.15.0 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-vela/types v0.24.0 h1:KkkiXxw3uHckh/foyadmLY1YnLw6vhZbz9XwqONCj6o=
github.com/go-vela/types v0.24.0/go.mod h1:YWj6BIapl9Kbj4yHq/fp8jltXdGiwD/gTy1ez32Rzag=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down

0 comments on commit 7796ac7

Please sign in to comment.