-
Notifications
You must be signed in to change notification settings - Fork 9
/
requires.go
30 lines (24 loc) · 908 Bytes
/
requires.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright 2022 Namespace Labs Inc; All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
package cuefrontendopaque
import (
"context"
"namespacelabs.dev/foundation/internal/fnerrors"
"namespacelabs.dev/foundation/internal/frontend/fncue"
"namespacelabs.dev/foundation/internal/parsing"
"namespacelabs.dev/foundation/schema"
"namespacelabs.dev/foundation/std/pkggraph"
)
func parseRequires(ctx context.Context, pl parsing.EarlyPackageLoader, loc pkggraph.Location, v *fncue.CueV) ([]schema.PackageName, error) {
var bits []schema.PackageName
if err := v.Val.Decode(&bits); err != nil {
return nil, err
}
for _, p := range bits {
if err := pl.Ensure(ctx, p); err != nil {
return nil, fnerrors.NewWithLocation(loc, "loading package %s failed: %w", p, err)
}
}
return bits, nil
}