Receive plugins' versions with underscores. (#699)
* Receive plugins versions with underscores. New jenkins plugin versions have underscores in them (example: https://plugins.jenkins.io/credentials/). The operator refuses configuration for such plug-ins as they do not match the existing regex. * Add tests to underscores in plugin versions Adds a new test to check that versions with underscores are valid. * Synchronise regexps character order to avoid range Make two related regexps more evidently similar to each other and re-order the symbols so that the - is not interpreted.
This commit is contained in:
parent
0f507409cc
commit
424ec3fbc2
|
|
@ -22,9 +22,9 @@ func (p Plugin) String() string {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// NamePattern is the plugin name regex pattern
|
// NamePattern is the plugin name regex pattern
|
||||||
NamePattern = regexp.MustCompile(`^[0-9a-zA-Z-_]+$`)
|
NamePattern = regexp.MustCompile(`^[0-9a-zA-Z\-_]+$`)
|
||||||
// VersionPattern is the plugin version regex pattern
|
// VersionPattern is the plugin version regex pattern
|
||||||
VersionPattern = regexp.MustCompile(`^[0-9a-zA-Z+\\.-]+$`)
|
VersionPattern = regexp.MustCompile(`^[0-9a-zA-Z\-_+\\.]+$`)
|
||||||
// DownloadURLPattern is the plugin download url regex pattern
|
// DownloadURLPattern is the plugin download url regex pattern
|
||||||
DownloadURLPattern = regexp.MustCompile(`https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)`)
|
DownloadURLPattern = regexp.MustCompile(`https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)`)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,10 @@ func TestValidatePlugin(t *testing.T) {
|
||||||
got := validatePlugin(validPluginName, "3.1.20180605-140134.c2e96c4", "")
|
got := validatePlugin(validPluginName, "3.1.20180605-140134.c2e96c4", "")
|
||||||
assert.NoError(t, got)
|
assert.NoError(t, got)
|
||||||
})
|
})
|
||||||
|
t.Run("version 1074.v60e6c29b_b_44b_", func(t *testing.T) {
|
||||||
|
got := validatePlugin(validPluginName, "1074.v60e6c29b_b_44b_", "")
|
||||||
|
assert.NoError(t, got)
|
||||||
|
})
|
||||||
t.Run("invalid version !", func(t *testing.T) {
|
t.Run("invalid version !", func(t *testing.T) {
|
||||||
got := validatePlugin(validPluginName, "0.5.1!", "")
|
got := validatePlugin(validPluginName, "0.5.1!", "")
|
||||||
assert.Error(t, got)
|
assert.Error(t, got)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue