Created
July 18, 2022 12:05
-
-
Save slp/045c30696aabf8da51aed6e45e448e5b to your computer and use it in GitHub Desktop.
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
From 7de989625b0d643893b8f66ce1f305cc579ead90 Mon Sep 17 00:00:00 2001 | |
From: Sergio Lopez <[email protected]> | |
Date: Mon, 25 Jan 2021 14:01:01 +0100 | |
Subject: [PATCH 2/4] run_unix: return a valid DefaultNamespaceOptions | |
On non-Linux systems return a valid DefaultNamespaceOptions with all | |
namespaces disabled. This allows buildah to still perform most image | |
operations even on systems without support for namespaces. | |
[NO NEW TESTS NEEDED] This only has an impact to the "darwin" target | |
Signed-off-by: Sergio Lopez <[email protected]> | |
(cherry picked from commit 79bab77a7e2d1fb84a07d78b2a29585ef558e3fb) | |
Signed-off-by: Sergio Lopez <[email protected]> | |
--- | |
run_unix.go | 12 +++++++++++- | |
1 file changed, 11 insertions(+), 1 deletion(-) | |
diff --git a/run_unix.go b/run_unix.go | |
index 9e62691e..17870728 100644 | |
--- a/run_unix.go | |
+++ b/run_unix.go | |
@@ -5,6 +5,7 @@ package buildah | |
import ( | |
"github.com/containers/buildah/define" | |
nettypes "github.com/containers/common/libnetwork/types" | |
+ "github.com/opencontainers/runtime-spec/specs-go" | |
"github.com/containers/storage" | |
"github.com/pkg/errors" | |
) | |
@@ -22,7 +23,16 @@ func (b *Builder) Run(command []string, options RunOptions) error { | |
return errors.New("function not supported on non-linux systems") | |
} | |
func DefaultNamespaceOptions() (NamespaceOptions, error) { | |
- return NamespaceOptions{}, errors.New("function not supported on non-linux systems") | |
+ options := NamespaceOptions{ | |
+ {Name: string(specs.CgroupNamespace), Host: false}, | |
+ {Name: string(specs.IPCNamespace), Host: false}, | |
+ {Name: string(specs.MountNamespace), Host: false}, | |
+ {Name: string(specs.NetworkNamespace), Host: false}, | |
+ {Name: string(specs.PIDNamespace), Host: false}, | |
+ {Name: string(specs.UserNamespace), Host: false}, | |
+ {Name: string(specs.UTSNamespace), Host: false}, | |
+ } | |
+ return options, nil | |
} | |
// getNetworkInterface creates the network interface | |
-- | |
2.35.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment