diff --git a/Jenkinsfile b/Jenkinsfile index 90a710e..c8e4504 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,8 +9,9 @@ podTemplate(label: 'k8svault-controller', ttyEnabled: true ), containerTemplate( - name: 'docker', - image: 'docker:latest', + name: 'kaniko', + command: '/busybox/cat', + image: 'gcr.io/kaniko-project/executor:debug', ttyEnabled: true ), containerTemplate( @@ -21,17 +22,13 @@ podTemplate(label: 'k8svault-controller', ), ], volumes: [ - hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'), + secretVolume(secretName: 'dockerauth', mountPath: '/root/dockerauth') ] ) { node ('k8svault-controller') { ansiColor("xterm") { stage('checkout') { checkout(scm) - - container('docker') { - dockerAuth() - } } stage("build") { @@ -56,9 +53,9 @@ podTemplate(label: 'k8svault-controller', version = "$major.$minor.$patch$group" - container('docker') { - sh "docker build . -t nexus.doodle.com:5000/devops/k8svault-controller:${env.TAG_NAME}" - sh "docker push nexus.doodle.com:5000/devops/k8svault-controller:${env.TAG_NAME}" + container(name: 'kaniko', shell: '/busybox/sh') { + sh "cp /root/dockerauth/.dockerconfigjson /kaniko/.docker/config.json" + sh "/kaniko/executor -f `pwd`/Dockerfile -c `pwd` --destination='nexus.doodle.com:5000/devops/k8svault-controller:${env.TAG_NAME}'" } container('helm') { @@ -69,7 +66,6 @@ podTemplate(label: 'k8svault-controller', sh "mkdir chart/k8svault-controller/crds" sh "cp config/crd/bases/* chart/k8svault-controller/crds" sh "helm package chart/k8svault-controller" - } container('golang') { @@ -86,28 +82,6 @@ podTemplate(label: 'k8svault-controller', } } -void dockerAuth() { - // nexus repository - withCredentials([[ - $class : 'UsernamePasswordMultiBinding', - credentialsId : 'nexus', - usernameVariable: 'NEXUS_USER', - passwordVariable: 'NEXUS_PASSWORD' - ]]) { - sh "docker login nexus.doodle.com:5000 -u ${env.NEXUS_USER} -p ${env.NEXUS_PASSWORD}" - } - - // docker hub - withCredentials([[ - $class : 'UsernamePasswordMultiBinding', - credentialsId : 'dockerhub', - usernameVariable: 'DOCKERHUB_USER', - passwordVariable: 'DOCKERHUB_PASSWORD' - ]]) { - sh "docker login -u ${env.DOCKERHUB_USER} -p ${env.DOCKERHUB_PASSWORD}" - } -} - def bumpImageVersion(String version) { echo "Update image tag" def valuesFile = "./chart/k8svault-controller/values.yaml" diff --git a/go.mod b/go.mod index deca8a3..f8802f4 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,9 @@ module github.com/DoodleScheduling/k8svault-controller go 1.15 require ( + 4d63.com/gochecknoglobals v0.0.0-20201008074935-acfc0b28355a // indirect + 4d63.com/gochecknoinits v0.0.0-20200108094044-eb73b47b9fc4 // indirect + github.com/alecthomas/gocyclo v0.0.0-20150208221726-aa8f8b160214 // indirect github.com/alexkohler/nakedret v1.0.0 // indirect github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6 // indirect github.com/coreos/go-etcd v2.0.0+incompatible // indirect @@ -16,6 +19,8 @@ require ( github.com/hashicorp/vault/sdk v0.1.14-0.20200519221838-e0cfd64bc267 github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect github.com/jgautheron/goconst v0.0.0-20201117150253-ccae5bf973f3 // indirect + github.com/mdempsky/maligned v0.0.0-20210215075342-f0178ee82032 // indirect + github.com/mdempsky/unconvert v0.0.0-20200228143138-95ecdbfc0b5f // indirect github.com/mibk/dupl v1.0.0 // indirect github.com/onsi/ginkgo v1.14.1 github.com/onsi/gomega v1.10.2 @@ -24,6 +29,7 @@ require ( github.com/securego/gosec v0.0.0-20200401082031-e946c8c39989 // indirect github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.7.0 + github.com/stripe/safesql v0.2.0 // indirect github.com/tsenart/deadcode v0.0.0-20160724212837-210d2dc333e9 // indirect github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8 // indirect github.com/walle/lll v1.0.1 // indirect @@ -34,5 +40,8 @@ require ( k8s.io/apimachinery v0.20.2 k8s.io/cli-runtime v0.20.2 k8s.io/client-go v0.20.2 + mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed // indirect + mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect + mvdan.cc/unparam v0.0.0-20210104141923-aac4ce9116a7 // indirect sigs.k8s.io/controller-runtime v0.8.0 ) diff --git a/go.sum b/go.sum index 739acb6..085984b 100644 --- a/go.sum +++ b/go.sum @@ -786,6 +786,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182aff github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/mdempsky/maligned v0.0.0-20201101000000-d73c43cb16d0 h1:+6XJvFZBYbNv/nSekNWFZyaGNMXcPnZ4n/HHoCXn+Ms= github.com/mdempsky/maligned v0.0.0-20201101000000-d73c43cb16d0/go.mod h1:3UB4iTzhLciyWcrrvXSkrtCIU+IJ5GCfEmnleHRsxL4= +github.com/mdempsky/maligned v0.0.0-20210215075342-f0178ee82032 h1:3A6SZn0ThJmhm66wGfgvarlntuWbQQ8Qt0MGim6flzo= +github.com/mdempsky/maligned v0.0.0-20210215075342-f0178ee82032/go.mod h1:3UB4iTzhLciyWcrrvXSkrtCIU+IJ5GCfEmnleHRsxL4= github.com/mdempsky/unconvert v0.0.0-20200228143138-95ecdbfc0b5f h1:Kc3s6QFyh9DLgInXpWKuG+8I7R7lXbnP7mcoOVIt6KY= github.com/mdempsky/unconvert v0.0.0-20200228143138-95ecdbfc0b5f/go.mod h1:AmCV4WB3cDMZqgPk+OUQKumliiQS4ZYsBt3AXekyuAU= github.com/mholt/archiver v3.1.1+incompatible/go.mod h1:Dh2dOXnSdiLxRiPoVfIr/fI1TwETms9B8CTWfeh7ROU=