Merge pull request #1527 from mrunalp/spec_bump_v1
Bump the spec up to v1.0.0
This commit is contained in:
commit
c5ec254876
|
@ -1,7 +1,7 @@
|
|||
# OCI runtime-spec. When updating this, make sure you use a version tag rather
|
||||
# than a commit ID so it's much more obvious what version of the spec we are
|
||||
# using.
|
||||
github.com/opencontainers/runtime-spec 96de01bbb42c7af89bff100e10a9f0fb62e75bfb
|
||||
github.com/opencontainers/runtime-spec v1.0.0
|
||||
# Core libcontainer functionality.
|
||||
github.com/mrunalp/fileutils ed869b029674c0e9ce4c0dfa781405c2d9946d08
|
||||
github.com/opencontainers/selinux v1.0.0-rc1
|
||||
|
|
|
@ -11,7 +11,7 @@ const (
|
|||
VersionPatch = 0
|
||||
|
||||
// VersionDev indicates development branch. Releases will be empty string.
|
||||
VersionDev = "-rc6-dev"
|
||||
VersionDev = ""
|
||||
)
|
||||
|
||||
// Version is the specification version that the package types support.
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
// Copyright (c) 2013, Suryandaru Triandana <syndtr@gmail.com>
|
||||
// All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package capability
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestState(t *testing.T) {
|
||||
testEmpty := func(name string, c Capabilities, whats CapType) {
|
||||
for i := CapType(1); i <= BOUNDING; i <<= 1 {
|
||||
if (i&whats) != 0 && !c.Empty(i) {
|
||||
t.Errorf(name+": capabilities set %q wasn't empty", i)
|
||||
}
|
||||
}
|
||||
}
|
||||
testFull := func(name string, c Capabilities, whats CapType) {
|
||||
for i := CapType(1); i <= BOUNDING; i <<= 1 {
|
||||
if (i&whats) != 0 && !c.Full(i) {
|
||||
t.Errorf(name+": capabilities set %q wasn't full", i)
|
||||
}
|
||||
}
|
||||
}
|
||||
testPartial := func(name string, c Capabilities, whats CapType) {
|
||||
for i := CapType(1); i <= BOUNDING; i <<= 1 {
|
||||
if (i&whats) != 0 && (c.Empty(i) || c.Full(i)) {
|
||||
t.Errorf(name+": capabilities set %q wasn't partial", i)
|
||||
}
|
||||
}
|
||||
}
|
||||
testGet := func(name string, c Capabilities, whats CapType, max Cap) {
|
||||
for i := CapType(1); i <= BOUNDING; i <<= 1 {
|
||||
if (i & whats) == 0 {
|
||||
continue
|
||||
}
|
||||
for j := Cap(0); j <= max; j++ {
|
||||
if !c.Get(i, j) {
|
||||
t.Errorf(name+": capability %q wasn't found on %q", j, i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
capf := new(capsFile)
|
||||
capf.data.version = 2
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
c Capabilities
|
||||
sets CapType
|
||||
max Cap
|
||||
}{
|
||||
{"v1", new(capsV1), EFFECTIVE | PERMITTED, CAP_AUDIT_CONTROL},
|
||||
{"v3", new(capsV3), EFFECTIVE | PERMITTED | BOUNDING, CAP_LAST_CAP},
|
||||
{"file_v1", new(capsFile), EFFECTIVE | PERMITTED, CAP_AUDIT_CONTROL},
|
||||
{"file_v2", capf, EFFECTIVE | PERMITTED, CAP_LAST_CAP},
|
||||
} {
|
||||
testEmpty(tc.name, tc.c, tc.sets)
|
||||
tc.c.Fill(CAPS | BOUNDS)
|
||||
testFull(tc.name, tc.c, tc.sets)
|
||||
testGet(tc.name, tc.c, tc.sets, tc.max)
|
||||
tc.c.Clear(CAPS | BOUNDS)
|
||||
testEmpty(tc.name, tc.c, tc.sets)
|
||||
for i := CapType(1); i <= BOUNDING; i <<= 1 {
|
||||
for j := Cap(0); j <= CAP_LAST_CAP; j++ {
|
||||
tc.c.Set(i, j)
|
||||
}
|
||||
}
|
||||
testFull(tc.name, tc.c, tc.sets)
|
||||
testGet(tc.name, tc.c, tc.sets, tc.max)
|
||||
for i := CapType(1); i <= BOUNDING; i <<= 1 {
|
||||
for j := Cap(0); j <= CAP_LAST_CAP; j++ {
|
||||
tc.c.Unset(i, j)
|
||||
}
|
||||
}
|
||||
testEmpty(tc.name, tc.c, tc.sets)
|
||||
tc.c.Set(PERMITTED, CAP_CHOWN)
|
||||
testPartial(tc.name, tc.c, PERMITTED)
|
||||
tc.c.Clear(CAPS | BOUNDS)
|
||||
testEmpty(tc.name, tc.c, tc.sets)
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"go/format"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const fileName = "enum.go"
|
||||
const genName = "enum_gen.go"
|
||||
|
||||
type generator struct {
|
||||
buf bytes.Buffer
|
||||
caps []string
|
||||
}
|
||||
|
||||
func (g *generator) writeHeader() {
|
||||
g.buf.WriteString("// generated file; DO NOT EDIT - use go generate in directory with source\n")
|
||||
g.buf.WriteString("\n")
|
||||
g.buf.WriteString("package capability")
|
||||
}
|
||||
|
||||
func (g *generator) writeStringFunc() {
|
||||
g.buf.WriteString("\n")
|
||||
g.buf.WriteString("func (c Cap) String() string {\n")
|
||||
g.buf.WriteString("switch c {\n")
|
||||
for _, cap := range g.caps {
|
||||
fmt.Fprintf(&g.buf, "case %s:\n", cap)
|
||||
fmt.Fprintf(&g.buf, "return \"%s\"\n", strings.ToLower(cap[4:]))
|
||||
}
|
||||
g.buf.WriteString("}\n")
|
||||
g.buf.WriteString("return \"unknown\"\n")
|
||||
g.buf.WriteString("}\n")
|
||||
}
|
||||
|
||||
func (g *generator) writeListFunc() {
|
||||
g.buf.WriteString("\n")
|
||||
g.buf.WriteString("// List returns list of all supported capabilities\n")
|
||||
g.buf.WriteString("func List() []Cap {\n")
|
||||
g.buf.WriteString("return []Cap{\n")
|
||||
for _, cap := range g.caps {
|
||||
fmt.Fprintf(&g.buf, "%s,\n", cap)
|
||||
}
|
||||
g.buf.WriteString("}\n")
|
||||
g.buf.WriteString("}\n")
|
||||
}
|
||||
|
||||
func main() {
|
||||
fs := token.NewFileSet()
|
||||
parsedFile, err := parser.ParseFile(fs, fileName, nil, 0)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
var caps []string
|
||||
for _, decl := range parsedFile.Decls {
|
||||
decl, ok := decl.(*ast.GenDecl)
|
||||
if !ok || decl.Tok != token.CONST {
|
||||
continue
|
||||
}
|
||||
for _, spec := range decl.Specs {
|
||||
vspec := spec.(*ast.ValueSpec)
|
||||
name := vspec.Names[0].Name
|
||||
if strings.HasPrefix(name, "CAP_") {
|
||||
caps = append(caps, name)
|
||||
}
|
||||
}
|
||||
}
|
||||
g := &generator{caps: caps}
|
||||
g.writeHeader()
|
||||
g.writeStringFunc()
|
||||
g.writeListFunc()
|
||||
src, err := format.Source(g.buf.Bytes())
|
||||
if err != nil {
|
||||
fmt.Println("generated invalid Go code")
|
||||
fmt.Println(g.buf.String())
|
||||
log.Fatal(err)
|
||||
}
|
||||
fi, err := os.Stat(fileName)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := ioutil.WriteFile(genName, src, fi.Mode().Perm()); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue