Skip to content

Commit

Permalink
jenkinsci#328 Code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikolaj Karebski authored and akram committed May 6, 2020
1 parent caf3543 commit 2ce6df8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/controller/jenkins/configuration/user/casc/caac.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -65,7 +66,6 @@ func prepareScript(script string) string {
}

func splitTooLongScript(groovyScript string) []string {
groovyUtf8MaxStringLength := 65535
var slicedGroovyScript []string

lastSubstrIndex := len(groovyScript) % groovyUtf8MaxStringLength
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/jenkins/configuration/user/casc/caas_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package casc

import (
"github.com/stretchr/testify/assert"
"strings"
"testing"

"github.com/stretchr/testify/assert"
)

func TestSplitToLongScript(t *testing.T) {
Expand Down

0 comments on commit 2ce6df8

Please sign in to comment.