Skip to content

Commit

Permalink
fix: small nit things
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Poignant <[email protected]>
  • Loading branch information
thomaspoignant committed Nov 21, 2024
1 parent a3bc4ff commit 93d4528
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 7 deletions.
8 changes: 4 additions & 4 deletions cmd/relayproxy/service/gofeatureflag.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ func initRetriever(c *config.RetrieverConf) (retriever.Retriever, error) {
return &redisretriever.Retriever{Options: c.RedisOptions, Prefix: c.RedisPrefix}, nil
case config.AzBlobStorageRetriever:
return &azblobretriever.Retriever{
Container: c.Container,
Object: c.Object,
AccountName: c.AccountName,
AccountKey: c.AccountKey,
Container: c.Container,
Object: c.Object,
AccountName: c.AccountName,
AccountKey: c.AccountKey,
}, nil

Check warning on line 196 in cmd/relayproxy/service/gofeatureflag.go

View check run for this annotation

Codecov / codecov/patch

cmd/relayproxy/service/gofeatureflag.go#L190-L196

Added lines #L190 - L196 were not covered by tests
default:
return nil, fmt.Errorf("invalid retriever: kind \"%s\" "+
Expand Down
6 changes: 3 additions & 3 deletions retriever/azblobstorageretriever/retriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ func (r *Retriever) Init(_ context.Context, _ *fflog.FFLogger) error {
}

func (r *Retriever) Shutdown(_ context.Context) error {
r.status = retriever.RetrieverNotReady
r.client = nil
r.status = retriever.RetrieverNotReady
return nil
}

Expand All @@ -92,7 +92,7 @@ func (r *Retriever) Retrieve(ctx context.Context) ([]byte, error) {
}

if r.Object == "" || r.Container == "" {
return nil, fmt.Errorf("missing mandatory information filePath=%s, repositorySlug=%s", r.Object, r.Container)
return nil, fmt.Errorf("missing mandatory information object=%s, repositorySlug=%s", r.Object, r.Container)
}

fileStream, err := r.client.DownloadStream(ctx, r.Container, r.Object, nil)
Expand All @@ -106,7 +106,7 @@ func (r *Retriever) Retrieve(ctx context.Context) ([]byte, error) {
body, err := io.ReadAll(retryReader)
if err != nil {
return nil,
fmt.Errorf("unable to read from Azure Blob Storage Object %s in Container %s, error: %s", r.Container, r.Object, err)
fmt.Errorf("unable to read from Azure Blob Storage Object %s in Container %s, error: %s", r.Object, r.Container, err)
}

Check warning on line 110 in retriever/azblobstorageretriever/retriever.go

View check run for this annotation

Codecov / codecov/patch

retriever/azblobstorageretriever/retriever.go#L108-L110

Added lines #L108 - L110 were not covered by tests

return body, nil
Expand Down
24 changes: 24 additions & 0 deletions retriever/azblobstorageretriever/retriever_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,30 @@ func TestAzureBlobStorageRetriever(t *testing.T) {
}
}

func TestInit(t *testing.T) {
t.Run("Should error when no account name", func(t *testing.T) {
retriever := azblobretriever.Retriever{
Container: containerName,
AccountKey: azurite.AccountKey,
Object: "flag-config.yaml",
}
err := retriever.Init(context.Background(), &fflog.FFLogger{LeveledLogger: slog.Default()})
assert.Error(t, err)
})

t.Run("Should error when calling retrieve without init", func(t *testing.T) {
retriever := azblobretriever.Retriever{
Container: containerName,
AccountName: azurite.AccountName,
AccountKey: azurite.AccountKey,
Object: "flag-config.yaml",
}
_, err := retriever.Retrieve(context.Background())
assert.Error(t, err)
})

}

func setupTest(t *testing.T) (*azurite.AzuriteContainer, *azblob.Client) {
ctx := context.Background()
azuriteContainer, err := azurite.Run(
Expand Down
9 changes: 9 additions & 0 deletions website/docs/configure_flag/store_your_flags.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import k8slogo from '@site/static/docs/retrievers/k8s.png';
import mongodblogo from '@site/static/docs/retrievers/mongodb.png';
import redislogo from '@site/static/docs/retrievers/redis.png';
import bitbucketlogo from '@site/static/docs/retrievers/bitbucket.png';
import azBloblogo from '@site/static/docs/collectors/azblob.png';


# Where to store your flags' configuration?
Expand Down Expand Up @@ -126,6 +127,14 @@ configuration and will evaluate your feature flags based on this configuration.
goModuleLink={'../go_module/store_file/bitbucket'}
/>
},
{
logoImg: azBloblogo,
title: "Azure Blob Storage",
content: <ConfigCardContent
relayproxyLink={'../relay_proxy/configure_relay_proxy#azure-blob-storage'}
goModuleLink={'../go_module/store_file/azureblobstorage'}
/>
},
{
logoImg: customlogo,
title: "Custom ...",
Expand Down
10 changes: 10 additions & 0 deletions website/docs/relay_proxy/configure_relay_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,16 @@ the [doc](../go_module/store_file/redis#expected-format) available._
| `token` | string | **none** | Bitbucket token used to access a private repository ([_Create a Repository Access Token_](https://support.atlassian.com/bitbucket-cloud/docs/create-a-repository-access-token/)). |
| `timeout` | string | `10000` | Timeout in millisecond used when calling GitLab. |

### Azure Blob Storage

| Field name | Type | Default | Description |
|---------------|--------|-----------|------------------------------------------------------------------------------------------------------------------------------------|
| `kind` | string | **none** | **(mandatory)** Value should be **`azureBlobStorage`**.<br/>_This field is mandatory and describes which retriever you are using._ |
| `container` | string | **none** | **(mandatory)** This is the name of your Azure Blob Storage container _(ex: `my-featureflag-container`)_. |
| `accountName` | string | **none** | **(mandatory)** This is the name of your Azure Blob Storage account. |
| `accountKey` | string | **none** | This is the secret key of your Azure Blob Storage account. |
| `object` | string | **none** | **(mandatory)** Location of your configuration file. |

<a name="exporter"></a>

## type `exporter`
Expand Down

0 comments on commit 93d4528

Please sign in to comment.