Skip to content

Commit

Permalink
feat: support azure blob storage (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
hgiasac authored Jan 17, 2025
1 parent c115882 commit c141415
Show file tree
Hide file tree
Showing 130 changed files with 8,617 additions and 4,799 deletions.
7 changes: 6 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ S3_SECRET_ACCESS_KEY=randomsecret
S3_DEFAULT_BUCKET=bucket1

APP_STORAGE_READ_URL="http://local.hasura.dev:8080"
APP_STORAGE_WRITE_URL="http://local.hasura.dev:8080"
APP_STORAGE_WRITE_URL="http://local.hasura.dev:8080"

AZURE_STORAGE_ENDPOINT=http://local.hasura.dev:10000
AZURE_STORAGE_DEFAULT_BUCKET=azure-test
AZURE_STORAGE_ACCOUNT_NAME=local
AZURE_STORAGE_ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
10 changes: 2 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ linters-settings:
skip-tests: true

dupl:
# Tokens count to trigger issue.
# Default: 150
threshold: 200

nestif:
Expand All @@ -44,12 +42,8 @@ linters-settings:
excludes:
- G115
- G306

# gocritic:
# disabled-checks:
# - appendAssign
# gocyclo:
# min-complexity: 40
- G401
- G501

revive:
max-open-files: 2048
Expand Down
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"azblob"
]
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ At this moment, the connector supports S3 Compatible Storage services.
| Google Cloud Storage ||
| Cloudflare R2 ||
| DigitalOcean Spaces ||
| Azure Blob Storage ||

## Get Started

Expand All @@ -27,7 +28,7 @@ The connector is built upon the MinIO Go Client SDK so it supports most of metho
## Documentation

- [Configuration](./docs/configuration.md)
- [Upload/Download Objects](./docs/upload-download.md)
- [Manage Objects](./docs/objects.md)

## License

Expand Down
17 changes: 17 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ services:
S3_DEFAULT_BUCKET: $S3_DEFAULT_BUCKET
S3_ACCESS_KEY_ID: $S3_ACCESS_KEY_ID
S3_SECRET_ACCESS_KEY: $S3_SECRET_ACCESS_KEY
AZURE_STORAGE_ENDPOINT: $AZURE_STORAGE_ENDPOINT
AZURE_STORAGE_CONNECTION_STRING: DefaultEndpointsProtocol=http;AccountName=${AZURE_STORAGE_ACCOUNT_NAME};AccountKey=${AZURE_STORAGE_ACCOUNT_KEY};BlobEndpoint=${AZURE_STORAGE_ENDPOINT}
AZURE_STORAGE_DEFAULT_BUCKET: $AZURE_STORAGE_DEFAULT_BUCKET
AZURE_STORAGE_ACCOUNT_NAME: $AZURE_STORAGE_ACCOUNT_NAME
AZURE_STORAGE_ACCOUNT_KEY: $AZURE_STORAGE_ACCOUNT_KEY
HASURA_LOG_LEVEL: debug
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4317
OTEL_METRICS_EXPORTER: prometheus
Expand Down Expand Up @@ -51,6 +56,18 @@ services:
volumes:
- s3_data:/containers3root

# https://github.com/Azure/Azurite
azurite:
image: mcr.microsoft.com/azure-storage/azurite
restart: always
command: ["azurite-blob", "--blobHost", "0.0.0.0", "-d", "/debug.log"]
extra_hosts:
- local.hasura.dev=host-gateway
ports:
- "10000:10000"
environment:
AZURITE_ACCOUNTS: "${AZURE_STORAGE_ACCOUNT_NAME}:${AZURE_STORAGE_ACCOUNT_KEY}"

volumes:
minio_data:
s3_data:
14 changes: 7 additions & 7 deletions configuration/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (

"github.com/hasura/ndc-sdk-go/utils"
"github.com/hasura/ndc-storage/connector/storage"
"github.com/hasura/ndc-storage/connector/storage/common"
"github.com/hasura/ndc-storage/connector/storage/minio"
"github.com/hasura/ndc-storage/connector/types"
"gopkg.in/yaml.v3"
)
Expand Down Expand Up @@ -63,13 +65,11 @@ var defaultConfiguration = types.Configuration{
},
Clients: []storage.ClientConfig{
{
Type: storage.EnvStorageProviderType{
EnvString: utils.NewEnvStringVariable("STORAGE_PROVIDER_TYPE"),
},
Endpoint: utils.ToPtr(utils.NewEnvStringVariable("STORAGE_ENDPOINT")),
DefaultBucket: utils.NewEnvStringVariable("DEFAULT_BUCKET"),
Authentication: storage.AuthCredentials{
Type: storage.AuthTypeStatic,
"type": common.S3,
"endpoint": utils.ToPtr(utils.NewEnvStringVariable("STORAGE_ENDPOINT")),
"defaultBucket": utils.NewEnvStringVariable("DEFAULT_BUCKET"),
"authentication": minio.AuthCredentials{
Type: minio.AuthTypeStatic,
AccessKeyID: utils.ToPtr(utils.NewEnvStringVariable("ACCESS_KEY_ID")),
SecretAccessKey: utils.ToPtr(utils.NewEnvStringVariable("SECRET_ACCESS_KEY")),
},
Expand Down
6 changes: 3 additions & 3 deletions connector-definition/configuration.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/hasura/ndc-storage/main/jsonschema/configuration.schema.json
clients:
- type:
env: STORAGE_PROVIDER_TYPE
- id: default
type: s3
endpoint:
env: STORAGE_ENDPOINT
defaultBucket:
Expand All @@ -19,4 +19,4 @@ clients:
allowedBuckets: []
concurrency:
query: 5
mutation: 1
mutation: 3
206 changes: 0 additions & 206 deletions connector/collection/object.go

This file was deleted.

Loading

0 comments on commit c141415

Please sign in to comment.