Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions agent/agentcontainers/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,3 @@ type ContainerCLI interface {
// Remove removes the container
Remove(ctx context.Context, containerName string) error
}

// noopContainerCLI is a ContainerCLI that does nothing.
type noopContainerCLI struct{}

var _ ContainerCLI = noopContainerCLI{}

func (noopContainerCLI) List(_ context.Context) (codersdk.WorkspaceAgentListContainersResponse, error) {
return codersdk.WorkspaceAgentListContainersResponse{}, nil
}

func (noopContainerCLI) DetectArchitecture(_ context.Context, _ string) (string, error) {
return "<none>", nil
}
func (noopContainerCLI) Copy(_ context.Context, _ string, _ string, _ string) error { return nil }
func (noopContainerCLI) ExecAs(_ context.Context, _ string, _ string, _ ...string) ([]byte, error) {
return nil, nil
}
func (noopContainerCLI) Stop(_ context.Context, _ string) error { return nil }
func (noopContainerCLI) Remove(_ context.Context, _ string) error { return nil }
9 changes: 0 additions & 9 deletions agent/agentcontainers/devcontainercli.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,6 @@ type devcontainerCLIReadConfigConfig struct {
stderr io.Writer
}

// WithReadConfigOutput sets additional stdout and stderr writers for logs
// during ReadConfig operations.
func WithReadConfigOutput(stdout, stderr io.Writer) DevcontainerCLIReadConfigOptions {
return func(o *devcontainerCLIReadConfigConfig) {
o.stdout = stdout
o.stderr = stderr
}
}

func applyDevcontainerCLIUpOptions(opts []DevcontainerCLIUpOptions) DevcontainerCLIUpConfig {
conf := DevcontainerCLIUpConfig{Stdout: io.Discard, Stderr: io.Discard}
for _, opt := range opts {
Expand Down
7 changes: 0 additions & 7 deletions agent/agentgit/agentgit.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ func WithClock(c quartz.Clock) Option {
}
}

// WithGitBinary overrides the git binary path (for testing).
func WithGitBinary(path string) Option {
return func(h *Handler) {
h.gitBin = path
}
}

const (
// scanCooldown is the minimum interval between successive scans.
scanCooldown = 1 * time.Second
Expand Down
17 changes: 0 additions & 17 deletions aibridge/circuitbreaker/circuitbreaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"net"
"net/http"
"sync"
"time"

"github.com/sony/gobreaker/v2"
"golang.org/x/xerrors"
Expand Down Expand Up @@ -187,22 +186,6 @@ func (p *ProviderCircuitBreakers) Execute(endpoint, model string, w http.Respons
return handlerErr
}

// Timeout returns the configured timeout duration for this circuit breaker.
func (p *ProviderCircuitBreakers) Timeout() time.Duration {
return p.config.Timeout
}

// Provider returns the provider name for this circuit breaker.
func (p *ProviderCircuitBreakers) Provider() string {
return p.provider
}

// OpenErrorResponse returns the error response body when the circuit is open.
// This is exposed for handlers to use when responding to rejected requests.
func (p *ProviderCircuitBreakers) OpenErrorResponse() []byte {
return p.openErrBody()
}

// StateToGaugeValue converts gobreaker.State to a gauge value.
// closed=0, half-open=0.5, open=1
func StateToGaugeValue(s gobreaker.State) float64 {
Expand Down
34 changes: 0 additions & 34 deletions aibridge/provider/anthropic_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,40 +29,6 @@ func newTestAnthropic(t testing.TB, cfg config.Anthropic, bedrockCfg *config.AWS
return p
}

func TestAnthropic_TypeAndName(t *testing.T) {
t.Parallel()

tests := []struct {
name string
cfg config.Anthropic
expectType string
expectName string
}{
{
name: "defaults",
cfg: config.Anthropic{},
expectType: config.ProviderAnthropic,
expectName: config.ProviderAnthropic,
},
{
name: "custom_name",
cfg: config.Anthropic{Name: "anthropic-custom"},
expectType: config.ProviderAnthropic,
expectName: "anthropic-custom",
},
}

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

p := newTestAnthropic(t, tc.cfg, nil)
assert.Equal(t, tc.expectType, p.Type())
assert.Equal(t, tc.expectName, p.Name())
})
}
}

func TestNewAnthropic_KeyResolution(t *testing.T) {
t.Parallel()

Expand Down
24 changes: 0 additions & 24 deletions aibridge/provider/bedrock_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,30 +482,6 @@ func TestBedrock_CircuitBreakerOpenErrorResponse(t *testing.T) {
assert.Equal(t, "service_unavailable", openAIEnvelope.Error.Code)
}

func TestBedrock_TypeAndName(t *testing.T) {
t.Parallel()

p := newTestBedrock(t, config.Anthropic{}, config.AWSBedrock{
Region: "us-west-2",
AccessKey: "test-key",
AccessKeySecret: "test-secret",
Model: "m",
SmallFastModel: "s",
})
assert.Equal(t, config.ProviderBedrock, p.Type())
assert.Equal(t, config.ProviderBedrock, p.Name())

p2 := newTestBedrock(t, config.Anthropic{Name: "bedrock-custom"}, config.AWSBedrock{
Region: "us-west-2",
AccessKey: "test-key",
AccessKeySecret: "test-secret",
Model: "m",
SmallFastModel: "s",
})
assert.Equal(t, config.ProviderBedrock, p2.Type())
assert.Equal(t, "bedrock-custom", p2.Name())
}

func TestBedrock_KeyPool(t *testing.T) {
t.Parallel()

Expand Down
34 changes: 0 additions & 34 deletions aibridge/provider/copilot_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,6 @@ import (

var testTracer = otel.Tracer("copilot_test")

func TestCopilot_TypeAndName(t *testing.T) {
t.Parallel()

tests := []struct {
name string
cfg config.Copilot
expectType string
expectName string
}{
{
name: "defaults",
cfg: config.Copilot{},
expectType: config.ProviderCopilot,
expectName: config.ProviderCopilot,
},
{
name: "custom_name",
cfg: config.Copilot{Name: "copilot-business"},
expectType: config.ProviderCopilot,
expectName: "copilot-business",
},
}

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

p := NewCopilot(tc.cfg)
assert.Equal(t, tc.expectType, p.Type())
assert.Equal(t, tc.expectName, p.Name())
})
}
}

// TestCopilot_KeyFailoverConfig verifies that Copilot, being BYOK-only,
// returns a zero-value KeyFailoverConfig so that KeyFailoverTransport
// short-circuits and passes the request through unchanged.
Expand Down
34 changes: 0 additions & 34 deletions aibridge/provider/openai_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,40 +164,6 @@ func generateResponsesPayload(payloadSize int, inputCount int, stream bool) []by
return bodyBytes
}

func TestOpenAI_TypeAndName(t *testing.T) {
t.Parallel()

tests := []struct {
name string
cfg config.OpenAI
expectType string
expectName string
}{
{
name: "defaults",
cfg: config.OpenAI{},
expectType: config.ProviderOpenAI,
expectName: config.ProviderOpenAI,
},
{
name: "custom_name",
cfg: config.OpenAI{Name: "openai-custom"},
expectType: config.ProviderOpenAI,
expectName: "openai-custom",
},
}

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

p := NewOpenAI(tc.cfg)
assert.Equal(t, tc.expectType, p.Type())
assert.Equal(t, tc.expectName, p.Name())
})
}
}

func TestOpenAI_CreateInterceptor_Credential(t *testing.T) {
t.Parallel()

Expand Down
91 changes: 91 additions & 0 deletions aibridge/provider/provider_internal_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package provider

import (
"testing"

"github.com/stretchr/testify/assert"

"github.com/coder/coder/v2/aibridge/config"
)

func TestProvider_TypeAndName(t *testing.T) {
t.Parallel()

bedrockCfg := config.AWSBedrock{
Region: "us-west-2",
AccessKey: "test-key",
AccessKeySecret: "test-secret",
Model: "m",
SmallFastModel: "s",
}

tests := []struct {
name string
provider func(t testing.TB) Provider
expectType string
expectName string
}{
{
name: "anthropic_defaults",
provider: func(t testing.TB) Provider { return newTestAnthropic(t, config.Anthropic{}, nil) },
expectType: config.ProviderAnthropic,
expectName: config.ProviderAnthropic,
},
{
name: "anthropic_custom_name",
provider: func(t testing.TB) Provider {
return newTestAnthropic(t, config.Anthropic{Name: "anthropic-custom"}, nil)
},
expectType: config.ProviderAnthropic,
expectName: "anthropic-custom",
},
{
name: "bedrock_defaults",
provider: func(t testing.TB) Provider { return newTestBedrock(t, config.Anthropic{}, bedrockCfg) },
expectType: config.ProviderBedrock,
expectName: config.ProviderBedrock,
},
{
name: "bedrock_custom_name",
provider: func(t testing.TB) Provider {
return newTestBedrock(t, config.Anthropic{Name: "bedrock-custom"}, bedrockCfg)
},
expectType: config.ProviderBedrock,
expectName: "bedrock-custom",
},
{
name: "copilot_defaults",
provider: func(testing.TB) Provider { return NewCopilot(config.Copilot{}) },
expectType: config.ProviderCopilot,
expectName: config.ProviderCopilot,
},
{
name: "copilot_custom_name",
provider: func(testing.TB) Provider { return NewCopilot(config.Copilot{Name: "copilot-business"}) },
expectType: config.ProviderCopilot,
expectName: "copilot-business",
},
{
name: "openai_defaults",
provider: func(testing.TB) Provider { return NewOpenAI(config.OpenAI{}) },
expectType: config.ProviderOpenAI,
expectName: config.ProviderOpenAI,
},
{
name: "openai_custom_name",
provider: func(testing.TB) Provider { return NewOpenAI(config.OpenAI{Name: "openai-custom"}) },
expectType: config.ProviderOpenAI,
expectName: "openai-custom",
},
}

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

p := tc.provider(t)
assert.Equal(t, tc.expectType, p.Type())
assert.Equal(t, tc.expectName, p.Name())
})
}
}
9 changes: 0 additions & 9 deletions aibridge/tracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,3 @@ func InterceptionAttributesFromContext(ctx context.Context) []attribute.KeyValue
func WithRequestBridgeAttributesInContext(ctx context.Context, traceAttrs []attribute.KeyValue) context.Context {
return context.WithValue(ctx, traceRequestBridgeAttrsContextKey{}, traceAttrs)
}

func RequestBridgeAttributesFromContext(ctx context.Context) []attribute.KeyValue {
attrs, ok := ctx.Value(traceRequestBridgeAttrsContextKey{}).([]attribute.KeyValue)
if !ok {
return nil
}

return attrs
}
6 changes: 0 additions & 6 deletions cli/clilog/clilog.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ func WithStackdriver(loc string) Option {
}
}

func WithTrace() Option {
return func(b *Builder) {
b.Trace = true
}
}

func WithVerbose() Option {
return func(b *Builder) {
b.Verbose = true
Expand Down
13 changes: 0 additions & 13 deletions cli/clitest/clitest.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/provisioner/echo"
"github.com/coder/coder/v2/testutil"
"github.com/coder/quartz"
"github.com/coder/serpent"
)

Expand All @@ -41,18 +40,6 @@ func New(t testing.TB, args ...string) (*serpent.Invocation, config.Root) {
return NewWithCommand(t, cmd, args...)
}

// NewWithClock is like New, but injects the given clock for
// tests that are time-dependent.
func NewWithClock(t testing.TB, clk quartz.Clock, args ...string) (*serpent.Invocation, config.Root) {
var root cli.RootCmd
root.SetClock(clk)

cmd, err := root.Command(root.AGPL())
require.NoError(t, err)

return NewWithCommand(t, cmd, args...)
}

type logWriter struct {
prefix string
log slog.Logger
Expand Down
5 changes: 0 additions & 5 deletions cli/clitest/golden.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,6 @@ func Capture(inv *serpent.Invocation) *Output {
return output
}

// Golden returns the formatted output with lines prefixed by "err: " or "out: ".
func (o *Output) Golden() []byte {
return o.combined.Bytes()
}

// Stdout returns the unprefixed stdout content for parsing (e.g., JSON).
func (o *Output) Stdout() string {
return o.stdout.String()
Expand Down
Loading
Loading