-
Notifications
You must be signed in to change notification settings - Fork 609
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now that containerd supports FreeBSD, we can port nerdctl, too! :rocket:. For full-fledged functionality, we will need to port * buildkit. Status: POC is ready, need to upstream fixes to dependencies. * runtime + containerd shim. runj/knast should work just fine. * CNI bridge plugin for networking. This change fixes FreeBSD compilation errors by renaming linux files to unix where necessary, or otherwise introducing FreeBSD versions for the necessary files. Signed-off-by: Artem Khramov <akhramov@pm.me>
- Loading branch information
Showing
27 changed files
with
671 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
//go:build freebsd || linux | ||
// +build freebsd linux | ||
|
||
/* | ||
Copyright The containerd Authors. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//go:build freebsd | ||
// +build freebsd | ||
|
||
/* | ||
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 main | ||
|
||
import ( | ||
"github.com/opencontainers/runtime-spec/specs-go" | ||
) | ||
|
||
func setExecCapabilities(pspec *specs.Process) error { | ||
//no op freebsd | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
//go:build freebsd || linux | ||
// +build freebsd linux | ||
|
||
/* | ||
Copyright The containerd Authors. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//go:build freebsd | ||
// +build freebsd | ||
|
||
/* | ||
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 main | ||
|
||
import ( | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func appNeedsRootlessParentMain(clicontext *cli.Context) bool { | ||
return false | ||
} | ||
|
||
func appBashComplete(clicontext *cli.Context) { | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
//go:build freebsd || linux | ||
// +build freebsd linux | ||
|
||
/* | ||
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 main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/containerd/nerdctl/pkg/infoutil" | ||
|
||
"github.com/containerd/nerdctl/pkg/rootlessutil" | ||
"github.com/sirupsen/logrus" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func bashCompleteNamespaceNames(clicontext *cli.Context) { | ||
if rootlessutil.IsRootlessParent() { | ||
_ = rootlessutil.ParentMain() | ||
return | ||
} | ||
|
||
client, ctx, cancel, err := newClient(clicontext) | ||
if err != nil { | ||
return | ||
} | ||
defer cancel() | ||
nsService := client.NamespaceService() | ||
nsList, err := nsService.List(ctx) | ||
if err != nil { | ||
logrus.Warn(err) | ||
return | ||
} | ||
for _, ns := range nsList { | ||
fmt.Fprintln(clicontext.App.Writer, ns) | ||
} | ||
} | ||
|
||
func bashCompleteSnapshotterNames(clicontext *cli.Context) { | ||
if rootlessutil.IsRootlessParent() { | ||
_ = rootlessutil.ParentMain() | ||
return | ||
} | ||
|
||
client, ctx, cancel, err := newClient(clicontext) | ||
if err != nil { | ||
return | ||
} | ||
defer cancel() | ||
snapshotterPlugins, err := infoutil.GetSnapshotterNames(ctx, client.IntrospectionService()) | ||
if err != nil { | ||
return | ||
} | ||
for _, name := range snapshotterPlugins { | ||
fmt.Fprintln(clicontext.App.Writer, name) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//go:build freebsd | ||
// +build freebsd | ||
|
||
/* | ||
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 main | ||
|
||
import ( | ||
"github.com/containerd/containerd/oci" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func generateCgroupOpts(clicontext *cli.Context, id string) ([]oci.SpecOpts, error) { | ||
return []oci.SpecOpts{}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
//go:build freebsd | ||
// +build freebsd | ||
|
||
/* | ||
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 main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/containerd/containerd/containers" | ||
"github.com/containerd/containerd/oci" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func runBashComplete(clicontext *cli.Context) { | ||
coco := parseCompletionContext(clicontext) | ||
if coco.boring { | ||
defaultBashComplete(clicontext) | ||
return | ||
} | ||
if coco.flagTakesValue { | ||
w := clicontext.App.Writer | ||
switch coco.flagName { | ||
case "restart": | ||
fmt.Fprintln(w, "always") | ||
fmt.Fprintln(w, "no") | ||
return | ||
case "pull": | ||
fmt.Fprintln(w, "always") | ||
fmt.Fprintln(w, "missing") | ||
fmt.Fprintln(w, "never") | ||
return | ||
case "net", "network": | ||
bashCompleteNetworkNames(clicontext, nil) | ||
return | ||
} | ||
defaultBashComplete(clicontext) | ||
return | ||
} | ||
// show image names, unless we have "--rootfs" flag | ||
if clicontext.Bool("rootfs") { | ||
defaultBashComplete(clicontext) | ||
return | ||
} | ||
bashCompleteImageNames(clicontext) | ||
} | ||
|
||
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 } | ||
} | ||
|
||
// executablePath returns the absolute path to the current binary | ||
func executablePath() (string, error) { | ||
return filepath.Abs(os.Args[0]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.