Skip to content

Commit

Permalink
fix create_bucket setting
Browse files Browse the repository at this point in the history
  • Loading branch information
stv0g committed Jun 12, 2022
1 parent 7f20917 commit 5ac814e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ type S3ServerConfig struct {

// S3ServerSetup describes initial configuration for an S3 server/bucket
type S3ServerSetup struct {
CreateBucket bool `json:"create_bucket" yaml:"create_bucket"`
Bucket bool `json:"bucket" yaml:"bucket"`
CORS bool `json:"cors" yaml:"cors"`
Lifecycle bool `json:"lifecycle" yaml:"ifecycle"`
AbortIncompleteUploads int `json:"abort_incomplete_uploads" yaml:"abort_incomplete_uploads"`
Expand Down Expand Up @@ -177,8 +177,8 @@ func NewConfig(configFile string) (*Config, error) {
cfg.SetDefault("no_ssl", false)
cfg.SetDefault("access_key", "")
cfg.SetDefault("secret_key", "")
cfg.SetDefault("create_bucket", true)
cfg.SetDefault("implementation", "")
cfg.SetDefault("setup.bucket", true)
cfg.SetDefault("setup.cors", true)
cfg.SetDefault("setup.lifecycle", true)
cfg.SetDefault("setup.abort_incomplete_uploads", 31)
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (s *Server) Setup() error {
if _, err := s.GetBucketPolicy(&s3.GetBucketPolicyInput{
Bucket: aws.String(s.Config.Bucket),
}); err != nil {
if aerr, ok := err.(awserr.Error); ok && aerr.Code() == s3.ErrCodeNoSuchBucket && s.Config.Setup.CreateBucket {
if aerr, ok := err.(awserr.Error); ok && aerr.Code() == s3.ErrCodeNoSuchBucket && s.Config.Setup.Bucket {
if _, err := s.CreateBucket(&s3.CreateBucketInput{
Bucket: aws.String(s.Config.Bucket),
}); err != nil {
Expand Down

0 comments on commit 5ac814e

Please sign in to comment.