func listBuckets(conn s3iface.S3API) error { output, err := conn.ListBuckets(nil) if err != nil { return err } for _, b := range output.Buckets { fmt.Fprintf(out, "s3://%s/\n", *b.Name) } return nil }
func rmBuckets(conn s3iface.S3API, buckets []string) error { for _, name := range buckets { bucket, _ := extractBucketPath(name) input := s3.DeleteBucketInput{Bucket: aws.String(bucket)} _, err := conn.DeleteBucket(&input) if err != nil { return err } } return nil }
func putBuckets(conn s3iface.S3API, buckets []string) error { for _, bucket := range buckets { input := s3.CreateBucketInput{ ACL: aws.String(acl), Bucket: aws.String(bucket), } _, err := conn.CreateBucket(&input) if err != nil { return err } } return nil }
func deleteBatch(conn s3iface.S3API, bucket string, batch []*s3.ObjectIdentifier) error { if !dryRun { deleteRequest := s3.Delete{ Objects: batch, } input := s3.DeleteObjectsInput{ Bucket: aws.String(bucket), Delete: &deleteRequest, } _, err := conn.DeleteObjects(&input) return err } return nil }