Skip to content

Commit

Permalink
Fork opencontainers/runtime-tools to allow us more control
Browse files Browse the repository at this point in the history
We are the only tools that are using runtime-tools, rather then
having to go through the vendoring process, I want to move this
under containers/common.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
  • Loading branch information
rhatdan committed Oct 8, 2021
1 parent eaf9dd6 commit 916db1c
Show file tree
Hide file tree
Showing 39 changed files with 1,886 additions and 555 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.15

require (
github.com/BurntSushi/toml v0.4.1
github.com/blang/semver v3.5.1+incompatible
github.com/containers/image/v5 v5.16.1
github.com/containers/ocicrypt v1.1.2
github.com/containers/storage v1.37.0
Expand All @@ -25,7 +26,6 @@ require (
github.com/opencontainers/image-spec v1.0.2-0.20210819154149-5ad6f50d6283
github.com/opencontainers/runc v1.0.2
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417
github.com/opencontainers/runtime-tools v0.9.0
github.com/opencontainers/selinux v1.9.1
github.com/pkg/errors v0.9.1
github.com/seccomp/libseccomp-golang v0.9.2-0.20200616122406-847368b35ebf
Expand All @@ -34,6 +34,7 @@ require (
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.7.0
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
github.com/xeipuuv/gojsonschema v1.2.0
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,6 @@ github.com/opencontainers/runtime-spec v1.0.3-0.20200929063507-e6143ca7d51d/go.m
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 h1:3snG66yBm59tKhhSPQrQ/0bCrv1LQbKt40LnUPiUxdc=
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/runtime-tools v0.0.0-20181011054405-1d69bd0f9c39/go.mod h1:r3f7wjNzSs2extwzU3Y+6pKfobzPh+kKFJ3ofN+3nfs=
github.com/opencontainers/runtime-tools v0.9.0 h1:FYgwVsKRI/H9hU32MJ/4MLOzXWodKK5zsQavY8NPMkU=
github.com/opencontainers/runtime-tools v0.9.0/go.mod h1:r3f7wjNzSs2extwzU3Y+6pKfobzPh+kKFJ3ofN+3nfs=
github.com/opencontainers/selinux v1.6.0/go.mod h1:VVGKuOLlE7v4PJyT6h7mNWvq1rzqiriPsEqVhc+svHE=
github.com/opencontainers/selinux v1.8.0/go.mod h1:RScLhm78qiWa2gbVCcGkC7tCGdgk3ogry1nUQF8Evvo=
github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xAPP8dBsCoU0KuF8=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,11 @@ type Error struct {
// ParseLevel takes a string level and returns the RFC 2119 compliance level constant.
func ParseLevel(level string) (Level, error) {
switch strings.ToUpper(level) {
case "MAY":
fallthrough
case "OPTIONAL":
case "MAY", "OPTIONAL":
return May, nil
case "SHOULD":
fallthrough
case "SHOULDNOT":
fallthrough
case "RECOMMENDED":
fallthrough
case "NOTRECOMMENDED":
case "SHOULD", "SHOULDNOT", "RECOMMENDED", "NOTRECOMMENDED": //nolint
return Should, nil
case "MUST":
fallthrough
case "MUSTNOT":
fallthrough
case "SHALL":
fallthrough
case "SHALLNOT":
fallthrough
case "REQUIRED":
case "MUST", "MUSTNOT", "SHALL", "SHALLNOT", "REQUIRED":
return Must, nil
}

Expand Down
File renamed without changes.
237 changes: 237 additions & 0 deletions pkg/runtime-tools/filepath/abs_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
package filepath

import (
"fmt"
"path/filepath"
"runtime"
"testing"
)

func TestAbs(t *testing.T) {
for _, test := range []struct {
os string
path string
cwd string
expected string
}{
{
os: "linux",
path: "/",
cwd: "/cwd",
expected: "/",
},
{
os: "linux",
path: "/a",
cwd: "/cwd",
expected: "/a",
},
{
os: "linux",
path: "/a/",
cwd: "/cwd",
expected: "/a",
},
{
os: "linux",
path: "//a",
cwd: "/cwd",
expected: "/a",
},
{
os: "linux",
path: ".",
cwd: "/cwd",
expected: "/cwd",
},
{
os: "linux",
path: "./c",
cwd: "/a/b",
expected: "/a/b/c",
},
{
os: "linux",
path: ".//c",
cwd: "/a/b",
expected: "/a/b/c",
},
{
os: "linux",
path: "../a",
cwd: "/cwd",
expected: "/a",
},
{
os: "linux",
path: "../../b",
cwd: "/cwd",
expected: "/b",
},
{
os: "windows",
path: "c:\\",
cwd: "/cwd",
expected: "c:\\",
},
{
os: "windows",
path: "c:\\a",
cwd: "c:\\cwd",
expected: "c:\\a",
},
{
os: "windows",
path: "c:\\a\\",
cwd: "c:\\cwd",
expected: "c:\\a",
},
{
os: "windows",
path: "c:\\\\a",
cwd: "c:\\cwd",
expected: "c:\\a",
},
{
os: "windows",
path: ".",
cwd: "c:\\cwd",
expected: "c:\\cwd",
},
{
os: "windows",
path: ".\\c",
cwd: "c:\\a\\b",
expected: "c:\\a\\b\\c",
},
{
os: "windows",
path: ".\\\\c",
cwd: "c:\\a\\b",
expected: "c:\\a\\b\\c",
},
{
os: "windows",
path: "..\\a",
cwd: "c:\\cwd",
expected: "c:\\a",
},
{
os: "windows",
path: "..\\..\\b",
cwd: "c:\\cwd",
expected: "c:\\b",
},
} {
t.Run(
fmt.Sprintf("Abs(%q,%q,%q)", test.os, test.path, test.cwd),
func(t *testing.T) {
os := test.os //nolint
path := test.path //nolint
cwd := test.cwd //nolint
expected := test.expected //nolint
abs, err := Abs(os, path, cwd)
if err != nil {
t.Error(err)
} else if abs != expected {
t.Errorf("unexpected result: %q (expected %q)", abs, expected)
}
},
)
}
}

func TestIsAbs(t *testing.T) {
for _, test := range []struct {
os string
path string
expected bool
}{
{
os: "linux",
path: "/",
expected: true,
},
{
os: "linux",
path: "/a",
expected: true,
},
{
os: "linux",
path: "//",
expected: true,
},
{
os: "linux",
path: "//a",
expected: true,
},
{
os: "linux",
path: ".",
expected: false,
},
{
os: "linux",
path: "./a",
expected: false,
},
{
os: "linux",
path: ".//a",
expected: false,
},
{
os: "linux",
path: "../a",
expected: false,
},
{
os: "linux",
path: "../../a",
expected: false,
},
{
os: "windows",
path: "c:\\",
expected: true,
},
{
os: "windows",
path: "c:\\a",
expected: true,
},
{
os: "windows",
path: ".",
expected: false,
},
{
os: "windows",
path: ".\\a",
expected: false,
},
{
os: "windows",
path: "..\\a",
expected: false,
},
} {
t.Run(
fmt.Sprintf("IsAbs(%q,%q)", test.os, test.path),
func(t *testing.T) {
abs := IsAbs(test.os, test.path) //nolint
if abs != test.expected { //nolint
t.Errorf("unexpected result: %t (expected %t)", abs, test.expected) //nolint
}
if runtime.GOOS == test.os { //nolint
stdAbs := filepath.IsAbs(test.path) //nolint
if abs != stdAbs {
t.Errorf("non-standard result: %t (%t is standard)", abs, stdAbs)
}
}
},
)
}
}
File renamed without changes.
Loading

0 comments on commit 916db1c

Please sign in to comment.