Skip to content

Commit

Permalink
toStringSlice not to do defaulting
Browse files Browse the repository at this point in the history
Signed-off-by: Nghia Tran <tcnghia@gmail.com>
  • Loading branch information
tcnghia committed May 15, 2024
1 parent a06299b commit b36e1e2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/provider/resource_ko_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func fromData(d *schema.ResourceData, po *Opts) buildOptions {
ip: d.Get("importpath").(string),
workingDir: d.Get("working_dir").(string),
imageRepo: repo,
platforms: toStringSlice(d.Get("platforms").([]interface{})),
platforms: defaultPlatform(toStringSlice(d.Get("platforms").([]interface{}))),
baseImage: d.Get("base_image").(string),
sbom: d.Get("sbom").(string),
auth: po.auth,
Expand All @@ -262,11 +262,14 @@ func fromData(d *schema.ResourceData, po *Opts) buildOptions {
}
}

func toStringSlice(in []interface{}) []string {
func defaultPlatform(in []string) []string {
if len(in) == 0 {
return []string{"linux/amd64"}
}
return in
}

func toStringSlice(in []interface{}) []string {
out := make([]string, len(in))
for i, ii := range in {
if s, ok := ii.(string); ok {
Expand Down

0 comments on commit b36e1e2

Please sign in to comment.