Skip to content

Commit f549132

Browse files
gloursndeloof
authored andcommitted
remove support of Synchronize File Shares integration with Docker Desktop
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
1 parent f46689a commit f549132

7 files changed

Lines changed: 0 additions & 682 deletions

File tree

go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ require (
3737
github.com/opencontainers/go-digest v1.0.0
3838
github.com/opencontainers/image-spec v1.1.1
3939
github.com/otiai10/copy v1.14.1
40-
github.com/r3labs/sse v0.0.0-20210224172625-26fe804710bc
4140
github.com/sirupsen/logrus v1.9.3
4241
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
4342
github.com/spf13/cobra v1.9.1
@@ -193,7 +192,6 @@ require (
193192
google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a // indirect
194193
google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect
195194
google.golang.org/protobuf v1.36.5 // indirect
196-
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect
197195
gopkg.in/inf.v0 v0.9.1 // indirect
198196
gopkg.in/ini.v1 v1.67.0 // indirect
199197
gopkg.in/yaml.v2 v2.4.0 // indirect

go.sum

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,6 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT
420420
github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
421421
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
422422
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
423-
github.com/r3labs/sse v0.0.0-20210224172625-26fe804710bc h1:zAsgcP8MhzAbhMnB1QQ2O7ZhWYVGYSR2iVcjzQuPV+o=
424-
github.com/r3labs/sse v0.0.0-20210224172625-26fe804710bc/go.mod h1:S8xSOnV3CgpNrWd0GQ/OoQfMtlg2uPRSuTzcSGrzwK8=
425423
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
426424
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
427425
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
@@ -561,7 +559,6 @@ golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73r
561559
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
562560
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
563561
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
564-
golang.org/x/net v0.0.0-20191116160921-f9c825593386/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
565562
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
566563
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
567564
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
@@ -637,8 +634,6 @@ google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwl
637634
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
638635
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
639636
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
640-
gopkg.in/cenkalti/backoff.v1 v1.1.0 h1:Arh75ttbsvlpVA7WtVpH4u9h6Zl46xuptxqLxPiSo4Y=
641-
gopkg.in/cenkalti/backoff.v1 v1.1.0/go.mod h1:J6Vskwqd+OMVJl8C33mmtxTBs2gyzfv7UDAkHu8BrjI=
642637
gopkg.in/cenkalti/backoff.v2 v2.2.1 h1:eJ9UAg01/HIHG987TwxvnzK2MgxXq97YY6rYDpY9aII=
643638
gopkg.in/cenkalti/backoff.v2 v2.2.1/go.mod h1:S0QdOvT2AlerfSBkp0O+dk+bbIMaNbEmVk876gPCthU=
644639
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

internal/desktop/client.go

Lines changed: 0 additions & 209 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717
package desktop
1818

1919
import (
20-
"bytes"
2120
"context"
2221
"encoding/json"
23-
"errors"
2422
"fmt"
2523
"io"
2624
"net"
@@ -29,7 +27,6 @@ import (
2927

3028
"github.com/docker/compose/v2/internal"
3129
"github.com/docker/compose/v2/internal/memnet"
32-
"github.com/r3labs/sse"
3330
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
3431
)
3532

@@ -130,212 +127,6 @@ func (c *Client) FeatureFlags(ctx context.Context) (FeatureFlagResponse, error)
130127
return ret, nil
131128
}
132129

133-
type GetFileSharesConfigResponse struct {
134-
Active bool `json:"active"`
135-
Compose struct {
136-
ManageBindMounts bool `json:"manageBindMounts"`
137-
}
138-
}
139-
140-
func (c *Client) GetFileSharesConfig(ctx context.Context) (*GetFileSharesConfigResponse, error) {
141-
req, err := c.newRequest(ctx, http.MethodGet, "/mutagen/file-shares/config", http.NoBody)
142-
if err != nil {
143-
return nil, err
144-
}
145-
146-
resp, err := c.client.Do(req)
147-
if err != nil {
148-
return nil, err
149-
}
150-
defer func() {
151-
_ = resp.Body.Close()
152-
}()
153-
154-
if resp.StatusCode != http.StatusOK {
155-
return nil, newHTTPStatusCodeError(resp)
156-
}
157-
158-
var ret GetFileSharesConfigResponse
159-
if err := json.NewDecoder(resp.Body).Decode(&ret); err != nil {
160-
return nil, err
161-
}
162-
return &ret, nil
163-
}
164-
165-
type CreateFileShareRequest struct {
166-
HostPath string `json:"hostPath"`
167-
Labels map[string]string `json:"labels,omitempty"`
168-
}
169-
170-
type CreateFileShareResponse struct {
171-
FileShareID string `json:"fileShareID"`
172-
}
173-
174-
func (c *Client) CreateFileShare(ctx context.Context, r CreateFileShareRequest) (*CreateFileShareResponse, error) {
175-
rawBody, err := json.Marshal(r)
176-
if err != nil {
177-
return nil, fmt.Errorf("failed to marshal request: %w", err)
178-
}
179-
180-
req, err := c.newRequest(ctx, http.MethodPost, "/mutagen/file-shares", bytes.NewReader(rawBody))
181-
if err != nil {
182-
return nil, err
183-
}
184-
req.Header.Set("Content-Type", "application/json")
185-
186-
resp, err := c.client.Do(req)
187-
if err != nil {
188-
return nil, err
189-
}
190-
defer func() {
191-
_ = resp.Body.Close()
192-
}()
193-
194-
if resp.StatusCode != http.StatusOK {
195-
errBody, _ := io.ReadAll(resp.Body)
196-
return nil, fmt.Errorf("unexpected status code %d: %s", resp.StatusCode, string(errBody))
197-
}
198-
199-
var ret CreateFileShareResponse
200-
if err := json.NewDecoder(resp.Body).Decode(&ret); err != nil {
201-
return nil, err
202-
}
203-
return &ret, nil
204-
}
205-
206-
type FileShareReceiverState struct {
207-
TotalReceivedSize uint64 `json:"totalReceivedSize"`
208-
}
209-
210-
type FileShareEndpoint struct {
211-
Path string `json:"path"`
212-
TotalFileSize uint64 `json:"totalFileSize,omitempty"`
213-
StagingProgress *FileShareReceiverState `json:"stagingProgress"`
214-
}
215-
216-
type FileShareSession struct {
217-
SessionID string `json:"identifier"`
218-
Alpha FileShareEndpoint `json:"alpha"`
219-
Beta FileShareEndpoint `json:"beta"`
220-
Labels map[string]string `json:"labels"`
221-
Status string `json:"status"`
222-
}
223-
224-
func (c *Client) ListFileShares(ctx context.Context) ([]FileShareSession, error) {
225-
req, err := c.newRequest(ctx, http.MethodGet, "/mutagen/file-shares", http.NoBody)
226-
if err != nil {
227-
return nil, err
228-
}
229-
230-
resp, err := c.client.Do(req)
231-
if err != nil {
232-
return nil, err
233-
}
234-
defer func() {
235-
_ = resp.Body.Close()
236-
}()
237-
238-
if resp.StatusCode != http.StatusOK {
239-
return nil, newHTTPStatusCodeError(resp)
240-
}
241-
242-
var ret []FileShareSession
243-
if err := json.NewDecoder(resp.Body).Decode(&ret); err != nil {
244-
return nil, err
245-
}
246-
return ret, nil
247-
}
248-
249-
func (c *Client) DeleteFileShare(ctx context.Context, id string) error {
250-
req, err := c.newRequest(ctx, http.MethodDelete, "/mutagen/file-shares/"+id, http.NoBody)
251-
if err != nil {
252-
return err
253-
}
254-
255-
resp, err := c.client.Do(req)
256-
if err != nil {
257-
return err
258-
}
259-
defer func() {
260-
_ = resp.Body.Close()
261-
}()
262-
263-
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
264-
return newHTTPStatusCodeError(resp)
265-
}
266-
return nil
267-
}
268-
269-
type EventMessage[T any] struct {
270-
Value T
271-
Error error
272-
}
273-
274-
func newHTTPStatusCodeError(resp *http.Response) error {
275-
r := io.LimitReader(resp.Body, 2048)
276-
body, err := io.ReadAll(r)
277-
if err != nil {
278-
return fmt.Errorf("http status code %d", resp.StatusCode)
279-
}
280-
return fmt.Errorf("http status code %d: %s", resp.StatusCode, string(body))
281-
}
282-
283-
func (c *Client) StreamFileShares(ctx context.Context) (<-chan EventMessage[[]FileShareSession], error) {
284-
req, err := c.newRequest(ctx, http.MethodGet, "/mutagen/file-shares/stream", http.NoBody)
285-
if err != nil {
286-
return nil, err
287-
}
288-
289-
resp, err := c.client.Do(req)
290-
if err != nil {
291-
return nil, err
292-
}
293-
294-
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
295-
_ = resp.Body.Close()
296-
return nil, newHTTPStatusCodeError(resp)
297-
}
298-
299-
events := make(chan EventMessage[[]FileShareSession])
300-
go func(ctx context.Context) {
301-
defer func() {
302-
_ = resp.Body.Close()
303-
close(events)
304-
}()
305-
if err := readEvents(ctx, resp.Body, events); err != nil {
306-
select {
307-
case <-ctx.Done():
308-
case events <- EventMessage[[]FileShareSession]{Error: err}:
309-
}
310-
}
311-
}(ctx)
312-
return events, nil
313-
}
314-
315-
func readEvents[T any](ctx context.Context, r io.Reader, events chan<- EventMessage[T]) error {
316-
eventReader := sse.NewEventStreamReader(r)
317-
for {
318-
msg, err := eventReader.ReadEvent()
319-
if errors.Is(err, io.EOF) {
320-
return nil
321-
} else if err != nil {
322-
return fmt.Errorf("reading events: %w", err)
323-
}
324-
msg = bytes.TrimPrefix(msg, []byte("data: "))
325-
326-
var event T
327-
if err := json.Unmarshal(msg, &event); err != nil {
328-
return err
329-
}
330-
select {
331-
case <-ctx.Done():
332-
return context.Cause(ctx)
333-
case events <- EventMessage[T]{Value: event}:
334-
// event was sent to channel, read next
335-
}
336-
}
337-
}
338-
339130
func (c *Client) newRequest(ctx context.Context, method, path string, body io.Reader) (*http.Request, error) {
340131
req, err := http.NewRequestWithContext(ctx, method, backendURL(path), body)
341132
if err != nil {

0 commit comments

Comments
 (0)