Skip to content

Commit 868a674

Browse files
authored
Merge pull request #118 from piyush-garg/iss_117
Refactor Util functions
2 parents 7222ebf + 2b783ee commit 868a674

File tree

7 files changed

+16
-17
lines changed

7 files changed

+16
-17
lines changed

src/io/openshift/plugins/analytics.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.openshift.plugins
22

33
import io.openshift.Events
4-
import io.openshift.Utils
4+
import static io.openshift.Utils.addAnnotationToBuild
55

66
def register() {
77
Events.on("build.pass") {
@@ -14,7 +14,7 @@ def register() {
1414
retry(3) {
1515
def response = bayesianAnalysis(url: 'https://bayesian-link', gitUrl: a[0].git.url, ecosystem: image)
1616
if (response.success) {
17-
Utils.addAnnotationToBuild(this, 'fabric8.io/bayesian.analysisUrl', response.getAnalysisUrl())
17+
addAnnotationToBuild(this, 'fabric8.io/bayesian.analysisUrl', response.getAnalysisUrl())
1818
} else {
1919
echo "Bayesian analysis failed ${response}"
2020
}

vars/loadResources.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import io.openshift.Utils
1+
import static io.openshift.Utils.shWithOutput
22

33
def call(Map args = [:]) {
44
def file = args.file
@@ -17,7 +17,7 @@ def call(Map args = [:]) {
1717

1818
def validate = args.validate == false ? false : true
1919
if (validate) {
20-
Utils.shWithOutput(this, "oc apply --dry-run=true --validate=true -f $args.file");
20+
shWithOutput(this, "oc apply --dry-run=true --validate=true -f $args.file");
2121
}
2222

2323
// resources can be:

vars/pod.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import io.openshift.Utils
1+
import static io.openshift.Utils.buildID
22

33
def call(Map args = [:], body = null) {
4-
def label = Utils.buildID(env.JOB_NAME, env.BUILD_NUMBER, prefix=args.name)
4+
def label = buildID(env.JOB_NAME, env.BUILD_NUMBER, prefix=args.name)
55
def envVars = processEnvVars(args.envVars)
66

77
podTemplate(

vars/processTemplate.groovy

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import io.openshift.Utils
1+
import static io.openshift.Utils.shWithOutput
22

33
def call(args=[:]) {
44
def file = args.file ?: ".openshiftio/application.yaml"
@@ -19,7 +19,7 @@ def call(args=[:]) {
1919
def params = applyDefaults(args.params, paramNames)
2020

2121
def ocParams = params.collect { k,v -> "$k=$v"}.join(' ')
22-
def processed = Utils.shWithOutput(this, "oc process -f $file $ocParams -o yaml")
22+
def processed = shWithOutput(this, "oc process -f $file $ocParams -o yaml")
2323

2424
def kind = { r -> r.kind }
2525
def resources = readYaml(text: processed).items.groupBy(kind)
@@ -44,9 +44,9 @@ def applyDefaults(provided=[:], templateParams) {
4444
}
4545

4646
setParam('SUFFIX_NAME') { "-${env.BRANCH_NAME}".toLowerCase() }
47-
setParam('SOURCE_REPOSITORY_REF') { Utils.shWithOutput(this, "git rev-parse --short HEAD") }
48-
setParam('SOURCE_REPOSITORY_URL') { Utils.shWithOutput(this, "git config remote.origin.url") }
49-
setParam('RELEASE_VERSION') { Utils.shWithOutput(this, "git rev-list --count HEAD") }
47+
setParam('SOURCE_REPOSITORY_REF') { shWithOutput(this, "git rev-parse --short HEAD") }
48+
setParam('SOURCE_REPOSITORY_URL') { shWithOutput(this, "git config remote.origin.url") }
49+
setParam('RELEASE_VERSION') { shWithOutput(this, "git rev-list --count HEAD") }
5050
return params
5151
}
5252

vars/runTest.groovy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
def call(Map args) {
32
stage("Run Tests") {
43
if (!args.commands) {
@@ -10,4 +9,4 @@ def call(Map args) {
109
}
1110
spawn(image: image, version: config.version(), commands: args.commands)
1211
}
13-
}
12+
}

vars/spawn.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import io.openshift.Utils;
1+
import static io.openshift.Utils.mergeResources
22

33
def call(Map args = [:], body = null){
44
if (args.commands == null && body == null) {
@@ -44,7 +44,7 @@ def mergeEnvs(args, spec){
4444
def apiEnvVars = args.envVar ?: []
4545
// read environment variable from spec
4646
def specEnvVars = spec.envVar ?: []
47-
return Utils.mergeResources(apiEnvVars + specEnvVars)
47+
return mergeResources(apiEnvVars + specEnvVars)
4848
}
4949

5050
def specForImage(image, version){

vars/testNamespace.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import io.openshift.Utils;
1+
import static io.openshift.Utils.usersNamespace
22

33
def call() {
4-
return Utils.usersNamespace()
4+
return usersNamespace()
55
}

0 commit comments

Comments
 (0)