From bd553868ae635267f1615927ca7a6656406d16df Mon Sep 17 00:00:00 2001 From: Ash McKenzie Date: Mon, 1 Jul 2024 12:17:14 +1000 Subject: [PATCH] Field needs to be called Url Changelog: fixed --- workhorse/cmd/gitlab-workhorse/channel_test.go | 2 +- workhorse/internal/api/channel_settings.go | 8 ++++---- workhorse/internal/api/channel_settings_test.go | 4 ++-- workhorse/internal/channel/auth_checker_test.go | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/workhorse/cmd/gitlab-workhorse/channel_test.go b/workhorse/cmd/gitlab-workhorse/channel_test.go index 6e8ad945fd2dc4..11b414cc526c0d 100644 --- a/workhorse/cmd/gitlab-workhorse/channel_test.go +++ b/workhorse/cmd/gitlab-workhorse/channel_test.go @@ -174,7 +174,7 @@ func webSocketHandler(upgrader *websocket.Upgrader, connCh chan connWithReq) htt func channelOkBody(remote *httptest.Server, header http.Header, subprotocols ...string) *api.Response { out := &api.Response{ Channel: &api.ChannelSettings{ - WsURL: websocketURL(remote.URL), + Url: websocketURL(remote.URL), Header: header, Subprotocols: subprotocols, MaxSessionTime: 0, diff --git a/workhorse/internal/api/channel_settings.go b/workhorse/internal/api/channel_settings.go index 6e8d2f13b07129..779d2ad7e691ff 100644 --- a/workhorse/internal/api/channel_settings.go +++ b/workhorse/internal/api/channel_settings.go @@ -19,7 +19,7 @@ type ChannelSettings struct { Subprotocols []string // The websocket URL to connect to. - WsURL string + Url string //nolint:revive,stylecheck // when JSON decoding, the value is provided via 'url' // Any headers (e.g., Authorization) to send with the websocket request Header http.Header @@ -35,7 +35,7 @@ type ChannelSettings struct { // URL parses the websocket URL in the ChannelSettings and returns a *url.URL. func (t *ChannelSettings) URL() (*url.URL, error) { - return url.Parse(t.WsURL) + return url.Parse(t.Url) } // Dialer returns a websocket Dialer configured with the settings from ChannelSettings. @@ -72,7 +72,7 @@ func (t *ChannelSettings) Clone() *ChannelSettings { // Dial establishes a websocket connection using the settings from ChannelSettings. // It returns a websocket connection, an HTTP response, and an error if any. func (t *ChannelSettings) Dial() (*websocket.Conn, *http.Response, error) { - return t.Dialer().Dial(t.WsURL, t.Header) + return t.Dialer().Dial(t.Url, t.Header) } // Validate checks if the ChannelSettings instance is valid. @@ -133,7 +133,7 @@ func (t *ChannelSettings) IsEqual(other *ChannelSettings) bool { } } - return t.WsURL == other.WsURL && + return t.Url == other.Url && t.CAPem == other.CAPem && t.MaxSessionTime == other.MaxSessionTime } diff --git a/workhorse/internal/api/channel_settings_test.go b/workhorse/internal/api/channel_settings_test.go index d33d78222d24eb..1735a8b6e3d778 100644 --- a/workhorse/internal/api/channel_settings_test.go +++ b/workhorse/internal/api/channel_settings_test.go @@ -9,7 +9,7 @@ import ( func channel(url string, subprotocols ...string) *ChannelSettings { return &ChannelSettings{ - WsURL: url, + Url: url, Subprotocols: subprotocols, MaxSessionTime: 0, } @@ -146,7 +146,7 @@ func TestIsEqual(t *testing.T) { {chann, chann, true}, {chann.Clone(), chann.Clone(), true}, {chann, channel("foo:"), false}, - {chann, channel(chann.WsURL), false}, + {chann, channel(chann.Url), false}, {header(chann), header(chann), true}, {channHeader2, channHeader2, true}, {channHeader3, channHeader3, true}, diff --git a/workhorse/internal/channel/auth_checker_test.go b/workhorse/internal/channel/auth_checker_test.go index 36a45b07c1e2c0..b522cf5da1fff3 100644 --- a/workhorse/internal/channel/auth_checker_test.go +++ b/workhorse/internal/channel/auth_checker_test.go @@ -19,7 +19,7 @@ func checkerSeries(values ...*api.ChannelSettings) AuthCheckerFunc { } func TestAuthCheckerStopsWhenAuthFails(t *testing.T) { - template := &api.ChannelSettings{WsURL: "ws://example.com"} + template := &api.ChannelSettings{Url: "ws://example.com"} stopCh := make(chan error) series := checkerSeries(template, template, template) ac := NewAuthChecker(series, template, stopCh) @@ -35,9 +35,9 @@ func TestAuthCheckerStopsWhenAuthFails(t *testing.T) { } func TestAuthCheckerStopsWhenAuthChanges(t *testing.T) { - template := &api.ChannelSettings{WsURL: "ws://example.com"} + template := &api.ChannelSettings{Url: "ws://example.com"} changed := template.Clone() - changed.WsURL = "wss://example.com" + changed.Url = "wss://example.com" stopCh := make(chan error) series := checkerSeries(template, changed, template) ac := NewAuthChecker(series, template, stopCh) -- GitLab