Skip to content

Commit

Permalink
darwin build
Browse files Browse the repository at this point in the history
Closes #732

Signed-off-by: Marat Radchenko <[email protected]>
  • Loading branch information
slonopotamus committed Dec 15, 2024
1 parent 7e97f06 commit 5328c85
Show file tree
Hide file tree
Showing 27 changed files with 155 additions and 175 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
goos: linux
- os: ubuntu-24.04
goos: freebsd
- os: ubuntu-24.04
goos: darwin
# FIXME: this is currently failing in a non-sensical way, so, running on linux instead...
# - os: windows-2022
- os: ubuntu-24.04
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ jobs:
goos: windows
- os: ubuntu-24.04
goos: linux
- os: macos-15
goos: darwin
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build unix && !linux

/*
Copyright The containerd Authors.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !linux

/*
Copyright The containerd Authors.
Expand Down
23 changes: 0 additions & 23 deletions cmd/nerdctl/container/container_cp_windows.go

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !linux

/*
Copyright The containerd Authors.
Expand Down
2 changes: 2 additions & 0 deletions cmd/nerdctl/main_freebsd.go → cmd/nerdctl/main_nolinux.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !linux

/*
Copyright The containerd Authors.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ require (
github.com/docker/docker v27.4.0+incompatible
github.com/docker/go-connections v0.5.0
github.com/docker/go-units v0.5.0
github.com/fahedouch/go-logrotate v0.2.1
github.com/fahedouch/go-logrotate v0.2.2-0.20241125150317-0240e7abd7a0
github.com/fatih/color v1.18.0
github.com/fluent/fluent-logger-golang v1.9.0
github.com/fsnotify/fsnotify v1.8.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20231105174938-2b5cbb29f3e2/go.mod
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0=
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4=
github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
Expand Down Expand Up @@ -104,8 +104,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fahedouch/go-logrotate v0.2.1 h1:Q0Hk9Kp/Y4iwy9uR9e/60fEoxGhvfk8MG7WwtL9aarM=
github.com/fahedouch/go-logrotate v0.2.1/go.mod h1:Mmyex1f9fGXBNnhS9uHsbnO9BGvADF4VGqVnqAJalgc=
github.com/fahedouch/go-logrotate v0.2.2-0.20241125150317-0240e7abd7a0 h1:8G3ndPQqhkZPriZQrTX1AXM5uA6/Bqa1NelOCOwrftU=
github.com/fahedouch/go-logrotate v0.2.2-0.20241125150317-0240e7abd7a0/go.mod h1:v58eXg33TCKxsBV7Qzgi6/IqgGaEC0i8cwZsrnHKtwM=
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
Expand Down
2 changes: 2 additions & 0 deletions pkg/buildkitutil/buildkitutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ func TestBuildKitFile(t *testing.T) {
var tmp = t.TempDir()
var wd, err = os.Getwd()
assert.NilError(t, err)
tmp, err = filepath.EvalSymlinks(tmp)
assert.NilError(t, err)
err = os.Chdir(tmp)
assert.NilError(t, err)
defer os.Chdir(wd)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build unix && !linux

/*
Copyright The containerd Authors.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !linux

/*
Copyright The containerd Authors.
Expand Down
26 changes: 0 additions & 26 deletions pkg/cmd/container/exec_windows.go

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build unix && !linux

/*
Copyright The containerd Authors.
Expand All @@ -20,17 +22,11 @@ import (
"context"

containerd "github.com/containerd/containerd/v2/client"
"github.com/containerd/containerd/v2/core/containers"
"github.com/containerd/containerd/v2/pkg/oci"

"github.com/containerd/nerdctl/v2/pkg/api/types"
)

func WithoutRunMount() func(ctx context.Context, client oci.Client, c *containers.Container, s *oci.Spec) error {
// not valid on freebsd
return func(_ context.Context, _ oci.Client, _ *containers.Container, s *oci.Spec) error { return nil }
}

func setPlatformOptions(
ctx context.Context,
client *containerd.Client,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !linux

/*
Copyright The containerd Authors.
Expand Down
26 changes: 0 additions & 26 deletions pkg/cmd/container/stats_windows.go

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !linux

/*
Copyright The containerd Authors.
Expand Down
26 changes: 0 additions & 26 deletions pkg/cmd/namespace/namespace_windows.go

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build unix && !linux

/*
Copyright The containerd Authors.
Expand Down
26 changes: 23 additions & 3 deletions pkg/defaults/defaults_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,42 @@

package defaults

import gocni "github.com/containerd/go-cni"

const (
AppArmorProfileName = ""
SeccompProfileName = ""
Runtime = ""
)

func CNIPath() string {
return ""
return gocni.DefaultCNIDir
}

func CNIRuntimeDir() string {
return "/var/run/cni"
}

func CNINetConfPath() string {
return ""
return gocni.DefaultNetDir
}

func DataRoot() string {
return ""
return "/var/lib/nerdctl"
}

func CgroupManager() string {
return ""
}

func CgroupnsMode() string {
return ""
}

func NerdctlTOML() string {
return "/etc/nerdctl/nerdctl.toml"
}

func HostsDirs() []string {
return []string{}
}
Expand Down
20 changes: 14 additions & 6 deletions cmd/nerdctl/main_windows.go → pkg/infoutil/infoutil_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,24 @@
limitations under the License.
*/

package main
package infoutil

import (
"github.com/spf13/cobra"
"github.com/containerd/nerdctl/v2/pkg/inspecttypes/dockercompat"
"github.com/containerd/nerdctl/v2/pkg/sysinfo"
)

func appNeedsRootlessParentMain(cmd *cobra.Command, args []string) bool {
return false
const UnameO = "Darwin"

func CgroupsVersion() string {
return ""
}

func fulfillPlatformInfo(info *dockercompat.Info) {
// unimplemented
}

func addApparmorCommand(rootCmd *cobra.Command) {
// NOP
func mobySysInfo(info *dockercompat.Info) *sysinfo.SysInfo {
var sysinfo sysinfo.SysInfo
return &sysinfo
}
72 changes: 72 additions & 0 deletions pkg/mountutil/mountutil_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
Copyright The containerd Authors.
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 mountutil

import (
"fmt"
"strings"

"github.com/containerd/containerd/v2/pkg/oci"
"github.com/containerd/errdefs"
"github.com/containerd/log"

"github.com/containerd/nerdctl/v2/pkg/mountutil/volumestore"
)

const (
DefaultMountType = ""

DefaultPropagationMode = ""
)

func UnprivilegedMountFlags(path string) ([]string, error) {
m := []string{}
return m, nil
}

// parseVolumeOptions parses specified optsRaw with using information of
// the volume type and the src directory when necessary.
func parseVolumeOptions(vType, src, optsRaw string) ([]string, []oci.SpecOpts, error) {
var writeModeRawOpts []string
for _, opt := range strings.Split(optsRaw, ",") {
switch opt {
case "rw":
writeModeRawOpts = append(writeModeRawOpts, opt)
case "ro":
writeModeRawOpts = append(writeModeRawOpts, opt)
case "":
// NOP
default:
log.L.Warnf("unsupported volume option %q", opt)
}
}
var opts []string
if len(writeModeRawOpts) > 1 {
return nil, nil, fmt.Errorf("duplicated read/write volume option: %+v", writeModeRawOpts)
} else if len(writeModeRawOpts) > 0 && writeModeRawOpts[0] == "ro" {
opts = append(opts, "ro")
} // No need to return option when "rw"
return opts, nil, nil
}

func ProcessFlagTmpfs(s string) (*Processed, error) {
return nil, errdefs.ErrNotImplemented
}

func ProcessFlagMount(s string, volStore volumestore.VolumeStore) (*Processed, error) {
return nil, errdefs.ErrNotImplemented
}
Loading

0 comments on commit 5328c85

Please sign in to comment.