Skip to content

Commit fa5aa22

Browse files
committed
Fix runtime_config round-trip response behavior
1 parent 939cb54 commit fa5aa22

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

pkg/api/v1/workload_service.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ import (
77
"context"
88
"errors"
99
"fmt"
10+
"log/slog"
1011
"strings"
1112
"time"
1213

1314
nameref "github.com/google/go-containerregistry/pkg/name"
15+
regtypes "github.com/stacklok/toolhive-core/registry/types"
1416
groupval "github.com/stacklok/toolhive-core/validation/group"
1517
httpval "github.com/stacklok/toolhive-core/validation/http"
1618
"github.com/stacklok/toolhive/pkg/auth/remote"
1719
"github.com/stacklok/toolhive/pkg/config"
1820
"github.com/stacklok/toolhive/pkg/container/runtime"
1921
"github.com/stacklok/toolhive/pkg/container/templates"
2022
"github.com/stacklok/toolhive/pkg/groups"
21-
"github.com/stacklok/toolhive/pkg/logger"
2223
"github.com/stacklok/toolhive/pkg/networking"
23-
regtypes "github.com/stacklok/toolhive/pkg/registry/registry"
2424
"github.com/stacklok/toolhive/pkg/runner"
2525
"github.com/stacklok/toolhive/pkg/runner/retriever"
2626
"github.com/stacklok/toolhive/pkg/secrets"
@@ -94,13 +94,13 @@ func (s *WorkloadService) CreateWorkloadFromRequest(ctx context.Context, req *cr
9494

9595
// Save the workload state
9696
if err := runConfig.SaveState(ctx); err != nil {
97-
logger.Errorf("Failed to save workload config: %v", err)
97+
slog.Error("failed to save workload config", "error", err)
9898
return nil, fmt.Errorf("failed to save workload config: %w", err)
9999
}
100100

101101
// Start workload
102102
if err := s.workloadManager.RunWorkloadDetached(ctx, runConfig); err != nil {
103-
logger.Errorf("Failed to start workload: %v", err)
103+
slog.Error("failed to start workload", "error", err)
104104
return nil, fmt.Errorf("failed to start workload: %w", err)
105105
}
106106

@@ -112,7 +112,7 @@ func (s *WorkloadService) UpdateWorkloadFromRequest(ctx context.Context, name st
112112
// If ProxyPort is 0, reuse the existing port
113113
if req.ProxyPort == 0 && existingPort > 0 {
114114
req.ProxyPort = existingPort
115-
logger.Debugf("Reusing existing port %d for workload %s", existingPort, name)
115+
slog.Debug("reusing existing port", "port", existingPort, "name", name)
116116
}
117117

118118
// Build the full run config
@@ -345,7 +345,7 @@ func (s *WorkloadService) BuildFullRunConfig(
345345

346346
runConfig, err := runner.NewRunConfigBuilder(ctx, imageMetadata, req.EnvVars, &runner.DetachedEnvVarValidator{}, options...)
347347
if err != nil {
348-
logger.Errorf("Failed to build run config: %v", err)
348+
slog.Error("failed to build run config", "error", err)
349349
return nil, fmt.Errorf("%w: Failed to build run config: %w", retriever.ErrInvalidRunConfig, err)
350350
}
351351

pkg/api/v1/workloads_types_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/stacklok/toolhive/pkg/auth"
1414
"github.com/stacklok/toolhive/pkg/auth/remote"
1515
"github.com/stacklok/toolhive/pkg/container/templates"
16-
"github.com/stacklok/toolhive/pkg/permissions"
16+
"github.com/stacklok/toolhive-core/permissions"
1717
"github.com/stacklok/toolhive/pkg/runner"
1818
"github.com/stacklok/toolhive/pkg/secrets"
1919
"github.com/stacklok/toolhive/pkg/transport/types"

0 commit comments

Comments
 (0)