MCPcopy Index your code
hub / github.com/jetify-com/devbox / Push

Function Push

internal/pullbox/s3/push.go:20–64  ·  view source on GitHub ↗
(
	ctx context.Context,
	creds *devopt.Credentials,
	dir, profile string,
)

Source from the content-addressed store, hash-verified

18)
19
20func Push(
21 ctx context.Context,
22 creds *devopt.Credentials,
23 dir, profile string,
24) error {
25 archivePath, err := tar.Compress(dir)
26 if err != nil {
27 return err
28 }
29
30 config, err := assumeRole(ctx, creds)
31 if err != nil {
32 return err
33 }
34
35 s3Client := manager.NewUploader(s3.NewFromConfig(*config))
36 file, err := os.Open(archivePath)
37 if err != nil {
38 return err
39 }
40 defer file.Close()
41
42 _, err = s3Client.Upload(ctx, &s3.PutObjectInput{
43 Bucket: aws.String(bucket),
44 Key: aws.String(
45 fmt.Sprintf(
46 "profiles/%s/%s.tar.gz",
47 creds.Sub,
48 profile,
49 ),
50 ),
51 Body: io.Reader(file),
52 })
53 if err != nil {
54 return err
55 }
56
57 ux.Fsuccessf(
58 os.Stderr,
59 "Profile successfully pushed (profile: %s)\n",
60 profile,
61 )
62
63 return nil
64}

Callers 1

PushMethod · 0.92

Calls 4

CompressFunction · 0.92
FsuccessfFunction · 0.92
assumeRoleFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected