Merge branch 'master' into fix-plugin-version

This commit is contained in:
Jakub Al-Khalili
2019-10-09 13:00:39 +02:00
committed by GitHub
32 changed files with 701 additions and 547 deletions
@@ -1,14 +1,14 @@
package plugins
const (
configurationAsCodePlugin = "configuration-as-code:1.29"
configurationAsCodePlugin = "configuration-as-code:1.32"
configurationAsCodeSupportPlugin = "configuration-as-code-support:1.19"
gitPlugin = "git:3.12.0"
gitPlugin = "git:3.12.1"
jobDslPlugin = "job-dsl:1.76"
kubernetesCredentialsProviderPlugin = "kubernetes-credentials-provider:0.12.1"
kubernetesPlugin = "kubernetes:1.18.3"
kubernetesPlugin = "kubernetes:1.19.3"
workflowAggregatorPlugin = "workflow-aggregator:2.6"
workflowJobPlugin = "workflow-job:2.34"
workflowJobPlugin = "workflow-job:2.35"
)
// basePluginsList contains plugins to install by operator
+4 -7
View File
@@ -5,8 +5,6 @@ import (
"regexp"
"strings"
"github.com/jenkinsci/kubernetes-operator/pkg/log"
"github.com/pkg/errors"
)
@@ -77,10 +75,10 @@ func Must(plugin *Plugin, err error) Plugin {
}
// VerifyDependencies checks if all plugins have compatible versions
func VerifyDependencies(values ...map[Plugin][]Plugin) bool {
func VerifyDependencies(values ...map[Plugin][]Plugin) []string {
var messages []string
// key - plugin name, value array of versions
allPlugins := make(map[string][]Plugin)
valid := true
for _, value := range values {
for rootPlugin, plugins := range value {
@@ -105,18 +103,17 @@ func VerifyDependencies(values ...map[Plugin][]Plugin) bool {
for _, firstVersion := range versions {
for _, secondVersion := range versions {
if firstVersion.Version != secondVersion.Version {
log.Log.V(log.VWarn).Info(fmt.Sprintf("Plugin '%s' requires version '%s' but plugin '%s' requires '%s' for plugin '%s'",
messages = append(messages, fmt.Sprintf("Plugin '%s' requires version '%s' but plugin '%s' requires '%s' for plugin '%s'",
firstVersion.rootPluginNameAndVersion,
firstVersion.Version,
secondVersion.rootPluginNameAndVersion,
secondVersion.Version,
pluginName,
))
valid = false
}
}
}
}
return valid
return messages
}
+15 -8
View File
@@ -18,7 +18,7 @@ func TestVerifyDependencies(t *testing.T) {
},
}
got := VerifyDependencies(basePlugins)
assert.Equal(t, true, got)
assert.Nil(t, got)
})
t.Run("happy, two root plugins with one depended plugin with the same version", func(t *testing.T) {
basePlugins := map[Plugin][]Plugin{
@@ -30,7 +30,7 @@ func TestVerifyDependencies(t *testing.T) {
},
}
got := VerifyDependencies(basePlugins)
assert.Equal(t, true, got)
assert.Nil(t, got)
})
t.Run("happy, two plugin names with names with underscores", func(t *testing.T) {
basePlugins := map[Plugin][]Plugin{
@@ -42,7 +42,7 @@ func TestVerifyDependencies(t *testing.T) {
},
}
got := VerifyDependencies(basePlugins)
assert.Equal(t, true, got)
assert.Nil(t, got)
})
t.Run("happy, two plugin names with uppercase names", func(t *testing.T) {
basePlugins := map[Plugin][]Plugin{
@@ -54,7 +54,7 @@ func TestVerifyDependencies(t *testing.T) {
},
}
got := VerifyDependencies(basePlugins)
assert.Equal(t, true, got)
assert.Nil(t, got)
})
t.Run("fail, two root plugins have different versions", func(t *testing.T) {
basePlugins := map[Plugin][]Plugin{
@@ -66,7 +66,8 @@ func TestVerifyDependencies(t *testing.T) {
},
}
got := VerifyDependencies(basePlugins)
assert.Equal(t, false, got)
assert.Contains(t, got, "Plugin 'first-root-plugin:1.0.0' requires version '1.0.0' but plugin 'first-root-plugin:2.0.0' requires '2.0.0' for plugin 'first-root-plugin'")
assert.Contains(t, got, "Plugin 'first-root-plugin:2.0.0' requires version '2.0.0' but plugin 'first-root-plugin:1.0.0' requires '1.0.0' for plugin 'first-root-plugin'")
})
t.Run("happy, no version collision with two sperate plugins lists", func(t *testing.T) {
basePlugins := map[Plugin][]Plugin{
@@ -80,7 +81,7 @@ func TestVerifyDependencies(t *testing.T) {
},
}
got := VerifyDependencies(basePlugins, extraPlugins)
assert.Equal(t, true, got)
assert.Nil(t, got)
})
t.Run("fail, dependent plugins have different versions", func(t *testing.T) {
basePlugins := map[Plugin][]Plugin{
@@ -92,7 +93,10 @@ func TestVerifyDependencies(t *testing.T) {
},
}
got := VerifyDependencies(basePlugins)
assert.Equal(t, false, got)
assert.Contains(t, got, "Plugin 'first-root-plugin:1.0.0' requires version '1.0.0' but plugin 'first-root-plugin:2.0.0' requires '2.0.0' for plugin 'first-root-plugin'")
assert.Contains(t, got, "Plugin 'first-root-plugin:2.0.0' requires version '2.0.0' but plugin 'first-root-plugin:1.0.0' requires '1.0.0' for plugin 'first-root-plugin'")
assert.Contains(t, got, "Plugin 'first-root-plugin:1.0.0' requires version '0.0.1' but plugin 'first-root-plugin:2.0.0' requires '0.0.2' for plugin 'first-plugin'")
assert.Contains(t, got, "Plugin 'first-root-plugin:2.0.0' requires version '0.0.2' but plugin 'first-root-plugin:1.0.0' requires '0.0.1' for plugin 'first-plugin'")
})
t.Run("fail, root and dependent plugins have different versions", func(t *testing.T) {
basePlugins := map[Plugin][]Plugin{
@@ -106,7 +110,10 @@ func TestVerifyDependencies(t *testing.T) {
},
}
got := VerifyDependencies(basePlugins, extraPlugins)
assert.Equal(t, false, got)
assert.Contains(t, got, "Plugin 'first-root-plugin:1.0.0' requires version '1.0.0' but plugin 'first-root-plugin:2.0.0' requires '2.0.0' for plugin 'first-root-plugin'")
assert.Contains(t, got, "Plugin 'first-root-plugin:2.0.0' requires version '2.0.0' but plugin 'first-root-plugin:1.0.0' requires '1.0.0' for plugin 'first-root-plugin'")
assert.Contains(t, got, "Plugin 'first-root-plugin:1.0.0' requires version '0.0.1' but plugin 'first-root-plugin:2.0.0' requires '0.0.2' for plugin 'first-plugin'")
assert.Contains(t, got, "Plugin 'first-root-plugin:2.0.0' requires version '0.0.2' but plugin 'first-root-plugin:1.0.0' requires '0.0.1' for plugin 'first-plugin'")
})
t.Run("happy with dash in version", func(t *testing.T) {
basePlugins := map[Plugin][]Plugin{