( ctx context.Context, creds *devopt.Credentials, dir, profile string, )
| 18 | ) |
| 19 | |
| 20 | func 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 | } |
no test coverage detected