diff options
| author | Nicolas Paul <n@nc0.fr> | 2023-05-31 00:44:17 +0200 |
|---|---|---|
| committer | Nicolas Paul <n@nc0.fr> | 2023-05-31 00:48:47 +0200 |
| commit | 1724bd8d98d791faf253aeddcfce02a1accd1ff9 (patch) | |
| tree | 6034f364e100e87124d90c0ac22c12c6993348e3 /pkg/config/starlark.go | |
| parent | 43be0e328a0e4c8c3d1ff88eb81b82402fcfa7c1 (diff) | |
Add Git library for Starlark
The Git library provides Starlark macros to easily index Go modules hosted on Git repositories. It also provides macros for services like GitHub, Bitbucket, Source Hut, Gitiles (via Gerrit)...
Signed-off-by: Nicolas Paul <n@nc0.fr>
Diffstat (limited to 'pkg/config/starlark.go')
| -rw-r--r-- | pkg/config/starlark.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/pkg/config/starlark.go b/pkg/config/starlark.go index 39adcf9..942479f 100644 --- a/pkg/config/starlark.go +++ b/pkg/config/starlark.go @@ -2,6 +2,7 @@ package config import ( "fmt" + "go.nc0.fr/svgu/pkg/config/lib/git" "go.nc0.fr/svgu/pkg/types" "go.starlark.net/starlark" ) @@ -35,17 +36,18 @@ func ExecConfig(fl string) (*types.Index, error) { // load loads a module from the given path. func load(t *starlark.Thread, module string) (starlark.StringDict, error) { switch module { - // todo: add libs + case "git.star": + return git.LoadGitModule(t) + default: + return nil, fmt.Errorf("unknown module %q", module) } - - return nil, fmt.Errorf("unknown module %q", module) } // Injected built-ins. // InternIndex represents the built-in function "index". // index(domain) initializes a new index with the given domain. -func InternIndex(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, +func InternIndex(_ *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { var domain string if err := starlark.UnpackArgs("index", args, kwargs, |
