diff --git a/go.mod b/go.mod index e95b845a2..96f431801 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/sergi/go-diff v1.1.0 // indirect github.com/spf13/cobra v1.1.1 - go.bytebuilders.dev/license-verifier/kubernetes v0.8.0 + go.bytebuilders.dev/license-verifier/kubernetes v0.8.1 gomodules.xyz/pointer v0.0.0-20201105071923-daf60fa55209 gomodules.xyz/x v0.0.0-20201105065653-91c568df6331 k8s.io/api v0.18.9 diff --git a/go.sum b/go.sum index 6c7b98a38..5f82efeb3 100644 --- a/go.sum +++ b/go.sum @@ -775,10 +775,10 @@ github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3Ifn github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= github.com/yudai/pp v2.0.1+incompatible h1:Q4//iY4pNF6yPLZIigmvcl7k/bPgrcTPIFIcmawg5bI= github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= -go.bytebuilders.dev/license-verifier v0.8.0 h1:lLnz+v65UuHcpMuWRiINDOI+HmwETNehtjm44+dauMo= -go.bytebuilders.dev/license-verifier v0.8.0/go.mod h1:N7fJxdaBJQ9seOGFg+trJQ3eWwy/ga6YZi0wlvdDQi0= -go.bytebuilders.dev/license-verifier/kubernetes v0.8.0 h1:RyXeFcib/Mr6dwyeSCkvpX8u+696CWXnH3FYXCEYdxs= -go.bytebuilders.dev/license-verifier/kubernetes v0.8.0/go.mod h1:xyLTXiI5SEefYKQSNq/ozFpJChwb2Xp+8x4SMJ9180Q= +go.bytebuilders.dev/license-verifier v0.8.1 h1:/n0QGsmVN7BZq7tTellz+NeqcnjOKEwohIKBXECOe2U= +go.bytebuilders.dev/license-verifier v0.8.1/go.mod h1:N7fJxdaBJQ9seOGFg+trJQ3eWwy/ga6YZi0wlvdDQi0= +go.bytebuilders.dev/license-verifier/kubernetes v0.8.1 h1:IVvPi7bhiSBmhJww7FDJzDyVMIw33rq19u8KQEm1Rew= +go.bytebuilders.dev/license-verifier/kubernetes v0.8.1/go.mod h1:WdnkwLs4wb5v0jjQEnhYLTPE90NfdVG6J1ePnT8N4yA= go.elastic.co/apm v1.5.0/go.mod h1:OdB9sPtM6Vt7oz3VXt7+KR96i9li74qrxBGHTQygFvk= go.elastic.co/apm/module/apmhttp v1.5.0/go.mod h1:1FbmNuyD3ddauwzgVwFB0fqY6KbZt3JkV187tGCYYhY= go.elastic.co/apm/module/apmot v1.5.0/go.mod h1:d2KYwhJParTpyw2WnTNy8geNlHKKFX+4oK3YLlsesWE= diff --git a/vendor/go.bytebuilders.dev/license-verifier/kubernetes/go.mod b/vendor/go.bytebuilders.dev/license-verifier/kubernetes/go.mod index f180726d5..32f7074d6 100644 --- a/vendor/go.bytebuilders.dev/license-verifier/kubernetes/go.mod +++ b/vendor/go.bytebuilders.dev/license-verifier/kubernetes/go.mod @@ -4,7 +4,7 @@ go 1.14 require ( github.com/gogo/protobuf v1.3.1 - go.bytebuilders.dev/license-verifier v0.8.0 + go.bytebuilders.dev/license-verifier v0.8.1 k8s.io/api v0.18.9 k8s.io/apimachinery v0.18.9 k8s.io/apiserver v0.18.9 diff --git a/vendor/go.bytebuilders.dev/license-verifier/kubernetes/lib.go b/vendor/go.bytebuilders.dev/license-verifier/kubernetes/lib.go index 8c060814a..5db6b4f80 100644 --- a/vendor/go.bytebuilders.dev/license-verifier/kubernetes/lib.go +++ b/vendor/go.bytebuilders.dev/license-verifier/kubernetes/lib.go @@ -230,15 +230,23 @@ func VerifyLicensePeriodically(config *rest.Config, licenseFile string, stopCh < Features: info.ProductName, }, } + + if err := verifyLicensePeriodically(le, licenseFile, stopCh); err != nil { + return le.handleLicenseVerificationFailure(err) + } + return nil +} + +func verifyLicensePeriodically(le *LicenseEnforcer, licenseFile string, stopCh <-chan struct{}) error { // Create Kubernetes client err := le.createClients() if err != nil { - return le.handleLicenseVerificationFailure(err) + return err } // Read cluster UID (UID of the "kube-system" namespace) err = le.readClusterUID() if err != nil { - return le.handleLicenseVerificationFailure(err) + return err } // Periodically verify license with 1 hour interval @@ -247,12 +255,12 @@ func VerifyLicensePeriodically(config *rest.Config, licenseFile string, stopCh < // Read license from file err = le.readLicenseFromFile() if err != nil { - return false, le.handleLicenseVerificationFailure(err) + return false, err } // Validate license _, err = verifier.VerifyLicense(le.opts) if err != nil { - return false, le.handleLicenseVerificationFailure(err) + return false, err } klog.Infoln("Successfully verified license!") // return false so that the loop never ends @@ -281,25 +289,33 @@ func CheckLicenseFile(config *rest.Config, licenseFile string) error { Features: info.ProductName, }, } + + if err := checkLicenseFile(le); err != nil { + return le.handleLicenseVerificationFailure(err) + } + return nil +} + +func checkLicenseFile(le *LicenseEnforcer) error { // Create Kubernetes client err := le.createClients() if err != nil { - return le.handleLicenseVerificationFailure(err) + return err } // Read cluster UID (UID of the "kube-system" namespace) err = le.readClusterUID() if err != nil { - return le.handleLicenseVerificationFailure(err) + return err } // Read license from file err = le.readLicenseFromFile() if err != nil { - return le.handleLicenseVerificationFailure(err) + return err } // Validate license _, err = verifier.VerifyLicense(le.opts) if err != nil { - return le.handleLicenseVerificationFailure(err) + return err } klog.Infoln("Successfully verified license!") return nil diff --git a/vendor/modules.txt b/vendor/modules.txt index 6ddb1a3b8..4d611dc68 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -131,12 +131,12 @@ github.com/yudai/gojsondiff github.com/yudai/gojsondiff/formatter # github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 github.com/yudai/golcs -# go.bytebuilders.dev/license-verifier v0.8.0 +# go.bytebuilders.dev/license-verifier v0.8.1 go.bytebuilders.dev/license-verifier go.bytebuilders.dev/license-verifier/apis/licenses go.bytebuilders.dev/license-verifier/apis/licenses/v1alpha1 go.bytebuilders.dev/license-verifier/info -# go.bytebuilders.dev/license-verifier/kubernetes v0.8.0 +# go.bytebuilders.dev/license-verifier/kubernetes v0.8.1 go.bytebuilders.dev/license-verifier/kubernetes # golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 golang.org/x/crypto/ssh/terminal