versioning: revert spec version to 0.2.0
This commit is contained in:
parent
d5e2e375d4
commit
7958b9f0cc
14
SPEC.md
14
SPEC.md
@ -68,8 +68,8 @@ The operations that the CNI plugin needs to support are:
|
|||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
"cniVersion": "0.3.0", // the version of the CNI spec in use for this output
|
"cniVersion": "0.2.0", // the version of the CNI spec in use for this output
|
||||||
"supportedVersions": [ "0.1.0", "0.2.0", "0.3.0" ] // the list of CNI spec versions that this plugin supports
|
"supportedVersions": [ "0.1.0", "0.2.0" ] // the list of CNI spec versions that this plugin supports
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ Success is indicated by a return code of zero and the following JSON printed to
|
|||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
"cniVersion": "0.3.0",
|
"cniVersion": "0.2.0",
|
||||||
"ip4": {
|
"ip4": {
|
||||||
"ip": <ipv4-and-subnet-in-CIDR>,
|
"ip": <ipv4-and-subnet-in-CIDR>,
|
||||||
"gateway": <ipv4-of-the-gateway>, (optional)
|
"gateway": <ipv4-of-the-gateway>, (optional)
|
||||||
@ -120,7 +120,7 @@ Examples include generating an `/etc/resolv.conf` file to be injected into the c
|
|||||||
Errors are indicated by a non-zero return code and the following JSON being printed to stdout:
|
Errors are indicated by a non-zero return code and the following JSON being printed to stdout:
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
"cniVersion": "0.3.0",
|
"cniVersion": "0.2.0",
|
||||||
"code": <numeric-error-code>,
|
"code": <numeric-error-code>,
|
||||||
"msg": <short-error-message>,
|
"msg": <short-error-message>,
|
||||||
"details": <long-error-message> (optional)
|
"details": <long-error-message> (optional)
|
||||||
@ -157,7 +157,7 @@ Plugins may define additional fields that they accept and may generate an error
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"cniVersion": "0.3.0",
|
"cniVersion": "0.2.0",
|
||||||
"name": "dbnet",
|
"name": "dbnet",
|
||||||
"type": "bridge",
|
"type": "bridge",
|
||||||
// type (plugin) specific
|
// type (plugin) specific
|
||||||
@ -176,7 +176,7 @@ Plugins may define additional fields that they accept and may generate an error
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"cniVersion": "0.3.0",
|
"cniVersion": "0.2.0",
|
||||||
"name": "pci",
|
"name": "pci",
|
||||||
"type": "ovs",
|
"type": "ovs",
|
||||||
// type (plugin) specific
|
// type (plugin) specific
|
||||||
@ -226,7 +226,7 @@ Success is indicated by a zero return code and the following JSON being printed
|
|||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
"cniVersion": "0.3.0",
|
"cniVersion": "0.2.0",
|
||||||
"ip4": {
|
"ip4": {
|
||||||
"ip": <ipv4-and-subnet-in-CIDR>,
|
"ip": <ipv4-and-subnet-in-CIDR>,
|
||||||
"gateway": <ipv4-of-the-gateway>, (optional)
|
"gateway": <ipv4-of-the-gateway>, (optional)
|
||||||
|
@ -163,7 +163,7 @@ var _ = Describe("Invoking the plugin", func() {
|
|||||||
|
|
||||||
Expect(versionInfo).NotTo(BeNil())
|
Expect(versionInfo).NotTo(BeNil())
|
||||||
Expect(versionInfo.SupportedVersions()).To(Equal([]string{
|
Expect(versionInfo.SupportedVersions()).To(Equal([]string{
|
||||||
"0.-42.0", "0.1.0", "0.2.0", "0.3.0",
|
"0.-42.0", "0.1.0", "0.2.0",
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -52,15 +52,33 @@ var _ = Describe("GetVersion, integration tests", func() {
|
|||||||
|
|
||||||
Expect(versionInfo.SupportedVersions()).To(ConsistOf(expectedVersions.SupportedVersions()))
|
Expect(versionInfo.SupportedVersions()).To(ConsistOf(expectedVersions.SupportedVersions()))
|
||||||
},
|
},
|
||||||
Entry("old plugin, before VERSION was introduced", git_ref_v010, plugin_source_v010, version.PluginSupports("0.1.0")),
|
|
||||||
Entry("when VERSION was introduced", git_ref_v020, plugin_source_v010, version.PluginSupports("0.1.0", "0.2.0")),
|
Entry("historical: before VERSION was introduced",
|
||||||
Entry("when plugins report their own version support", git_ref_v030, plugin_source_v030, version.PluginSupports("0.3.0", "0.999.0")),
|
git_ref_v010, plugin_source_no_custom_versions,
|
||||||
Entry("HEAD", "HEAD", plugin_source_v030, version.PluginSupports("0.3.0", "0.999.0")),
|
version.PluginSupports("0.1.0"),
|
||||||
|
),
|
||||||
|
|
||||||
|
Entry("historical: when VERSION was introduced but plugins couldn't customize it",
|
||||||
|
git_ref_v020_no_custom_versions, plugin_source_no_custom_versions,
|
||||||
|
version.PluginSupports("0.1.0", "0.2.0"),
|
||||||
|
),
|
||||||
|
|
||||||
|
Entry("historical: when plugins started reporting their own version list",
|
||||||
|
git_ref_v020_custom_versions, plugin_source_v020_custom_versions,
|
||||||
|
version.PluginSupports("0.2.0", "0.999.0"),
|
||||||
|
),
|
||||||
|
|
||||||
|
// this entry tracks the current behavior. Before you change it, ensure
|
||||||
|
// that its previous behavior is captured in the most recent "historical" entry
|
||||||
|
Entry("current",
|
||||||
|
"HEAD", plugin_source_v020_custom_versions,
|
||||||
|
version.PluginSupports("0.2.0", "0.999.0"),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
// a 0.3.0 plugin that can report its own versions
|
// a 0.2.0 plugin that can report its own versions
|
||||||
const plugin_source_v030 = `package main
|
const plugin_source_v020_custom_versions = `package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/containernetworking/cni/pkg/skel"
|
"github.com/containernetworking/cni/pkg/skel"
|
||||||
@ -70,12 +88,12 @@ import (
|
|||||||
|
|
||||||
func c(_ *skel.CmdArgs) error { fmt.Println("{}"); return nil }
|
func c(_ *skel.CmdArgs) error { fmt.Println("{}"); return nil }
|
||||||
|
|
||||||
func main() { skel.PluginMain(c, c, version.PluginSupports("0.3.0", "0.999.0")) }
|
func main() { skel.PluginMain(c, c, version.PluginSupports("0.2.0", "0.999.0")) }
|
||||||
`
|
`
|
||||||
const git_ref_v030 = "bf31ed15"
|
const git_ref_v020_custom_versions = "bf31ed15"
|
||||||
|
|
||||||
// a minimal 0.1.0 / 0.2.0 plugin
|
// a minimal 0.1.0 / 0.2.0 plugin that cannot report it's own version support
|
||||||
const plugin_source_v010 = `package main
|
const plugin_source_no_custom_versions = `package main
|
||||||
|
|
||||||
import "github.com/containernetworking/cni/pkg/skel"
|
import "github.com/containernetworking/cni/pkg/skel"
|
||||||
import "fmt"
|
import "fmt"
|
||||||
@ -86,4 +104,4 @@ func main() { skel.PluginMain(c, c) }
|
|||||||
`
|
`
|
||||||
|
|
||||||
const git_ref_v010 = "2c482f4"
|
const git_ref_v010 = "2c482f4"
|
||||||
const git_ref_v020 = "349d66d"
|
const git_ref_v020_no_custom_versions = "349d66d"
|
||||||
|
@ -186,7 +186,7 @@ var _ = Describe("dispatching to the correct callback", func() {
|
|||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(stdout).To(MatchJSON(`{
|
Expect(stdout).To(MatchJSON(`{
|
||||||
"cniVersion": "0.3.0",
|
"cniVersion": "0.2.0",
|
||||||
"supportedVersions": ["9.8.7"]
|
"supportedVersions": ["9.8.7"]
|
||||||
}`))
|
}`))
|
||||||
})
|
})
|
||||||
|
@ -21,17 +21,21 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Decoding versions reported by a plugin", func() {
|
var _ = Describe("Decoding versions reported by a plugin", func() {
|
||||||
var decoder *version.PluginDecoder
|
var (
|
||||||
|
decoder *version.PluginDecoder
|
||||||
|
versionStdout []byte
|
||||||
|
)
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
decoder = &version.PluginDecoder{}
|
decoder = &version.PluginDecoder{}
|
||||||
|
versionStdout = []byte(`{
|
||||||
|
"cniVersion": "some-library-version",
|
||||||
|
"supportedVersions": [ "some-version", "some-other-version" ]
|
||||||
|
}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns a PluginInfo that represents the given json bytes", func() {
|
It("returns a PluginInfo that represents the given json bytes", func() {
|
||||||
pluginInfo, err := decoder.Decode([]byte(`{
|
pluginInfo, err := decoder.Decode(versionStdout)
|
||||||
"cniVersion": "some-library-version",
|
|
||||||
"supportedVersions": [ "some-version", "some-other-version" ]
|
|
||||||
}`))
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(pluginInfo).NotTo(BeNil())
|
Expect(pluginInfo).NotTo(BeNil())
|
||||||
Expect(pluginInfo.SupportedVersions()).To(Equal([]string{
|
Expect(pluginInfo.SupportedVersions()).To(Equal([]string{
|
||||||
@ -41,37 +45,40 @@ var _ = Describe("Decoding versions reported by a plugin", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Context("when the bytes cannot be decoded as json", func() {
|
Context("when the bytes cannot be decoded as json", func() {
|
||||||
|
BeforeEach(func() {
|
||||||
|
versionStdout = []byte(`{{{`)
|
||||||
|
})
|
||||||
|
|
||||||
It("returns a meaningful error", func() {
|
It("returns a meaningful error", func() {
|
||||||
_, err := decoder.Decode([]byte(`{{{`))
|
_, err := decoder.Decode(versionStdout)
|
||||||
Expect(err).To(MatchError("decoding version info: invalid character '{' looking for beginning of object key string"))
|
Expect(err).To(MatchError("decoding version info: invalid character '{' looking for beginning of object key string"))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Context("when the json bytes are missing the required CNIVersion field", func() {
|
Context("when the json bytes are missing the required CNIVersion field", func() {
|
||||||
|
BeforeEach(func() {
|
||||||
|
versionStdout = []byte(`{ "supportedVersions": [ "foo" ] }`)
|
||||||
|
})
|
||||||
|
|
||||||
It("returns a meaningful error", func() {
|
It("returns a meaningful error", func() {
|
||||||
_, err := decoder.Decode([]byte(`{ "supportedVersions": [ "foo" ] }`))
|
_, err := decoder.Decode(versionStdout)
|
||||||
Expect(err).To(MatchError("decoding version info: missing field cniVersion"))
|
Expect(err).To(MatchError("decoding version info: missing field cniVersion"))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Context("when there are no supported versions", func() {
|
Context("when there are no supported versions", func() {
|
||||||
Context("when the cniVersion is 0.2.0", func() {
|
BeforeEach(func() {
|
||||||
It("infers the supported versions are 0.1.0 and 0.2.0", func() {
|
versionStdout = []byte(`{ "cniVersion": "0.2.0" }`)
|
||||||
pluginInfo, err := decoder.Decode([]byte(`{ "cniVersion": "0.2.0" }`))
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
Expect(pluginInfo).NotTo(BeNil())
|
|
||||||
Expect(pluginInfo.SupportedVersions()).To(Equal([]string{
|
|
||||||
"0.1.0",
|
|
||||||
"0.2.0",
|
|
||||||
}))
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Context("when the cniVersion is >= 0.3.0", func() {
|
It("assumes that the supported versions are 0.1.0 and 0.2.0", func() {
|
||||||
It("returns a meaningful error", func() {
|
pluginInfo, err := decoder.Decode(versionStdout)
|
||||||
_, err := decoder.Decode([]byte(`{ "cniVersion": "0.3.0" }`))
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(err).To(MatchError("decoding version info: missing field supportedVersions"))
|
Expect(pluginInfo).NotTo(BeNil())
|
||||||
})
|
Expect(pluginInfo.SupportedVersions()).To(Equal([]string{
|
||||||
|
"0.1.0",
|
||||||
|
"0.2.0",
|
||||||
|
}))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ package version
|
|||||||
|
|
||||||
// Current reports the version of the CNI spec implemented by this library
|
// Current reports the version of the CNI spec implemented by this library
|
||||||
func Current() string {
|
func Current() string {
|
||||||
return "0.3.0"
|
return "0.2.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Legacy PluginInfo describes a plugin that is backwards compatible with the
|
// Legacy PluginInfo describes a plugin that is backwards compatible with the
|
||||||
@ -24,6 +24,6 @@ func Current() string {
|
|||||||
// library ought to work correctly with a plugin that reports support for
|
// library ought to work correctly with a plugin that reports support for
|
||||||
// Legacy versions.
|
// Legacy versions.
|
||||||
//
|
//
|
||||||
// Any future CNI spec versions which meet this definition will be added to
|
// Any future CNI spec versions which meet this definition should be added to
|
||||||
// this list.
|
// this list.
|
||||||
var Legacy = PluginSupports("0.1.0", "0.2.0", "0.3.0")
|
var Legacy = PluginSupports("0.1.0", "0.2.0")
|
||||||
|
@ -64,7 +64,7 @@ func debugBehavior(args *skel.CmdArgs, command string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func debugGetSupportedVersions() []string {
|
func debugGetSupportedVersions() []string {
|
||||||
vers := []string{"0.-42.0", "0.1.0", "0.2.0", "0.3.0"}
|
vers := []string{"0.-42.0", "0.1.0", "0.2.0"}
|
||||||
cniArgs := os.Getenv("CNI_ARGS")
|
cniArgs := os.Getenv("CNI_ARGS")
|
||||||
if cniArgs == "" {
|
if cniArgs == "" {
|
||||||
return vers
|
return vers
|
||||||
|
@ -131,7 +131,7 @@ var _ = Describe("No-op plugin", func() {
|
|||||||
Context("when the CNI_COMMAND is VERSION", func() {
|
Context("when the CNI_COMMAND is VERSION", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
cmd.Env[0] = "CNI_COMMAND=VERSION"
|
cmd.Env[0] = "CNI_COMMAND=VERSION"
|
||||||
debug.ReportVersionSupport = []string{"0.123.0", "0.3.0"}
|
debug.ReportVersionSupport = []string{"0.123.0", "0.2.0"}
|
||||||
|
|
||||||
Expect(debug.WriteDebug(debugFileName)).To(Succeed())
|
Expect(debug.WriteDebug(debugFileName)).To(Succeed())
|
||||||
})
|
})
|
||||||
@ -144,7 +144,7 @@ var _ = Describe("No-op plugin", func() {
|
|||||||
pluginInfo, err := decoder.Decode(session.Out.Contents())
|
pluginInfo, err := decoder.Decode(session.Out.Contents())
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(pluginInfo.SupportedVersions()).To(ConsistOf(
|
Expect(pluginInfo.SupportedVersions()).To(ConsistOf(
|
||||||
"0.123.0", "0.3.0"))
|
"0.123.0", "0.2.0"))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user