Skip to content

Commit

Permalink
fix more code-style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
stv0g committed Apr 4, 2022
1 parent b7d912a commit 6ff9cd8
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 9 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ Check our my [blog article](https://noteblok.net/2022/04/03/gos%c9%9b-a-terascal
- Scalable to multiple replicas
- All state is kept in the S3 storage backend
- No other database or cache is required
- Direct up & download to Amazon S3 via
-URLs
- Gose deployment does not see an significant traffic
- Direct up & download to Amazon S3 via presigned URLs
- Gose deployment does not see an significant traffic
- UTF-8 filenames
- Multiple user-selectable buckets / servers
- Optional link shortening via an external service
Expand Down Expand Up @@ -83,9 +82,9 @@ mv gose /usr/local/bin

### Kubernetes / Kustomize

1. Copy default configuration file: `cp config.yaml kustomize/config.yaml`
1. Adjust config: `nano kustomize/config.yaml`
1. Apply configuration: `kubectl apply -k kustomize`
1. Copy default configuration file: `cp config.yaml kustomize/config.yaml`
2. Adjust config: `nano kustomize/config.yaml`
3. Apply configuration: `kubectl apply -k kustomize`

### Docker

Expand Down
11 changes: 8 additions & 3 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ import (
)

const (
DefaultPartSize size = 16e6 // 16MB
// DefaultPartSize is the default size of the chunks used for Multi-part Upload if not provided by the configuration
DefaultPartSize size = 16e6 // 16MB

// DefaultMaxUploadSize is the maximum upload size if not provided by the configuration
DefaultMaxUploadSize size = 1e12 // 1TB
DefaultRegion = "us-east-1"

// Is the default S3 region if not provided by the configuration
DefaultRegion = "us-east-1"
)

type size int64
Expand Down Expand Up @@ -140,7 +145,7 @@ func NewConfig(configFile string) (*Config, error) {
}

// Some normalization and default values for servers
for i, _ := range cfg.Servers {
for i := range cfg.Servers {
svr := &cfg.Servers[i]

if svr.ID == "" {
Expand Down
1 change: 1 addition & 0 deletions pkg/handlers/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/vfaronov/httpheader"
)

// HandleDownload handles a request for downloading a file
func HandleDownload(c *gin.Context) {
var err error

Expand Down
1 change: 1 addition & 0 deletions pkg/handlers/initiate.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
)

const (
// MaxFileNameLength is the maximum file length which can be uploaded
MaxFileNameLength = 256
)

Expand Down
3 changes: 3 additions & 0 deletions pkg/server/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import (
"github.com/stv0g/gose/pkg/config"
)

// List is a list of Servers
type List map[string]Server

// NewList creates a new server list
func NewList(svrs []config.S3Server) List {
svcs := List{}
sess := session.Must(session.NewSession())
Expand All @@ -32,6 +34,7 @@ func NewList(svrs []config.S3Server) List {
return svcs
}

// Setup initialize all servers in the list
func (sl List) Setup() error {
for _, svc := range sl {
if err := svc.Setup(); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/stv0g/gose/pkg/config"
)

// Server is a abstraction of an S3 server/bucket
type Server struct {
*s3.S3

Expand Down Expand Up @@ -42,6 +43,7 @@ func (s *Server) GetObjectURL(key string) *url.URL {
return u
}

// GetExpirationClass gets the expiration class by name
func (s *Server) GetExpirationClass(cls string) *config.Expiration {
for _, c := range s.Config.Expiration {
if c.ID == cls {
Expand Down
1 change: 1 addition & 0 deletions pkg/server/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/aws/aws-sdk-go/service/s3"
)

// Setup initializes the S3 bucket (life-cycle rules & CORS)
func (s *Server) Setup() error {

corsRule := &s3.CORSRule{
Expand Down
2 changes: 2 additions & 0 deletions pkg/utils/etag.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import (
)

const (
// MaxPartCount is the maximum number of parts for a MPU
MaxPartCount = 10000
)

// IsValidETag check is an ETag is valid as generated/accepted by AWS-S3
func IsValidETag(et string) bool {
p := strings.SplitN(et, "-", 2)

Expand Down

0 comments on commit 6ff9cd8

Please sign in to comment.