From 23d8ae4d59ef4f999bacb784ffea2fcc6cac0c5f Mon Sep 17 00:00:00 2001 From: Roman Dmytrenko Date: Wed, 20 Dec 2023 19:24:48 +0200 Subject: [PATCH] drop configuration for account and shared_key as rely on envs of go-cloud --- build/internal/cmd/azurite/main.go | 4 ++-- build/testing/integration.go | 8 ++++---- config/flipt.schema.cue | 2 -- config/flipt.schema.json | 6 ------ internal/config/config_test.go | 4 +--- internal/config/storage.go | 6 ++---- internal/config/testdata/storage/azblob_full.yml | 2 -- internal/storage/fs/azblob/store.go | 14 -------------- internal/storage/fs/store/store.go | 2 -- 9 files changed, 9 insertions(+), 39 deletions(-) diff --git a/build/internal/cmd/azurite/main.go b/build/internal/cmd/azurite/main.go index 94ade39d4e..3edb519d79 100644 --- a/build/internal/cmd/azurite/main.go +++ b/build/internal/cmd/azurite/main.go @@ -33,8 +33,8 @@ func main() { ctx := context.Background() credentials, err := azblob.NewSharedKeyCredential( - os.Getenv("FLIPT_STORAGE_OBJECT_AZBLOB_ACCOUNT"), - os.Getenv("FLIPT_STORAGE_OBJECT_AZBLOB_SHARED_KEY"), + os.Getenv("AZURE_STORAGE_ACCOUNT"), + os.Getenv("AZURE_STORAGE_KEY"), ) fatalOnError(err) client, err := azblob.NewClientWithSharedKeyCredential(blobURL, credentials, nil) diff --git a/build/testing/integration.go b/build/testing/integration.go index 40d7331d9d..87bff6aa6b 100644 --- a/build/testing/integration.go +++ b/build/testing/integration.go @@ -507,8 +507,8 @@ func azblob(ctx context.Context, client *dagger.Client, base, flipt *dagger.Cont _, err := base. WithServiceBinding("azurite", azurite). - WithEnvVariable("FLIPT_STORAGE_OBJECT_AZBLOB_ACCOUNT", "devstoreaccount1"). - WithEnvVariable("FLIPT_STORAGE_OBJECT_AZBLOB_SHARED_KEY", "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="). + WithEnvVariable("AZURE_STORAGE_ACCOUNT", "devstoreaccount1"). + WithEnvVariable("AZURE_STORAGE_KEY", "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="). WithExec([]string{"go", "run", "./build/internal/cmd/azurite/...", "-url", "http://azurite:10000/devstoreaccount1", "-testdata-dir", testdataDir}). Sync(ctx) if err != nil { @@ -522,8 +522,8 @@ func azblob(ctx context.Context, client *dagger.Client, base, flipt *dagger.Cont WithEnvVariable("FLIPT_STORAGE_OBJECT_TYPE", "azblob"). WithEnvVariable("FLIPT_STORAGE_OBJECT_AZBLOB_ENDPOINT", "http://azurite:10000/devstoreaccount1"). WithEnvVariable("FLIPT_STORAGE_OBJECT_AZBLOB_CONTAINER", "testdata"). - WithEnvVariable("FLIPT_STORAGE_OBJECT_AZBLOB_ACCOUNT", "devstoreaccount1"). - WithEnvVariable("FLIPT_STORAGE_OBJECT_AZBLOB_SHARED_KEY", "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="). + WithEnvVariable("AZURE_STORAGE_ACCOUNT", "devstoreaccount1"). + WithEnvVariable("AZURE_STORAGE_KEY", "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="). WithEnvVariable("UNIQUE", uuid.New().String()) return suite(ctx, "readonly", base, flipt.WithExec(nil), conf) diff --git a/config/flipt.schema.cue b/config/flipt.schema.cue index f21a43281e..e8a231a572 100644 --- a/config/flipt.schema.cue +++ b/config/flipt.schema.cue @@ -181,8 +181,6 @@ import "strings" } azblob?: { container: string - account: string - shared_key?: string endpoint?: string poll_interval?: =~#duration | *"1m" } diff --git a/config/flipt.schema.json b/config/flipt.schema.json index ae414d5ac1..182cd7c2ec 100644 --- a/config/flipt.schema.json +++ b/config/flipt.schema.json @@ -655,12 +655,6 @@ "container": { "type": "string" }, - "account": { - "type": "string" - }, - "shared_key": { - "type": "string" - }, "endpoint": { "type": "string" }, diff --git a/internal/config/config_test.go b/internal/config/config_test.go index c52033cb28..98868e6533 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -798,7 +798,7 @@ func TestLoad(t *testing.T) { { name: "azblob config invalid", path: "./testdata/storage/azblob_invalid.yml", - wantErr: errors.New("azblob container and account must be specified"), + wantErr: errors.New("azblob container must be specified"), }, { name: "azblob full config provided", @@ -811,8 +811,6 @@ func TestLoad(t *testing.T) { Type: AZBlobObjectSubStorageType, AZBlob: &AZBlob{ Container: "testdata", - Account: "devaccount", - SharedKey: "sharedkey", Endpoint: "https//devaccount.blob.core.windows.net", PollInterval: 5 * time.Minute, }, diff --git a/internal/config/storage.go b/internal/config/storage.go index 6b474b652b..84bd4821d7 100644 --- a/internal/config/storage.go +++ b/internal/config/storage.go @@ -166,7 +166,7 @@ func (o *Object) validate() error { return errors.New("s3 bucket must be specified") } case AZBlobObjectSubStorageType: - if o.AZBlob == nil || o.AZBlob.Container == "" || o.AZBlob.Account == "" { + if o.AZBlob == nil || o.AZBlob.Container == "" { return errors.New("azblob container and account must be specified") } default: @@ -186,9 +186,7 @@ type S3 struct { // AZBlob contains configuration for referencing a Azure Blob Storage type AZBlob struct { - Account string `json:"-" mapstructure:"account" yaml:"account,omitempty"` - SharedKey string `json:"-" mapstructure:"shared_key" yaml:"shared_key,omitempty"` - Endpoint string `json:"endpoint,omitempty" mapstructure:"endpoint" yaml:"endpoint,omitempty"` + Endpoint string `json:"-" mapstructure:"endpoint" yaml:"endpoint,omitempty"` Container string `json:"container,omitempty" mapstructure:"container" yaml:"container,omitempty"` PollInterval time.Duration `json:"pollInterval,omitempty" mapstructure:"poll_interval" yaml:"poll_interval,omitempty"` } diff --git a/internal/config/testdata/storage/azblob_full.yml b/internal/config/testdata/storage/azblob_full.yml index e2c7cfd63d..376eb0993f 100644 --- a/internal/config/testdata/storage/azblob_full.yml +++ b/internal/config/testdata/storage/azblob_full.yml @@ -4,7 +4,5 @@ storage: type: azblob azblob: container: testdata - account: devaccount - shared_key: sharedkey endpoint: https//devaccount.blob.core.windows.net poll_interval: "5m" diff --git a/internal/storage/fs/azblob/store.go b/internal/storage/fs/azblob/store.go index fd33868504..e192432dfd 100644 --- a/internal/storage/fs/azblob/store.go +++ b/internal/storage/fs/azblob/store.go @@ -83,20 +83,6 @@ func WithEndpoint(endpoint string) containers.Option[SnapshotStore] { } } -// WithAccount configures the account -func WithAccount(account string) containers.Option[SnapshotStore] { - return func(s *SnapshotStore) { - s.account = account - } -} - -// WithAccount configures the account -func NewWithSharedKey(sharedKey string) containers.Option[SnapshotStore] { - return func(s *SnapshotStore) { - s.sharedKey = sharedKey - } -} - // WithPollOptions configures the poller options used when periodically updating snapshot state func WithPollOptions(opts ...containers.Option[storagefs.Poller]) containers.Option[SnapshotStore] { return func(s *SnapshotStore) { diff --git a/internal/storage/fs/store/store.go b/internal/storage/fs/store/store.go index 568eb9eb00..433bd07efa 100644 --- a/internal/storage/fs/store/store.go +++ b/internal/storage/fs/store/store.go @@ -161,8 +161,6 @@ func newObjectStore(ctx context.Context, cfg *config.Config, logger *zap.Logger) return storagefs.NewStore(snapStore), nil case config.AZBlobObjectSubStorageType: opts := []containers.Option[azblob.SnapshotStore]{ - azblob.WithAccount(objectCfg.AZBlob.Account), - azblob.NewWithSharedKey(objectCfg.AZBlob.SharedKey), azblob.WithEndpoint(objectCfg.AZBlob.Endpoint), azblob.WithPollOptions( storagefs.WithInterval(objectCfg.AZBlob.PollInterval),