MCPcopy Index your code
hub / github.com/rilldata/rill / SeedCmd

Function SeedCmd

cli/cmd/devtool/seed.go:14–64  ·  view source on GitHub ↗
(ch *cmdutil.Helper)

Source from the content-addressed store, hash-verified

12)
13
14func SeedCmd(ch *cmdutil.Helper) *cobra.Command {
15 cmd := &cobra.Command{
16 Use: "seed {cloud|e2e}",
17 Short: "Authenticate and deploy a seed project",
18 Args: cobra.ExactArgs(1),
19 RunE: func(cmd *cobra.Command, args []string) error {
20 preset := args[0]
21 if preset != "cloud" && preset != "e2e" {
22 return fmt.Errorf("seeding not available for preset %q", preset)
23 }
24
25 // clone examples to a temp dir and deploy
26 temp, err := os.MkdirTemp("", "rill-seed-*")
27 if err != nil {
28 return err
29 }
30 defer os.RemoveAll(temp)
31 _, err = git.PlainClone(temp, false, &git.CloneOptions{
32 URL: "https://github.com/rilldata/rill-examples.git",
33 })
34 if err != nil {
35 return err
36 }
37
38 // create org if not exists
39 if ch.Org == "" {
40 client, err := ch.Client()
41 if err != nil {
42 return err
43 }
44 _, err = client.CreateOrganization(cmd.Context(), &adminv1.CreateOrganizationRequest{
45 Name: "rilldata",
46 })
47 if err != nil {
48 return err
49 }
50 }
51 return project.ConnectGithubFlow(cmd.Context(), ch, &project.DeployOpts{
52 GitPath: temp,
53 SubPath: "rill-openrtb-prog-ads",
54 Name: "rill-openrtb-prog-ads",
55 RemoteName: "origin",
56 ProdVersion: "latest",
57 Slots: 2,
58 Github: true,
59 })
60 },
61 }
62
63 return cmd
64}

Callers 1

DevtoolCmdFunction · 0.85

Calls 5

ConnectGithubFlowFunction · 0.92
ErrorfMethod · 0.65
CreateOrganizationMethod · 0.65
ContextMethod · 0.65
ClientMethod · 0.45

Tested by

no test coverage detected