# GoFeatureFlagBuilderExtensions Methods

- Package: [CommunityToolkit.Aspire.Hosting.GoFeatureFlag](/reference/api/csharp/communitytoolkit.aspire.hosting.gofeatureflag.md)
- Type: [GoFeatureFlagBuilderExtensions](/reference/api/csharp/communitytoolkit.aspire.hosting.gofeatureflag/gofeatureflagbuilderextensions.md)
- Kind: `Methods`
- Members: `4`

Provides extension methods for adding GO Feature Flag resources to the application model.

## AddGoFeatureFlag(IDistributedApplicationBuilder, string, string?, int?)

- Name: `AddGoFeatureFlag(IDistributedApplicationBuilder, string, string?, int?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<GoFeatureFlagResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.GoFeatureFlag/GoFeatureFlagBuilderExtensions.cs#L50-L67)

Adds an GO Feature Flag container resource to the application model. The default image is and the tag is .

```csharp
public static class GoFeatureFlagBuilderExtensions
{
    public static IResourceBuilder<GoFeatureFlagResource> AddGoFeatureFlag(
        this IDistributedApplicationBuilder builder,
        string name,
        string? pathToConfigFile = null,
        int? port = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder`.
- `name` (`string`)
  The name of the resource. This name will be used as the connection string name when referenced in a dependency.
- `pathToConfigFile` (`string?`) `optional`
  The path set to find the configuration file (https://gofeatureflag.org/docs/relay-proxy/configure-relay-proxy#configuration-file).
- `port` (`int?`) `optional`
  The host port to bind the underlying container to.

## Returns

`IResourceBuilder<GoFeatureFlagResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## Remarks

Add an GO Feature Flag container to the application model and reference it in a .NET project.

```csharp
var builder = DistributedApplication.CreateBuilder(args);

var goff = builder.AddGoFeatureFlag("goff");
var api = builder.AddProject<Projects.Api>("api")
  .WithReference(goff);

builder.Build().Run();
```

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithDataVolume(IResourceBuilder<GoFeatureFlagResource>, string?)

- Name: `WithDataVolume(IResourceBuilder<GoFeatureFlagResource>, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<GoFeatureFlagResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.GoFeatureFlag/GoFeatureFlagBuilderExtensions.cs#L95-L97)

Adds a named volume for the data folder to a GO Feature flag container resource.

```csharp
public static class GoFeatureFlagBuilderExtensions
{
    public static IResourceBuilder<GoFeatureFlagResource> WithDataVolume(
        this IResourceBuilder<GoFeatureFlagResource> builder,
        string? name = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<GoFeatureFlagResource>`)
  The resource builder.
- `name` (`string?`) `optional`
  The name of the volume. Defaults to an auto-generated name based on the application and resource names.

## Returns

`IResourceBuilder<GoFeatureFlagResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## Remarks

Add a GO Feature flag container to the application model and reference it in a .NET project. Additionally, in this example a data volume is added to the container to allow data to be persisted across container restarts.

```csharp
var builder = DistributedApplication.CreateBuilder(args);

var goff = builder.AddGoFeatureFlag("goff")
.WithDataVolume();
var api = builder.AddProject<Projects.Api>("api")
  .WithReference(goff);

builder.Build().Run();
```

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithGoffBindMount(IResourceBuilder<GoFeatureFlagResource>, string)

- Name: `WithGoffBindMount(IResourceBuilder<GoFeatureFlagResource>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<GoFeatureFlagResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.GoFeatureFlag/GoFeatureFlagBuilderExtensions.cs#L125-L128)

Adds a bind mount for the goff configuration folder to a GO Feature flag container resource.

```csharp
public static class GoFeatureFlagBuilderExtensions
{
    public static IResourceBuilder<GoFeatureFlagResource> WithGoffBindMount(
        this IResourceBuilder<GoFeatureFlagResource> builder,
        string source)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<GoFeatureFlagResource>`)
  The resource builder.
- `source` (`string`)
  The source directory on the host to mount into the container.

## Returns

`IResourceBuilder<GoFeatureFlagResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## Remarks

Add a GO Feature flag container to the application model and reference it in a .NET project. Additionally, in this example a bind mount is added to the container to allow reading goff configuration.

```csharp
var builder = DistributedApplication.CreateBuilder(args);

var goff = builder.AddGoFeatureFlag("goff")
.WithGoffBindMount("./goff");
var api = builder.AddProject<Projects.Api>("api")
  .WithReference(goff);

builder.Build().Run();
```

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithLogLevel(IResourceBuilder<GoFeatureFlagResource>, LogLevel)

- Name: `WithLogLevel(IResourceBuilder<GoFeatureFlagResource>, LogLevel)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<GoFeatureFlagResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.GoFeatureFlag/GoFeatureFlagBuilderExtensions.cs)

Configures logging level for the GO Feature Flag container resource.

```csharp
public static class GoFeatureFlagBuilderExtensions
{
    public static IResourceBuilder<GoFeatureFlagResource> WithLogLevel(
        this IResourceBuilder<GoFeatureFlagResource> builder,
        LogLevel logLevel)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<GoFeatureFlagResource>`)
  The resource builder.
- `logLevel` (`LogLevel`)
  The log level to set.

## Returns

`IResourceBuilder<GoFeatureFlagResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## Remarks

The only supported `Logging.LogLevel` by GO Feature Flag are `LogLevel.Error`, `LogLevel.Warning`, `LogLevel.Information` and `LogLevel.Debug`. This overload is not available in polyglot app hosts. Use the enum-based overload instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.
