Exemplo n.º 1
0
// GetVersionInfo reports which versions of the CNI spec are supported by
// the given plugin.
func (c *CNIConfig) GetVersionInfo(pluginType string) (version.PluginInfo, error) {
	pluginPath, err := invoke.FindInPath(pluginType, c.Path)
	if err != nil {
		return nil, err
	}

	return invoke.GetVersionInfo(pluginPath)
}
	)

	BeforeEach(func() {
		pluginDir, err := ioutil.TempDir("", "plugins")
		Expect(err).NotTo(HaveOccurred())
		pluginPath = filepath.Join(pluginDir, "test-plugin")
	})

	AfterEach(func() {
		Expect(os.RemoveAll(pluginDir)).To(Succeed())
	})

	DescribeTable("correctly reporting plugin versions",
		func(gitRef string, pluginSource string, expectedVersions version.PluginInfo) {
			Expect(testhelpers.BuildAt([]byte(pluginSource), gitRef, pluginPath)).To(Succeed())
			versionInfo, err := invoke.GetVersionInfo(pluginPath)
			Expect(err).NotTo(HaveOccurred())

			Expect(versionInfo.SupportedVersions()).To(ConsistOf(expectedVersions.SupportedVersions()))
		},

		Entry("historical: before VERSION was introduced",
			git_ref_v010, plugin_source_no_custom_versions,
			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"),
		),