[OOM-K8S-CERT-EXTERNAL-PROVIDER] Rename variables to readable.
[oom/platform/cert-service.git] / certServiceK8sExternalProvider / src / api / certservice_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 api
27
28 import (
29         metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
30 )
31
32 func init() {
33         SchemeBuilder.Register(&CertServiceIssuer{}, &CertServiceIssuerList{})
34 }
35
36 // CertServiceIssuerSpec defines the desired state of CertServiceIssuer
37 type CertServiceIssuerSpec 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 // CertServiceIssuerStatus defines the observed state of CertServiceIssuer
47 type CertServiceIssuerStatus struct {
48         // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
49         // Important: Run "make" to regenerate code after modifying this file
50
51         // +optional
52         Conditions []CertServiceIssuerCondition `json:"conditions,omitempty"`
53 }
54
55 // +kubebuilder:object:root=true
56
57 // CertServiceIssuer is the Schema for the certserviceissuers API
58 // +kubebuilder:subresource:status
59 type CertServiceIssuer struct {
60         metav1.TypeMeta   `json:",inline"`
61         metav1.ObjectMeta `json:"metadata,omitempty"`
62
63         Spec   CertServiceIssuerSpec   `json:"spec,omitempty"`
64         Status CertServiceIssuerStatus `json:"status,omitempty"`
65 }
66
67 // +kubebuilder:object:root=true
68
69 // CertServiceIssuerList contains a list of CertServiceIssuer
70 type CertServiceIssuerList struct {
71         metav1.TypeMeta `json:",inline"`
72         metav1.ListMeta `json:"metadata,omitempty"`
73         Items           []CertServiceIssuer `json:"items"`
74 }
75
76 // SecretKeySelector contains the reference to a secret.
77 type SecretKeySelector struct {
78         // The name of the secret in the pod's namespace to select from.
79         Name string `json:"name"`
80
81         // The key of the secret to select from. Must be a valid secret key.
82         // +optional
83         Key string `json:"key,omitempty"`
84 }
85
86 // ConditionType represents a CertServiceIssuer condition type.
87 // +kubebuilder:validation:Enum=Ready
88 type ConditionType string
89
90 const (
91         // ConditionReady indicates that a CertServiceIssuer is ready for use.
92         ConditionReady ConditionType = "Ready"
93 )
94
95 // ConditionStatus represents a condition's status.
96 // +kubebuilder:validation:Enum=True;False;Unknown
97 type ConditionStatus string
98
99 // These are valid condition statuses. "ConditionTrue" means a resource is in
100 // the condition; "ConditionFalse" means a resource is not in the condition;
101 // "ConditionUnknown" means kubernetes can't decide if a resource is in the
102 // condition or not. In the future, we could add other intermediate
103 // conditions, e.g. ConditionDegraded.
104 const (
105         // ConditionTrue represents the fact that a given condition is true
106         ConditionTrue ConditionStatus = "True"
107
108         // ConditionFalse represents the fact that a given condition is false
109         ConditionFalse ConditionStatus = "False"
110
111         // ConditionUnknown represents the fact that a given condition is unknown
112         ConditionUnknown ConditionStatus = "Unknown"
113 )
114
115 // CertServiceIssuerCondition contains condition information for the CertService issuer.
116 type CertServiceIssuerCondition struct {
117         // Type of the condition, currently ('Ready').
118         Type ConditionType `json:"type"`
119
120         // Status of the condition, one of ('True', 'False', 'Unknown').
121         // +kubebuilder:validation:Enum=True;False;Unknown
122         Status ConditionStatus `json:"status"`
123
124         // LastTransitionTime is the timestamp corresponding to the last status
125         // change of this condition.
126         // +optional
127         LastTransitionTime *metav1.Time `json:"lastTransitionTime,omitempty"`
128
129         // Reason is a brief machine readable explanation for the condition's last
130         // transition.
131         // +optional
132         Reason string `json:"reason,omitempty"`
133
134         // Message is a human readable description of the details of the last
135         // transition, complementing reason.
136         // +optional
137         Message string `json:"message,omitempty"`
138 }