#328 Code review fixes
This commit is contained in:
		
							parent
							
								
									fd1b5f2bd9
								
							
						
					
					
						commit
						85237e2da7
					
				|  | @ -13,6 +13,8 @@ import ( | ||||||
| 	k8s "sigs.k8s.io/controller-runtime/pkg/client" | 	k8s "sigs.k8s.io/controller-runtime/pkg/client" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | const groovyUtf8MaxStringLength = 65535 | ||||||
|  | 
 | ||||||
| // ConfigurationAsCode defines API which configures Jenkins with help Configuration as a code plugin
 | // ConfigurationAsCode defines API which configures Jenkins with help Configuration as a code plugin
 | ||||||
| type ConfigurationAsCode struct { | type ConfigurationAsCode struct { | ||||||
| 	groovyClient *groovy.Groovy | 	groovyClient *groovy.Groovy | ||||||
|  | @ -53,7 +55,6 @@ io.jenkins.plugins.casc.ConfigurationAsCode.get().configureWith(source) | ||||||
| ` | ` | ||||||
| 
 | 
 | ||||||
| func prepareScript(script string) string { | func prepareScript(script string) string { | ||||||
| 	groovyUtf8MaxStringLength := 65535 |  | ||||||
| 	var slicedScript []string | 	var slicedScript []string | ||||||
| 	if len(script) > groovyUtf8MaxStringLength { | 	if len(script) > groovyUtf8MaxStringLength { | ||||||
| 		slicedScript = splitTooLongScript(script) | 		slicedScript = splitTooLongScript(script) | ||||||
|  | @ -65,7 +66,6 @@ func prepareScript(script string) string { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func splitTooLongScript(groovyScript string) []string { | func splitTooLongScript(groovyScript string) []string { | ||||||
| 	groovyUtf8MaxStringLength := 65535 |  | ||||||
| 	var slicedGroovyScript []string | 	var slicedGroovyScript []string | ||||||
| 
 | 
 | ||||||
| 	lastSubstrIndex := len(groovyScript) % groovyUtf8MaxStringLength | 	lastSubstrIndex := len(groovyScript) % groovyUtf8MaxStringLength | ||||||
|  |  | ||||||
|  | @ -1,9 +1,10 @@ | ||||||
| package casc | package casc | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"github.com/stretchr/testify/assert" |  | ||||||
| 	"strings" | 	"strings" | ||||||
| 	"testing" | 	"testing" | ||||||
|  | 
 | ||||||
|  | 	"github.com/stretchr/testify/assert" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func TestSplitToLongScript(t *testing.T) { | func TestSplitToLongScript(t *testing.T) { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue