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

Function UploadRepo

cli/pkg/cmdutil/archive.go:14–56  ·  view source on GitHub ↗

UploadRepo uploads a local project files to rill managed store. Internally it creates an asset object on admin service and returns its id which can be supplied while creating/updating project.

(ctx context.Context, repo drivers.RepoStore, ch *Helper, org, name string)

Source from the content-addressed store, hash-verified

12// UploadRepo uploads a local project files to rill managed store.
13// Internally it creates an asset object on admin service and returns its id which can be supplied while creating/updating project.
14func UploadRepo(ctx context.Context, repo drivers.RepoStore, ch *Helper, org, name string) (string, error) {
15 // list files
16 entries, err := repo.ListGlob(ctx, "**", false)
17 if err != nil {
18 return "", err
19 }
20
21 adminClient, err := ch.Client()
22 if err != nil {
23 return "", err
24 }
25
26 rootPath, err := repo.Root(ctx)
27 if err != nil {
28 return "", fmt.Errorf("failed to get root path: %w", err)
29 }
30
31 b, err := archive.Create(ctx, entries, rootPath)
32 if err != nil {
33 return "", err
34 }
35
36 estimatedSizeBytes := int64(b.Len())
37
38 // generate a upload URL
39 asset, err := adminClient.CreateAsset(ctx, &adminv1.CreateAssetRequest{
40 Org: org,
41 Type: "deploy",
42 Name: name,
43 Extension: "tar.gz",
44 EstimatedSizeBytes: estimatedSizeBytes,
45 })
46 if err != nil {
47 return "", err
48 }
49
50 err = archive.Upload(ctx, asset.SignedUrl, b, asset.SigningHeaders)
51 if err != nil {
52 return "", err
53 }
54
55 return asset.AssetId, nil
56}

Callers 4

DeployProjectMethod · 0.92
RedeployProjectMethod · 0.92
DeployWithUploadFlowFunction · 0.92
redeployProjectFunction · 0.92

Calls 8

CreateFunction · 0.92
UploadFunction · 0.92
ListGlobMethod · 0.65
RootMethod · 0.65
ErrorfMethod · 0.65
CreateAssetMethod · 0.65
ClientMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected