forked from cloudfoundry/guardian
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Pea namespace sharing out of Bundler [#151709987] Signed-off-by: Will Martin <[email protected]>
- Loading branch information
1 parent
ba009ed
commit a0d37e2
Showing
19 changed files
with
294 additions
and
116 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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,17 @@ | ||
package bundlerules | ||
|
||
import ( | ||
"code.cloudfoundry.org/guardian/gardener" | ||
"code.cloudfoundry.org/guardian/rundmc/goci" | ||
specs "github.com/opencontainers/runtime-spec/specs-go" | ||
) | ||
|
||
type Namespaces struct{} | ||
|
||
func (n Namespaces) Apply(bndl goci.Bndl, spec gardener.DesiredContainerSpec, containerDir string) (goci.Bndl, error) { | ||
for ns, path := range spec.Namespaces { | ||
bndl = bndl.WithNamespace(specs.LinuxNamespace{Type: specs.LinuxNamespaceType(ns), Path: path}) | ||
} | ||
|
||
return bndl, 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,26 @@ | ||
package bundlerules_test | ||
|
||
import ( | ||
"code.cloudfoundry.org/guardian/gardener" | ||
"code.cloudfoundry.org/guardian/rundmc/bundlerules" | ||
"code.cloudfoundry.org/guardian/rundmc/goci" | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
specs "github.com/opencontainers/runtime-spec/specs-go" | ||
) | ||
|
||
var _ = Describe("Namespaces", func() { | ||
It("sets all namespaces in the bundle to those provided by the spec", func() { | ||
initialBndl := goci.Bundle() | ||
|
||
desiredContainerSpec := gardener.DesiredContainerSpec{Namespaces: map[string]string{"mount": "", "network": "test-net-ns", "user": "test-user-ns"}} | ||
transformedBndl, err := bundlerules.Namespaces{}.Apply(initialBndl, desiredContainerSpec, "") | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
Expect(transformedBndl.Namespaces()).To(ConsistOf( | ||
specs.LinuxNamespace{Type: "mount"}, | ||
specs.LinuxNamespace{Type: "network", Path: "test-net-ns"}, | ||
specs.LinuxNamespace{Type: "user", Path: "test-user-ns"}, | ||
)) | ||
}) | ||
}) |
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
Oops, something went wrong.