Skip to content

Commit

Permalink
fix(unikraft): Add additional checks for targets (#976)
Browse files Browse the repository at this point in the history
Reviewed-by: Alexander Jung <alex@unikraft.io>
Approved-by: Alexander Jung <alex@unikraft.io>
  • Loading branch information
nderjung committed Nov 5, 2023
2 parents 7473688 + 229faea commit 1b061f7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions unikraft/target/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ func TransformFromSchema(ctx context.Context, data interface{}) (interface{}, er
case string:
split := strings.SplitN(value, "/", 2)

if len(split) != 2 {
return nil, fmt.Errorf("invalid target format: %s", value)
}

platform, err := plat.TransformFromSchema(ctx, split[0])
if err != nil {
return nil, err
Expand Down Expand Up @@ -116,5 +120,13 @@ func TransformFromSchema(ctx context.Context, data interface{}) (interface{}, er
}
}

if t.Architecture().Name() == "" {
return nil, fmt.Errorf("architecture must be specified for all targets")
}

if t.Platform().Name() == "" {
return nil, fmt.Errorf("platform must be specified for all targets")
}

return t, nil
}

0 comments on commit 1b061f7

Please sign in to comment.