-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fs/azure): add support for Azure Blob Storage (FS Object Backend)
- Loading branch information
Showing
21 changed files
with
926 additions
and
373 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,7 @@ jobs: | |
"fs/local", | ||
"fs/s3", | ||
"fs/oci", | ||
"fs/azblob", | ||
"import/export", | ||
] | ||
steps: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"fmt" | ||
"io/fs" | ||
"log" | ||
"os" | ||
|
||
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob" | ||
) | ||
|
||
func main() { | ||
var blobURL, testdataDir, container string | ||
flag.StringVar(&blobURL, "url", "", "Address for target azurite blob service") | ||
flag.StringVar(&testdataDir, "testdata-dir", "", "Directory path to testdata") | ||
flag.StringVar(&container, "container", "testdata", "Azurite blob container") | ||
flag.Parse() | ||
|
||
fatalOnError := func(err error) { | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
|
||
if blobURL == "" { | ||
log.Fatal("Must supply non-empty -url flag value.") | ||
} | ||
|
||
fmt.Fprintln(os.Stderr, "Syncing data to azurite blob at", blobURL) | ||
|
||
ctx := context.Background() | ||
|
||
credentials, err := azblob.NewSharedKeyCredential( | ||
os.Getenv("FLIPT_STORAGE_OBJECT_AZBLOB_ACCOUNT"), | ||
os.Getenv("FLIPT_STORAGE_OBJECT_AZBLOB_SHARED_KEY"), | ||
) | ||
fatalOnError(err) | ||
client, err := azblob.NewClientWithSharedKeyCredential(blobURL, credentials, nil) | ||
fatalOnError(err) | ||
|
||
fmt.Fprintln(os.Stderr, "Using azurite blob container", container) | ||
_, err = client.CreateContainer(ctx, container, nil) | ||
fatalOnError(err) | ||
|
||
dir := os.DirFS(testdataDir) | ||
fatalOnError(err) | ||
|
||
// copy testdata into target s3 bucket | ||
err = fs.WalkDir(dir, ".", func(path string, d fs.DirEntry, err error) error { | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if d.IsDir() { | ||
return nil | ||
} | ||
|
||
fmt.Fprintln(os.Stderr, "Copying", path) | ||
|
||
f, err := dir.Open(path) | ||
if err != nil { | ||
return err | ||
} | ||
defer f.Close() | ||
|
||
_, err = client.UploadStream(ctx, container, path, f, nil) | ||
|
||
return err | ||
}) | ||
fatalOnError(err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.