diff options
author | Jan Malkiewicz <jan.malkiewicz@nokia.com> | 2020-10-15 09:04:18 +0200 |
---|---|---|
committer | Jan Malkiewicz <jan.malkiewicz@nokia.com> | 2020-10-15 16:01:53 +0200 |
commit | f5fb53b031c2f1c4bc4872de59b9774a559d786f (patch) | |
tree | 2345c86aeaedfef576b513c3b325ce303c1261c7 /certServiceK8sExternalProvider/main.go | |
parent | 720466562b0ea1e67ff36f44e0d95645837316d4 (diff) |
[OOM-K8S-CERT-EXTERNAL-PROVIDER] Mock implementaion enhanced (part II)
Rename CertServiceIssuer -> CMPv2Issuer
Checking for Issuer.Kind (has to be CMPv2Issuer)
Introduced exit codes
Refactoring file names and packages
Moved tests to main package (according to GOlang convention)
Issue-ID: OOM-2559
Signed-off-by: Jan Malkiewicz <jan.malkiewicz@nokia.com>
Change-Id: I710d9f6c9bd22318e5152e5215b78d5a9e7b4540
Diffstat (limited to 'certServiceK8sExternalProvider/main.go')
-rw-r--r-- | certServiceK8sExternalProvider/main.go | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/certServiceK8sExternalProvider/main.go b/certServiceK8sExternalProvider/main.go index 52c8280c..2fcbfaaf 100644 --- a/certServiceK8sExternalProvider/main.go +++ b/certServiceK8sExternalProvider/main.go @@ -33,8 +33,9 @@ import ( clientgoscheme "k8s.io/client-go/kubernetes/scheme" _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" "k8s.io/utils/clock" - certserviceapi "onap.org/oom-certservice/k8s-external-provider/src/api" - controllers "onap.org/oom-certservice/k8s-external-provider/src/certservice-controller" + app "onap.org/oom-certservice/k8s-external-provider/src" + certserviceapi "onap.org/oom-certservice/k8s-external-provider/src/cmpv2api" + controllers "onap.org/oom-certservice/k8s-external-provider/src/cmpv2controller" "os" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/log/zap" @@ -53,7 +54,7 @@ func init() { func main() { fmt.Println() - fmt.Println(" *** Cert Service Provider v1.0.1 ***") + fmt.Println(" *** Cert Service Provider v1.0.2 ***") fmt.Println() setupLog.Info("Parsing arguments...") @@ -73,36 +74,37 @@ func main() { LeaderElection: enableLeaderElection, }) if err != nil { - setupLog.Error(err, "unable to start manager") - os.Exit(1) + exit(app.FAILED_TO_CREATE_CONTROLLER_MANAGER, err) } - setupLog.Info("Registering CertServiceIssuerReconciler...") - if err = (&controllers.CertServiceIssuerReconciler{ + setupLog.Info("Registering CMPv2IssuerController...") + if err = (&controllers.CMPv2IssuerController{ Client: manager.GetClient(), - Log: ctrl.Log.WithName("controllers").WithName("CertServiceIssuer"), + Log: ctrl.Log.WithName("controllers").WithName("CMPv2Issuer"), Clock: clock.RealClock{}, - Recorder: manager.GetEventRecorderFor("certservice-issuer-controller"), + Recorder: manager.GetEventRecorderFor("cmpv2-issuer-controller"), }).SetupWithManager(manager); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "CertServiceIssuer") - os.Exit(1) + exit(app.FAILED_TO_REGISTER_CMPv2_ISSUER_CONTROLLER, err) } - setupLog.Info("Registering CertificateRequestReconciler...") - if err = (&controllers.CertificateRequestReconciler{ + setupLog.Info("Registering CertificateRequestController...") + if err = (&controllers.CertificateRequestController{ Client: manager.GetClient(), Log: ctrl.Log.WithName("controllers").WithName("CertificateRequest"), - Recorder: manager.GetEventRecorderFor("certificaterequests-controller"), + Recorder: manager.GetEventRecorderFor("certificate-requests-controller"), }).SetupWithManager(manager); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "CertificateRequest") - os.Exit(1) + exit(app.FAILED_TO_REGISTER_CERT_REQUEST_CONTROLLER, err) } setupLog.Info("Starting k8s manager...") if err := manager.Start(ctrl.SetupSignalHandler()); err != nil { - setupLog.Error(err, "problem running manager") - os.Exit(1) + exit(app.EXCEPTION_WHILE_RUNNING_CONTROLLER_MANAGER, err) } setupLog.Info("Application is up and running.") } + +func exit(exitCode app.ExitCode, err error) { + setupLog.Error(err, exitCode.Message) + os.Exit(exitCode.Code) +} |