#328 Code review fixes

This commit is contained in:
Mikolaj Karebski 2020-04-24 13:33:02 +02:00
parent fd1b5f2bd9
commit 85237e2da7
2 changed files with 4 additions and 3 deletions

View File

@ -13,6 +13,8 @@ import (
k8s "sigs.k8s.io/controller-runtime/pkg/client"
)
const groovyUtf8MaxStringLength = 65535
// ConfigurationAsCode defines API which configures Jenkins with help Configuration as a code plugin
type ConfigurationAsCode struct {
groovyClient *groovy.Groovy
@ -53,7 +55,6 @@ io.jenkins.plugins.casc.ConfigurationAsCode.get().configureWith(source)
`
func prepareScript(script string) string {
groovyUtf8MaxStringLength := 65535
var slicedScript []string
if len(script) > groovyUtf8MaxStringLength {
slicedScript = splitTooLongScript(script)
@ -65,7 +66,6 @@ func prepareScript(script string) string {
}
func splitTooLongScript(groovyScript string) []string {
groovyUtf8MaxStringLength := 65535
var slicedGroovyScript []string
lastSubstrIndex := len(groovyScript) % groovyUtf8MaxStringLength

View File

@ -1,9 +1,10 @@
package casc
import (
"github.com/stretchr/testify/assert"
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestSplitToLongScript(t *testing.T) {