|
9 | 9 | cfg "github.com/stacklok/toolhive/pkg/config"
|
10 | 10 | "github.com/stacklok/toolhive/pkg/container"
|
11 | 11 | "github.com/stacklok/toolhive/pkg/container/runtime"
|
| 12 | + "github.com/stacklok/toolhive/pkg/ignore" |
12 | 13 | "github.com/stacklok/toolhive/pkg/process"
|
13 | 14 | "github.com/stacklok/toolhive/pkg/registry"
|
14 | 15 | "github.com/stacklok/toolhive/pkg/runner"
|
@@ -241,45 +242,36 @@ func BuildRunnerConfig(
|
241 | 242 | }
|
242 | 243 |
|
243 | 244 | // Initialize a new RunConfig with values from command-line flags
|
244 |
| - // TODO: As noted elsewhere, we should use the builder pattern here to make it more readable. |
245 |
| - return runner.NewRunConfigFromFlags( |
246 |
| - ctx, rt, cmdArgs, |
247 |
| - runConfig.Name, |
248 |
| - imageURL, imageMetadata, |
249 |
| - validatedHost, |
250 |
| - debugMode, |
251 |
| - runConfig.Volumes, |
252 |
| - runConfig.Secrets, |
253 |
| - runConfig.AuthzConfig, |
254 |
| - runConfig.AuditConfig, |
255 |
| - runConfig.EnableAudit, |
256 |
| - runConfig.PermissionProfile, |
257 |
| - runConfig.TargetHost, |
258 |
| - runConfig.Transport, |
259 |
| - runConfig.ProxyPort, |
260 |
| - runConfig.TargetPort, |
261 |
| - runConfig.Env, |
262 |
| - runConfig.Labels, |
263 |
| - oidcIssuer, oidcAudience, oidcJwksURL, oidcClientID, oidcAllowOpaqueTokens, |
264 |
| - finalOtelEndpoint, |
265 |
| - runConfig.OtelServiceName, |
266 |
| - finalOtelSamplingRate, |
267 |
| - runConfig.OtelHeaders, |
268 |
| - runConfig.OtelInsecure, |
269 |
| - runConfig.OtelEnablePrometheusMetricsPath, |
270 |
| - finalOtelEnvironmentVariables, |
271 |
| - runConfig.IsolateNetwork, |
272 |
| - runConfig.K8sPodPatch, |
273 |
| - runConfig.ThvCABundle, |
274 |
| - runConfig.JWKSAuthTokenFile, |
275 |
| - runConfig.JWKSAllowPrivateIP, |
276 |
| - envVarValidator, |
277 |
| - types.ProxyMode(runConfig.ProxyMode), |
278 |
| - runConfig.Group, |
279 |
| - runConfig.ToolsFilter, |
280 |
| - runConfig.IgnoreGlobally, |
281 |
| - runConfig.PrintOverlays, |
282 |
| - ) |
| 245 | + return runner.NewRunConfigBuilder(). |
| 246 | + WithRuntime(rt). |
| 247 | + WithCmdArgs(cmdArgs). |
| 248 | + WithName(runConfig.Name). |
| 249 | + WithImage(imageURL). |
| 250 | + WithHost(validatedHost). |
| 251 | + WithTargetHost(runConfig.TargetHost). |
| 252 | + WithDebug(debugMode). |
| 253 | + WithVolumes(runConfig.Volumes). |
| 254 | + WithSecrets(runConfig.Secrets). |
| 255 | + WithAuthzConfigPath(runConfig.AuthzConfig). |
| 256 | + WithAuditConfigPath(runConfig.AuditConfig). |
| 257 | + WithPermissionProfileNameOrPath(runConfig.PermissionProfile). |
| 258 | + WithNetworkIsolation(runConfig.IsolateNetwork). |
| 259 | + WithK8sPodPatch(runConfig.K8sPodPatch). |
| 260 | + WithProxyMode(types.ProxyMode(runConfig.ProxyMode)). |
| 261 | + WithTransportAndPorts(runConfig.Transport, runConfig.ProxyPort, runConfig.TargetPort). |
| 262 | + WithAuditEnabled(runConfig.EnableAudit, runConfig.AuditConfig). |
| 263 | + WithLabels(runConfig.Labels). |
| 264 | + WithGroup(runConfig.Group). |
| 265 | + WithOIDCConfig(oidcIssuer, oidcAudience, oidcJwksURL, oidcClientID, oidcAllowOpaqueTokens, |
| 266 | + runConfig.ThvCABundle, runConfig.JWKSAuthTokenFile, runConfig.JWKSAllowPrivateIP). |
| 267 | + WithTelemetryConfig(finalOtelEndpoint, runConfig.OtelEnablePrometheusMetricsPath, runConfig.OtelServiceName, |
| 268 | + finalOtelSamplingRate, runConfig.OtelHeaders, runConfig.OtelInsecure, finalOtelEnvironmentVariables). |
| 269 | + WithToolsFilter(runConfig.ToolsFilter). |
| 270 | + WithIgnoreConfig(&ignore.Config{ |
| 271 | + LoadGlobal: runConfig.IgnoreGlobally, |
| 272 | + PrintOverlays: runConfig.PrintOverlays, |
| 273 | + }). |
| 274 | + Build(ctx, imageMetadata, runConfig.Env, envVarValidator) |
283 | 275 | }
|
284 | 276 |
|
285 | 277 | // getOidcFromFlags extracts OIDC configuration from command flags
|
|
0 commit comments