[OOM-K8S-CERT-EXTERNAL-PROVIDER] Mock implementaion enhanced (part II)
[oom/platform/cert-service.git] / certServiceK8sExternalProvider / src / cmpv2api / cmpv2_issuer_crd_schema.go
1 /*
2  * ============LICENSE_START=======================================================
3  * oom-certservice-k8s-external-provider
4  * ================================================================================
5  * Copyright (c) 2019 Smallstep Labs, Inc.
6  * Modifications copyright (C) 2020 Nokia. All rights reserved.
7  * ================================================================================
8  * This source code was copied from the following git repository:
9  * https://github.com/smallstep/step-issuer
10  * The source code was modified for usage in the ONAP project.
11  * ================================================================================
12  * Licensed under the Apache License, Version 2.0 (the "License");
13  * you may not use this file except in compliance with the License.
14  * You may obtain a copy of the License at
15  *
16  *      http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an "AS IS" BASIS,
20  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  * ============LICENSE_END=========================================================
24  */
25
26 package cmpv2api
27
28 import (
29         metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
30 )
31
32 func init() {
33         SchemeBuilder.Register(&CMPv2Issuer{}, &CMPv2IssuerList{})
34 }
35
36 // CMPv2IssuerSpec defines the desired state of CMPv2Issuer
37 type CMPv2IssuerSpec struct {
38         // URL is the base URL for the CertService certificates instance.
39         URL string `json:"url"`
40
41         // KeyRef is a reference to a Secret containing the provisioner
42         // password used to decrypt the provisioner private key.
43         KeyRef SecretKeySelector `json:"keyRef"`
44 }
45
46 // CMPv2IssuerStatus defines the observed state of CMPv2Issuer
47 type CMPv2IssuerStatus struct {
48
49         // +optional
50         Conditions []CMPv2IssuerCondition `json:"conditions,omitempty"`
51 }
52
53 type CMPv2Issuer struct {
54         metav1.TypeMeta   `json:",inline"`
55         metav1.ObjectMeta `json:"metadata,omitempty"`
56
57         Spec   CMPv2IssuerSpec   `json:"spec,omitempty"`
58         Status CMPv2IssuerStatus `json:"status,omitempty"`
59 }
60
61 // +kubebuilder:object:root=true
62
63 // CMPv2IssuerList contains a list of CMPv2Issuer
64 type CMPv2IssuerList struct {
65         metav1.TypeMeta `json:",inline"`
66         metav1.ListMeta `json:"metadata,omitempty"`
67         Items           []CMPv2Issuer `json:"items"`
68 }
69
70 // SecretKeySelector contains the reference to a secret.
71 type SecretKeySelector struct {
72         // The name of the secret in the pod's namespace to select from.
73         Name string `json:"name"`
74
75         // The key of the secret to select from. Must be a valid secret key.
76         // +optional
77         Key string `json:"key,omitempty"`
78 }
79
80 // ConditionType represents a CMPv2Issuer condition type.
81 // +kubebuilder:validation:Enum=Ready
82 type ConditionType string
83
84 const (
85         // ConditionReady indicates that a CMPv2Issuer is ready for use.
86         ConditionReady ConditionType = "Ready"
87 )
88
89 // ConditionStatus represents a condition's status.
90 // +kubebuilder:validation:Enum=True;False;Unknown
91 type ConditionStatus string
92
93 // These are valid condition statuses. "ConditionTrue" means a resource is in
94 // the condition; "ConditionFalse" means a resource is not in the condition;
95 // "ConditionUnknown" means kubernetes can't decide if a resource is in the
96 // condition or not. In the future, we could add other intermediate
97 // conditions, e.g. ConditionDegraded.
98 const (
99         // ConditionTrue represents the fact that a given condition is true
100         ConditionTrue ConditionStatus = "True"
101
102         // ConditionFalse represents the fact that a given condition is false
103         ConditionFalse ConditionStatus = "False"
104
105         // ConditionUnknown represents the fact that a given condition is unknown
106         ConditionUnknown ConditionStatus = "Unknown"
107 )
108
109 // CMPv2IssuerCondition contains condition information for the CertService issuer.
110 type CMPv2IssuerCondition struct {
111         // Type of the condition, currently ('Ready').
112         Type ConditionType `json:"type"`
113
114         // Status of the condition, one of ('True', 'False', 'Unknown').
115         // +kubebuilder:validation:Enum=True;False;Unknown
116         Status ConditionStatus `json:"status"`
117
118         // LastTransitionTime is the timestamp corresponding to the last status
119         // change of this condition.
120         // +optional
121         LastTransitionTime *metav1.Time `json:"lastTransitionTime,omitempty"`
122
123         // Reason is a brief machine readable explanation for the condition's last
124         // transition.
125         // +optional
126         Reason string `json:"reason,omitempty"`
127
128         // Message is a human readable description of the details of the last
129         // transition, complementing reason.
130         // +optional
131         Message string `json:"message,omitempty"`
132 }