Skip to content

Commit

Permalink
feat: support base
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Jul 25, 2024
1 parent 7b413ce commit 76a72eb
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 8 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Create Release
on:
push:
branches:
- main
permissions:
contents: read

jobs:
semantic-release:
permissions:
contents: write # for codfish/semantic-release-action to create release tags
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
- uses: codfish/semantic-release-action@b0e57c976bf8f74b2454f59a30e4a1b5f11727b4 # v3.3.0
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs:
release-version: ${{ steps.semantic.outputs.release-version }}
new-release-published: ${{ steps.semantic.outputs.new-release-published }}
bump-clients:
runs-on: ubuntu-latest
needs: [semantic-release]
if: needs.semantic-release.outputs.new-release-published == 'true'
strategy:
matrix:
repos: ["mission-control", "canary-checker", "config-db", "apm-hub"]
steps:
- uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
with:
repository: flanksource/${{ matrix.repos }}
token: ${{ secrets.FLANKBOT }}
- name: Setup Go
uses: buildjet/setup-go@v5
with:
go-version: v1.22.x
- uses: buildjet/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
.bin
key: cache-${{ hashFiles('**/go.sum') }}-${{ hashFiles('.bin/*') }}
restore-keys: |
cache-
- name: Create commits
run: |
# Sleep to let index refresh
sleep 60
go get github.com/flanksource/duty@v${{ needs.semantic-release.outputs.release-version }}
go mod tidy
if [ -d "hack/generate-schemas" ]; then
cd hack/generate-schemas && go mod tidy
fi
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5
with:
branch: "bump-duty-auto-pr"
commit-message: "chore: bump duty to v${{ needs.semantic-release.outputs.release-version }}"
title: "chore: bump duty to v${{ needs.semantic-release.outputs.release-version }}"
token: ${{ secrets.FLANKBOT }}
labels: dependencies

- name: Enable Pull Request Automerge
if: steps.cpr.outputs.pull-request-operation == 'created'
uses: peter-evans/enable-pull-request-automerge@v3
with:
token: ${{ secrets.FLANKBOT }}
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
merge-method: squash
repository: flanksource/${{ matrix.repos }}
20 changes: 20 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
branches:
- name: main
plugins:
- - "@semantic-release/commit-analyzer"
- releaseRules:
- { type: doc, scope: README, release: patch }
- { type: fix, release: patch }
- { type: chore, release: patch }
- { type: refactor, release: patch }
- { type: feat, release: patch }
- { type: ci, release: patch }
- { type: style, release: patch }
parserOpts:
noteKeywords:
- MAJOR RELEASE
- "@semantic-release/release-notes-generator"
- - "@semantic-release/github"
# From: https://github.com/semantic-release/github/pull/487#issuecomment-1486298997
- successComment: false
failTitle: false
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# s3fs [![Go Reference](https://pkg.go.dev/badge/github.com/jszwec/s3fs.svg)](https://pkg.go.dev/github.com/jszwec/s3fs) ![Go](https://github.com/jszwec/s3fs/workflows/Go/badge.svg?branch=main)
# s3fs [![Go Reference](https://pkg.go.dev/badge/github.com/flanksource/s3fs.svg)](https://pkg.go.dev/github.com/flanksource/s3fs) ![Go](https://github.com/flanksource/s3fs/workflows/Go/badge.svg?branch=main)

Package s3fs provides a S3 implementation for Go1.16 [filesystem](https://tip.golang.org/pkg/io/fs/#FS) interface.

Since S3 is a flat structure, s3fs simulates directories by using
prefixes and "/" delim. ModTime on directories is always zero value.

# SDK Versions
```github.com/jszwec/s3fs``` uses aws sdk v1
```github.com/flanksource/s3fs``` uses aws sdk v1

```github.com/jszwec/s3fs/v2``` uses aws sdk v2
```github.com/flanksource/s3fs/v2``` uses aws sdk v2


# Example (SDK v1)
Expand Down Expand Up @@ -40,7 +40,7 @@ _ = fs.WalkDir(s3fs, ".", func(path string, d fs.DirEntry, err error) error {
# Installation

```
go get github.com/jszwec/s3fs
go get github.com/flanksource/s3fs
```

# Requirements
Expand Down
10 changes: 10 additions & 0 deletions fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"errors"
"io/fs"
"path/filepath"

"github.com/aws/aws-sdk-go-v2/aws/transport/http"
"github.com/aws/aws-sdk-go-v2/service/s3"
Expand Down Expand Up @@ -45,6 +46,7 @@ type Client interface {
// by using prefixes and delims ("/"). Because directories are simulated, ModTime
// is always a default Time value (IsZero returns true).
type S3FS struct {
prefix string
cl Client
bucket string
readSeeker bool
Expand All @@ -64,8 +66,14 @@ func New(cl Client, bucket string, opts ...Option) *S3FS {
return fsys
}

func (f *S3FS) WithBase(base string) *S3FS {
f.prefix = base
return f
}

// Open implements fs.FS.
func (f *S3FS) Open(name string) (fs.File, error) {
name = filepath.Join(f.prefix, name)
if !fs.ValidPath(name) {
return nil, &fs.PathError{
Op: "open",
Expand Down Expand Up @@ -112,6 +120,7 @@ func (f *S3FS) Open(name string) (fs.File, error) {

// Stat implements fs.StatFS.
func (f *S3FS) Stat(name string) (fs.FileInfo, error) {
name = filepath.Join(f.prefix, name)
fi, err := stat(f.cl, f.bucket, name)
if err != nil {
return nil, &fs.PathError{
Expand All @@ -125,6 +134,7 @@ func (f *S3FS) Stat(name string) (fs.FileInfo, error) {

// ReadDir implements fs.ReadDirFS.
func (f *S3FS) ReadDir(name string) ([]fs.DirEntry, error) {
name = filepath.Join(f.prefix, name)
d, err := openDir(f.cl, f.bucket, name)
if err != nil {
return nil, &fs.PathError{
Expand Down
4 changes: 2 additions & 2 deletions fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import (
"github.com/aws/aws-sdk-go-v2/feature/s3/manager"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/aws-sdk-go-v2/service/s3/types"
"github.com/jszwec/s3fs/v2"
"github.com/flanksource/s3fs/v2"
)

var (
endpoint = flag.String("endpoint", "http://localhost:4566", "s3 endpoint")
bucket = flag.String("bucket", "test-github.com-jszwec-s3fs", "bucket name")
bucket = flag.String("bucket", "test-github.com-flanksource-s3fs", "bucket name")
skipVerify = flag.Bool("skip-verify", true, "http insecure skip verify")
)

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/jszwec/s3fs/v2
module github.com/flanksource/s3fs/v2

go 1.21
go 1.22.5

require (
github.com/aws/aws-sdk-go-v2 v1.24.0
Expand Down

0 comments on commit 76a72eb

Please sign in to comment.