2 * ============LICENSE_START=======================================================
3 * oom-certservice-k8s-external-provider
4 * ================================================================================
5 * Copyright (C) 2020 Nokia. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
24 cmapi "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
26 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27 "k8s.io/apimachinery/pkg/runtime"
28 "k8s.io/apimachinery/pkg/types"
29 scheme2 "k8s.io/client-go/kubernetes/scheme"
30 "sigs.k8s.io/controller-runtime/pkg/reconcile"
32 "onap.org/oom-certservice/k8s-external-provider/src/cmpv2api"
36 SecretName = "issuer-cert-secret"
37 Url = "https://oom-cert-service:8443/v1/certificate/"
38 HealthEndpoint = "actuator/health"
39 CertEndpoint = "v1/certificate"
41 KeySecretKey = "cmpv2Issuer-key.pem"
42 CertSecretKey = "cmpv2Issuer-cert.pem"
43 CacertSecretKey = "cacert.pem"
45 IssuerObjectName = "cmpv2-issuer"
48 PrivateKeySecret = "privateKeySecretName"
51 func GetValidIssuerWithSecret() (cmpv2api.CMPv2Issuer, v1.Secret) {
52 issuer := cmpv2api.CMPv2Issuer{
53 TypeMeta: metav1.TypeMeta{
54 APIVersion: APIVersion,
57 ObjectMeta: metav1.ObjectMeta{
58 Name: IssuerObjectName,
61 Spec: GetValidCMPv2IssuerSpec(),
65 Data: map[string][]byte{
66 KeySecretKey: KeyBytes,
67 CertSecretKey: CertBytes,
68 CacertSecretKey: CacertBytes,
70 ObjectMeta: metav1.ObjectMeta{
75 secret.Name = SecretName
79 func GetValidCMPv2IssuerSpec() cmpv2api.CMPv2IssuerSpec {
80 issuerSpec := cmpv2api.CMPv2IssuerSpec{
82 HealthEndpoint: HealthEndpoint,
83 CertEndpoint: CertEndpoint,
85 CertSecretRef: cmpv2api.SecretKeySelector{
88 CertRef: CertSecretKey,
89 CacertRef: CacertSecretKey,
95 func GetScheme() *runtime.Scheme {
96 scheme := runtime.NewScheme()
97 _ = scheme2.AddToScheme(scheme)
98 _ = cmapi.AddToScheme(scheme)
99 _ = cmpv2api.AddToScheme(scheme)
103 func GetFakeRequest(objectName string) reconcile.Request {
104 fakeRequest := reconcile.Request{
105 NamespacedName: CreateIssuerNamespaceName(Namespace, objectName),
110 func GetIssuerStoreKey() types.NamespacedName {
111 return CreateIssuerNamespaceName(Namespace, IssuerObjectName)
114 func CreateIssuerNamespaceName(namespace string, name string) types.NamespacedName {
115 return types.NamespacedName{
116 Namespace: namespace,