-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.go
58 lines (46 loc) · 1.76 KB
/
main.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// 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 main
import (
"context"
"log"
"os"
"github.com/spf13/cobra"
"namespacelabs.dev/foundation/cmd/nspipelines/cmd/github"
"namespacelabs.dev/foundation/cmd/nspipelines/cmd/runs"
workspaceCmd "namespacelabs.dev/foundation/cmd/nspipelines/cmd/workspace"
"namespacelabs.dev/foundation/internal/cli/cmd"
"namespacelabs.dev/foundation/internal/cli/fncobra"
"namespacelabs.dev/foundation/internal/frontend/cuefrontend"
"namespacelabs.dev/foundation/internal/frontend/cuefrontendopaque"
"namespacelabs.dev/foundation/internal/parsing"
"namespacelabs.dev/foundation/internal/providers/aws/ecr"
"namespacelabs.dev/foundation/schema"
"namespacelabs.dev/foundation/std/tasks"
"namespacelabs.dev/foundation/std/tasks/simplelog"
)
const maxLogLevel = 0
func main() {
root := &cobra.Command{
Use: "nspipelines",
TraverseChildren: true,
}
root.AddCommand(github.NewGithubCmd())
root.AddCommand(workspaceCmd.NewWorkspaceCmd())
root.AddCommand(runs.NewRunsCmd())
root.AddCommand(cmd.NewImagesCmd())
root.AddCommand(cmd.NewRobotLogin("robot-login"))
ctx := tasks.WithSink(context.Background(), simplelog.NewSink(os.Stderr, maxLogLevel))
ecr.Register()
parsing.ModuleLoader = cuefrontend.ModuleLoader
parsing.MakeFrontend = func(pl parsing.EarlyPackageLoader, env *schema.Environment) parsing.Frontend {
return cuefrontend.NewFrontend(pl, cuefrontendopaque.NewFrontend(env, pl), env)
}
tasks.SetupFlags(root.PersistentFlags())
if err := fncobra.RunInContext(ctx, func(ctx context.Context) error {
return root.ExecuteContext(ctx)
}, nil); err != nil {
log.Fatal(err)
}
}