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