Skip to content

Commit

Permalink
Merge pull request #430 from derailed/rel_v0.22.1
Browse files Browse the repository at this point in the history
Rel v0.22.1
  • Loading branch information
derailed authored Jan 28, 2025
2 parents bd9c9f4 + 7738cec commit 35b5549
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
NAME := popeye
PACKAGE := github.com/derailed/$(NAME)
VERSION := v0.22.0
VERSION := v0.22.1
GIT := $(shell git rev-parse --short HEAD)
DATE := $(shell date +%FT%T%Z)
IMG_NAME := derailed/popeye
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,13 @@ Example to save report to S3:
```shell
# AWS S3
# NOTE: You must provide env vars for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
# This will create bucket my-popeye if not present and upload a popeye json report to /fred/popeye.json
popeye --s3-bucket s3://my-popeye/fred/popeye.json --s3-region us-west-2 --out json
# This will create bucket my-popeye if not present and upload a popeye json report to /fred/scan.json
popeye --s3-bucket s3://my-popeye/fred --s3-region us-west-2 --out json --save --output-file scan.json
# Minio Object Store
# NOTE: You must provide env vars for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY and a minio server URI
# This will create bucket my-popeye if not present and upload a popeye json report to /fred/popeye.json
popeye --s3-bucket minio://my-popeye/fred/popeye.json --s3-region us-east --s3-endpoint localhost:9000
# This will create bucket my-popeye if not present and upload a popeye json report to /fred/scan.json
popeye --s3-bucket minio://my-popeye/fred --s3-region us-east --s3-endpoint localhost:9000 --out json --save --output-file scan.json
```
---
Expand Down Expand Up @@ -675,5 +675,5 @@ to make this project a reality!
---
<img src="https://github.com/derailed/popeye/blob/master/assets/imhotep_logo.png" width="32" height="auto"/> &nbsp;© 2024 Imhotep Software LLC.
<img src="https://github.com/derailed/popeye/blob/master/assets/imhotep_logo.png" width="32" height="auto"/> &nbsp;© 2025 Imhotep Software LLC.
All materials licensed under [Apache v2.0](http://www.apache.org/licenses/LICENSE-2.0)
2 changes: 1 addition & 1 deletion change_logs/release_v0.22.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ Also if you dig this tool, please make some noise on social! [@kitesurfer](https

---

<img src="https://raw.githubusercontent.com/derailed/popeye/master/assets/imhotep_logo.png" width="32" height="auto"/>&nbsp; © 2024 Imhotep Software LLC. All materials licensed under [Apache v2.0](http://www.apache.org/licenses/LICENSE-2.0)
<img src="https://raw.githubusercontent.com/derailed/popeye/master/assets/imhotep_logo.png" width="32" height="auto"/>&nbsp; © 2025 Imhotep Software LLC. All materials licensed under [Apache v2.0](http://www.apache.org/licenses/LICENSE-2.0)
23 changes: 23 additions & 0 deletions change_logs/release_v0.22.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<img src="https://raw.githubusercontent.com/derailed/popeye/master/assets/popeye_logo.png" align="right" width="200" height="auto"/>

# Release v0.22.1

## Notes

Thank you to all that contributed with flushing out issues and enhancements for Popeye! I'll try to mark some of these issues as fixed. But if you don't mind grab the latest rev and see if we're happier with some of the fixes! If you've filed an issue please help me verify and close. Your support, kindness and awesome suggestions to make Popeye better is as ever very much noticed and appreciated!

This project offers a GitHub Sponsor button (over here 👆). As you well know this is not pimped out by big corps with deep pockets. If you feel `Popeye` is saving you cycles diagnosing potential cluster issues please consider sponsoring this project!! It does go a long way in keeping our servers lights on and beers in our fridge.

Also if you dig this tool, please make some noise on social! [@kitesurfer](https://twitter.com/kitesurfer)

---

## Maintenance Release

---

## Resolved Issues

* [#425](https://github.com/derailed/popeye/issues/425) Upload to s3 failing in v0.22.0

<img src="https://raw.githubusercontent.com/derailed/popeye/master/assets/imhotep_logo.png" width="32" height="auto"/>&nbsp; © 2025 Imhotep Software LLC. All materials licensed under [Apache v2.0](http://www.apache.org/licenses/LICENSE-2.0)
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/derailed/popeye
go 1.23.0

require (
github.com/aws/aws-sdk-go-v2 v1.34.0
github.com/aws/aws-sdk-go-v2/config v1.29.2
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.54
github.com/aws/aws-sdk-go-v2/service/s3 v1.74.1
Expand Down Expand Up @@ -34,7 +35,6 @@ require (
require (
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/aws/aws-sdk-go-v2 v1.34.0 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.8 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.55 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.25 // indirect
Expand Down
24 changes: 13 additions & 11 deletions pkg/config/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"io"
"net/url"
"os"
"path/filepath"
"strings"

"github.com/aws/aws-sdk-go-v2/config"
Expand Down Expand Up @@ -58,15 +59,15 @@ func (s *S3Info) Upload(ctx context.Context, asset string, contentType string, r

switch kind {
case s3Bucket:
return s.awsUpload(ctx, bucket, key, rwc)
return s.awsUpload(ctx, bucket, key, asset, rwc)
case minioBucket:
return s.minioUpload(ctx, bucket, key, rwc)
return s.minioUpload(ctx, bucket, key, asset, rwc)
default:
return fmt.Errorf("unsupported S3 storage: %s", kind)
}
}

func (s *S3Info) minioUpload(ctx context.Context, bucket, key string, rwc io.ReadWriteCloser) error {
func (s *S3Info) minioUpload(ctx context.Context, bucket, key, asset string, rwc io.ReadWriteCloser) error {
minioClient, err := minio.New(*s.Endpoint, &minio.Options{
Creds: credentials.NewStaticV4(
os.Getenv("AWS_ACCESS_KEY_ID"),
Expand All @@ -91,7 +92,7 @@ func (s *S3Info) minioUpload(ctx context.Context, bucket, key string, rwc io.Rea
contentType := "application/octet-stream"
info, err := minioClient.PutObject(ctx,
bucket,
key,
filepath.Join(key, asset),
rwc,
-1,
minio.PutObjectOptions{ContentType: contentType},
Expand All @@ -104,7 +105,7 @@ func (s *S3Info) minioUpload(ctx context.Context, bucket, key string, rwc io.Rea
return nil
}

func (s *S3Info) awsUpload(ctx context.Context, bucket, key string, rwc io.ReadWriteCloser) error {
func (s *S3Info) awsUpload(ctx context.Context, bucket, key, asset string, rwc io.ReadWriteCloser) error {
cfg, err := config.LoadDefaultConfig(ctx,
config.WithRegion(*s.Region),
config.WithLogConfigurationWarnings(true),
Expand All @@ -115,13 +116,13 @@ func (s *S3Info) awsUpload(ctx context.Context, bucket, key string, rwc io.ReadW
}

clt := s3.NewFromConfig(cfg)
_, err = clt.CreateBucket(ctx, &s3.CreateBucketInput{
opts := s3.CreateBucketInput{
Bucket: &bucket,
CreateBucketConfiguration: &types.CreateBucketConfiguration{
LocationConstraint: types.BucketLocationConstraint(*s.Region),
},
})
if err != nil {
}
if _, err = clt.CreateBucket(ctx, &opts); err != nil {
var (
exists *types.BucketAlreadyExists
owned *types.BucketAlreadyOwnedByYou
Expand All @@ -138,15 +139,16 @@ func (s *S3Info) awsUpload(ctx context.Context, bucket, key string, rwc io.ReadW
}

uploader := manager.NewUploader(clt)
path := filepath.Join(key, asset)
_, err = uploader.Upload(ctx, &s3.PutObjectInput{
Bucket: &bucket,
Key: &key,
Key: &path,
Body: rwc,
})
if err != nil {
log.Err(err).Msgf("failed to upload to bucket: %s//%s", bucket, key)
log.Err(err).Msgf("failed to upload to bucket: %s//%s", bucket, path)
} else {
log.Info().Msgf("Success: uploaded to bucket: %s//%s", bucket, key)
log.Info().Msgf("Success: uploaded to bucket: %s//%s", bucket, path)
}

return err
Expand Down
7 changes: 7 additions & 0 deletions pkg/config/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ func TestParseBucket(t *testing.T) {
key: "with/leading/slashes",
},

"blee": {
uri: "my-bucket/popeye/my-cluster/2025/01/27/",
bucket: "my-bucket",
kind: s3Bucket,
key: "popeye/my-cluster/2025/01/27",
},

"minio": {
uri: "minio://fred/blee/",
bucket: "fred",
Expand Down

0 comments on commit 35b5549

Please sign in to comment.