From 0015641f998671d2fbafe30b2e6be3c31fb3cb44 Mon Sep 17 00:00:00 2001 From: Francesco Renzi Date: Tue, 13 Jan 2026 17:19:16 +0000 Subject: [PATCH] Remove unused fields (#48) --- client.go | 15 +++++++++++++++ examples/dockerscaleset/main.go | 2 -- types.go | 7 ------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/client.go b/client.go index 247a1f5..d51d911 100644 --- a/client.go +++ b/client.go @@ -415,11 +415,24 @@ func (c *Client) GetRunnerGroupByName(ctx context.Context, runnerGroup string) ( return &runnerGroupList.RunnerGroups[0], nil } +// applyDefaultLabelTypes ensures that each label in the runner scale set has a Type set, +// defaulting to "System" when the field is empty. This encapsulates the legacy API detail +// so that callers do not need to manage label types explicitly. +func applyDefaultLabelTypes(runnerScaleSet *RunnerScaleSet) { + for i := range runnerScaleSet.Labels { + if runnerScaleSet.Labels[i].Type == "" { + runnerScaleSet.Labels[i].Type = "System" + } + } +} + // CreateRunnerScaleSet creates a new runner scale set. Note that runner scale set names must be unique within a runner group. func (c *Client) CreateRunnerScaleSet(ctx context.Context, runnerScaleSet *RunnerScaleSet) (*RunnerScaleSet, error) { c.mu.Lock() defer c.mu.Unlock() + applyDefaultLabelTypes(runnerScaleSet) + body, err := json.Marshal(runnerScaleSet) if err != nil { return nil, fmt.Errorf("failed to marshal runner scale set: %w", err) @@ -454,6 +467,8 @@ func (c *Client) UpdateRunnerScaleSet(ctx context.Context, runnerScaleSetID int, c.mu.Lock() defer c.mu.Unlock() + applyDefaultLabelTypes(runnerScaleSet) + path := fmt.Sprintf("%s/%d", scaleSetEndpoint, runnerScaleSetID) body, err := json.Marshal(runnerScaleSet) diff --git a/examples/dockerscaleset/main.go b/examples/dockerscaleset/main.go index b7b8512..7cc8a52 100644 --- a/examples/dockerscaleset/main.go +++ b/examples/dockerscaleset/main.go @@ -80,11 +80,9 @@ func run(ctx context.Context, c Config) error { Labels: []scaleset.Label{ { Name: c.ScaleSetName, - Type: "System", }, }, RunnerSetting: scaleset.RunnerSetting{ - Ephemeral: true, DisableUpdate: true, }, }) diff --git a/types.go b/types.go index dba5dec..851039f 100644 --- a/types.go +++ b/types.go @@ -17,11 +17,6 @@ const ( MessageTypeJobCompleted MessageType = "JobCompleted" ) -type JobAvailable struct { - AcquireJobURL string `json:"acquireJobUrl"` - JobMessageBase -} - type JobAssigned struct { JobMessageBase } @@ -134,8 +129,6 @@ type RunnerScaleSetStatistic struct { } type RunnerSetting struct { - Ephemeral bool `json:"ephemeral,omitempty"` - IsElastic bool `json:"isElastic,omitempty"` DisableUpdate bool `json:"disableUpdate,omitempty"` }