Skip to content

Commit

Permalink
fix: restore openbsd and freebsd support (#1442)
Browse files Browse the repository at this point in the history
Related to #1438.
  • Loading branch information
enocom authored Sep 27, 2022
1 parent 2a9c8d8 commit 05dcdd4
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 21 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ on:
- cron: '0 2 * * *'

jobs:
compilation:
name: FreeBSD and OpenBSD compilation check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: 'actions/checkout@v3'

- name: Verify FreeBSD and OpenBSD Builds
run: |
CGO_ENABLED=0 GOOS=freebsd go build
CGO_ENABLED=0 GOOS=openbsd go build
integration:
# run job on proper workflow event triggers (skip job for pull_request event from forks and only run pull_request_target for "tests: run" label)
if: "${{ (github.event.action != 'labeled' && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name) || github.event.label.name == 'tests: run' }}"
Expand Down
4 changes: 2 additions & 2 deletions internal/proxy/fuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !windows
// +build !windows
//go:build !windows && !openbsd && !freebsd
// +build !windows,!openbsd,!freebsd

package proxy

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@ package proxy
import (
"context"
"errors"
"path/filepath"
"strings"
)

var errFUSENotSupported = errors.New("FUSE is not supported on Windows")
var errFUSENotSupported = errors.New("FUSE is not supported on FreeBSD")

// UnixAddress returns the Unix socket for a given instance in the provided
// directory, by replacing all colons in the instance's name with periods.
func UnixAddress(dir, inst string) string {
inst2 := strings.ReplaceAll(inst, ":", ".")
return filepath.Join(dir, inst2)
// SupportsFUSE is false on FreeBSD.
func SupportsFUSE() error {
return errFUSENotSupported
}

type fuseMount struct {
// fuseDir is always an empty string on Windows.
// fuseDir is always an empty string on FreeBSD.
fuseDir string
}

Expand Down
38 changes: 38 additions & 0 deletions internal/proxy/fuse_openbsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package proxy

import (
"context"
"errors"
)

var errFUSENotSupported = errors.New("FUSE is not supported on OpenBSD")

// SupportsFUSE is false on OpenBSD.
func SupportsFUSE() error {
return errFUSENotSupported
}

type fuseMount struct {
// fuseDir is always an empty string on OpenBSD.
fuseDir string
}

func configureFUSE(c *Client, conf *Config) (*Client, error) { return nil, errFUSENotSupported }
func (c *Client) fuseMounts() []*socketMount { return nil }
func (c *Client) serveFuse(ctx context.Context, notify func()) error { return errFUSENotSupported }
func (c *Client) unmountFUSE() error { return nil }
func (c *Client) waitForFUSEMounts() {}
25 changes: 24 additions & 1 deletion internal/proxy/fuse_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,33 @@
package proxy

import (
"context"
"errors"
"path/filepath"
"strings"
)

var errFUSENotSupported = errors.New("FUSE is not supported on Windows")

// SupportsFUSE is false on Windows.
func SupportsFUSE() error {
return errors.New("fuse is not supported on Windows")
return errFUSENotSupported
}

// UnixAddress returns the Unix socket for a given instance in the provided
// directory, by replacing all colons in the instance's name with periods.
func UnixAddress(dir, inst string) string {
inst2 := strings.ReplaceAll(inst, ":", ".")
return filepath.Join(dir, inst2)
}

type fuseMount struct {
// fuseDir is always an empty string on Windows.
fuseDir string
}

func configureFUSE(c *Client, conf *Config) (*Client, error) { return nil, errFUSENotSupported }
func (c *Client) fuseMounts() []*socketMount { return nil }
func (c *Client) serveFuse(ctx context.Context, notify func()) error { return errFUSENotSupported }
func (c *Client) unmountFUSE() error { return nil }
func (c *Client) waitForFUSEMounts() {}
11 changes: 2 additions & 9 deletions internal/proxy/proxy_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !windows
// +build !windows
//go:build !windows && !openbsd && !freebsd
// +build !windows,!openbsd,!freebsd

package proxy

Expand All @@ -29,13 +29,6 @@ import (
"github.com/hanwen/go-fuse/v2/fuse"
)

// UnixAddress is defined as a function to distinguish between Linux-based
// implementations where the dir and inst and simply joins, and Windows-based
// implementations where the inst must be further altered.
func UnixAddress(dir, inst string) string {
return filepath.Join(dir, inst)
}

type socketSymlink struct {
socket *socketMount
symlink *symlink
Expand Down
27 changes: 27 additions & 0 deletions internal/proxy/unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !windows
// +build !windows

package proxy

import "path/filepath"

// UnixAddress is defined as a function to distinguish between Unix-based
// implementations where the dir and inst are simply joined, and Windows-based
// implementations where the inst must be further altered.
func UnixAddress(dir, inst string) string {
return filepath.Join(dir, inst)
}

0 comments on commit 05dcdd4

Please sign in to comment.