Skip to content

Commit

Permalink
drop configuration for account and shared_key as rely on envs of
Browse files Browse the repository at this point in the history
go-cloud
  • Loading branch information
erka committed Dec 20, 2023
1 parent d707ed0 commit 23d8ae4
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 39 deletions.
4 changes: 2 additions & 2 deletions build/internal/cmd/azurite/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions build/testing/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions config/flipt.schema.cue
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ import "strings"
}
azblob?: {
container: string
account: string
shared_key?: string
endpoint?: string
poll_interval?: =~#duration | *"1m"
}
Expand Down
6 changes: 0 additions & 6 deletions config/flipt.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -655,12 +655,6 @@
"container": {
"type": "string"
},
"account": {
"type": "string"
},
"shared_key": {
"type": "string"
},
"endpoint": {
"type": "string"
},
Expand Down
4 changes: 1 addition & 3 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
},
Expand Down
6 changes: 2 additions & 4 deletions internal/config/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"`
}
Expand Down
2 changes: 0 additions & 2 deletions internal/config/testdata/storage/azblob_full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
14 changes: 0 additions & 14 deletions internal/storage/fs/azblob/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions internal/storage/fs/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 23d8ae4

Please sign in to comment.