diff options
author | 2020-10-15 09:04:18 +0200 | |
---|---|---|
committer | 2020-10-15 16:01:53 +0200 | |
commit | f5fb53b031c2f1c4bc4872de59b9774a559d786f (patch) | |
tree | 2345c86aeaedfef576b513c3b325ce303c1261c7 /certServiceK8sExternalProvider/src/cmpv2api | |
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/src/cmpv2api')
3 files changed, 338 insertions, 0 deletions
diff --git a/certServiceK8sExternalProvider/src/cmpv2api/cmpv2_groupversion_info.go b/certServiceK8sExternalProvider/src/cmpv2api/cmpv2_groupversion_info.go new file mode 100644 index 00000000..996cf21a --- /dev/null +++ b/certServiceK8sExternalProvider/src/cmpv2api/cmpv2_groupversion_info.go @@ -0,0 +1,45 @@ +/* + * ============LICENSE_START======================================================= + * oom-certservice-k8s-external-provider + * ================================================================================ + * Copyright (c) 2019 Smallstep Labs, Inc. + * Modifications copyright (C) 2020 Nokia. All rights reserved. + * ================================================================================ + * This source code was copied from the following git repository: + * https://github.com/smallstep/step-issuer + * The source code was modified for usage in the ONAP project. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package cmpv2api + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects + GroupVersion = schema.GroupVersion{Group: "certmanager.onap.org", Version: "v1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) + +const CMPv2IssuerKind = "CMPv2Issuer" + diff --git a/certServiceK8sExternalProvider/src/cmpv2api/cmpv2_issuer_crd_deepcopy.go b/certServiceK8sExternalProvider/src/cmpv2api/cmpv2_issuer_crd_deepcopy.go new file mode 100644 index 00000000..68e79ce1 --- /dev/null +++ b/certServiceK8sExternalProvider/src/cmpv2api/cmpv2_issuer_crd_deepcopy.go @@ -0,0 +1,161 @@ +/* + * ============LICENSE_START======================================================= + * oom-certservice-k8s-external-provider + * ================================================================================ + * Copyright (c) 2019 Smallstep Labs, Inc. + * Modifications copyright (C) 2020 Nokia. All rights reserved. + * ================================================================================ + * This source code was copied from the following git repository: + * https://github.com/smallstep/step-issuer + * The source code was modified for usage in the ONAP project. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package cmpv2api + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (inputSecretKeySelector *SecretKeySelector) DeepCopyInto(outSecretKeySelector *SecretKeySelector) { + *outSecretKeySelector = *inputSecretKeySelector +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecretKeySelector. +func (inputSecretKeySelector *SecretKeySelector) DeepCopy() *SecretKeySelector { + if inputSecretKeySelector == nil { + return nil + } + out := new(SecretKeySelector) + inputSecretKeySelector.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (inputCMPv2Issuer *CMPv2Issuer) DeepCopyInto(outCMPv2Issuer *CMPv2Issuer) { + *outCMPv2Issuer = *inputCMPv2Issuer + outCMPv2Issuer.TypeMeta = inputCMPv2Issuer.TypeMeta + inputCMPv2Issuer.ObjectMeta.DeepCopyInto(&outCMPv2Issuer.ObjectMeta) + inputCMPv2Issuer.Spec.DeepCopyInto(&outCMPv2Issuer.Spec) + inputCMPv2Issuer.Status.DeepCopyInto(&outCMPv2Issuer.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CMPv2Issuer. +func (inputCMPv2Issuer *CMPv2Issuer) DeepCopy() *CMPv2Issuer { + if inputCMPv2Issuer == nil { + return nil + } + out := new(CMPv2Issuer) + inputCMPv2Issuer.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (inputCMPv2Issuer *CMPv2Issuer) DeepCopyObject() runtime.Object { + if deepCopy := inputCMPv2Issuer.DeepCopy(); deepCopy != nil { + return deepCopy + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (inputIssuerCondition *CMPv2IssuerCondition) DeepCopyInto(outIssuerCondition *CMPv2IssuerCondition) { + *outIssuerCondition = *inputIssuerCondition + if inputIssuerCondition.LastTransitionTime != nil { + in, out := &inputIssuerCondition.LastTransitionTime, &outIssuerCondition.LastTransitionTime + *out = (*in).DeepCopy() + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CMPv2IssuerCondition. +func (inputIssuerCondition *CMPv2IssuerCondition) DeepCopy() *CMPv2IssuerCondition { + if inputIssuerCondition == nil { + return nil + } + out := new(CMPv2IssuerCondition) + inputIssuerCondition.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (inputIssuerList *CMPv2IssuerList) DeepCopyInto(outIssuerList *CMPv2IssuerList) { + *outIssuerList = *inputIssuerList + outIssuerList.TypeMeta = inputIssuerList.TypeMeta + inputIssuerList.ListMeta.DeepCopyInto(&outIssuerList.ListMeta) + if inputIssuerList.Items != nil { + in, out := &inputIssuerList.Items, &outIssuerList.Items + *out = make([]CMPv2Issuer, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CMPv2IssuerList. +func (inputIssuerList *CMPv2IssuerList) DeepCopy() *CMPv2IssuerList { + if inputIssuerList == nil { + return nil + } + out := new(CMPv2IssuerList) + inputIssuerList.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (inputIssuerList *CMPv2IssuerList) DeepCopyObject() runtime.Object { + if deepCopy := inputIssuerList.DeepCopy(); deepCopy != nil { + return deepCopy + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (inputIssuerSpec *CMPv2IssuerSpec) DeepCopyInto(outIssuerSpec *CMPv2IssuerSpec) { + *outIssuerSpec = *inputIssuerSpec + outIssuerSpec.KeyRef = inputIssuerSpec.KeyRef +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CMPv2IssuerSpec. +func (inputIssuerSpec *CMPv2IssuerSpec) DeepCopy() *CMPv2IssuerSpec { + if inputIssuerSpec == nil { + return nil + } + out := new(CMPv2IssuerSpec) + inputIssuerSpec.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (inputIssuerStatus *CMPv2IssuerStatus) DeepCopyInto(outIssuerStatus *CMPv2IssuerStatus) { + *outIssuerStatus = *inputIssuerStatus + if inputIssuerStatus.Conditions != nil { + in, out := &inputIssuerStatus.Conditions, &outIssuerStatus.Conditions + *out = make([]CMPv2IssuerCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CMPv2IssuerStatus. +func (inputIssuerStatus *CMPv2IssuerStatus) DeepCopy() *CMPv2IssuerStatus { + if inputIssuerStatus == nil { + return nil + } + out := new(CMPv2IssuerStatus) + inputIssuerStatus.DeepCopyInto(out) + return out +} diff --git a/certServiceK8sExternalProvider/src/cmpv2api/cmpv2_issuer_crd_schema.go b/certServiceK8sExternalProvider/src/cmpv2api/cmpv2_issuer_crd_schema.go new file mode 100644 index 00000000..f2482657 --- /dev/null +++ b/certServiceK8sExternalProvider/src/cmpv2api/cmpv2_issuer_crd_schema.go @@ -0,0 +1,132 @@ +/* + * ============LICENSE_START======================================================= + * oom-certservice-k8s-external-provider + * ================================================================================ + * Copyright (c) 2019 Smallstep Labs, Inc. + * Modifications copyright (C) 2020 Nokia. All rights reserved. + * ================================================================================ + * This source code was copied from the following git repository: + * https://github.com/smallstep/step-issuer + * The source code was modified for usage in the ONAP project. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package cmpv2api + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func init() { + SchemeBuilder.Register(&CMPv2Issuer{}, &CMPv2IssuerList{}) +} + +// CMPv2IssuerSpec defines the desired state of CMPv2Issuer +type CMPv2IssuerSpec struct { + // URL is the base URL for the CertService certificates instance. + URL string `json:"url"` + + // KeyRef is a reference to a Secret containing the provisioner + // password used to decrypt the provisioner private key. + KeyRef SecretKeySelector `json:"keyRef"` +} + +// CMPv2IssuerStatus defines the observed state of CMPv2Issuer +type CMPv2IssuerStatus struct { + + // +optional + Conditions []CMPv2IssuerCondition `json:"conditions,omitempty"` +} + +type CMPv2Issuer struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec CMPv2IssuerSpec `json:"spec,omitempty"` + Status CMPv2IssuerStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// CMPv2IssuerList contains a list of CMPv2Issuer +type CMPv2IssuerList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []CMPv2Issuer `json:"items"` +} + +// SecretKeySelector contains the reference to a secret. +type SecretKeySelector struct { + // The name of the secret in the pod's namespace to select from. + Name string `json:"name"` + + // The key of the secret to select from. Must be a valid secret key. + // +optional + Key string `json:"key,omitempty"` +} + +// ConditionType represents a CMPv2Issuer condition type. +// +kubebuilder:validation:Enum=Ready +type ConditionType string + +const ( + // ConditionReady indicates that a CMPv2Issuer is ready for use. + ConditionReady ConditionType = "Ready" +) + +// ConditionStatus represents a condition's status. +// +kubebuilder:validation:Enum=True;False;Unknown +type ConditionStatus string + +// These are valid condition statuses. "ConditionTrue" means a resource is in +// the condition; "ConditionFalse" means a resource is not in the condition; +// "ConditionUnknown" means kubernetes can't decide if a resource is in the +// condition or not. In the future, we could add other intermediate +// conditions, e.g. ConditionDegraded. +const ( + // ConditionTrue represents the fact that a given condition is true + ConditionTrue ConditionStatus = "True" + + // ConditionFalse represents the fact that a given condition is false + ConditionFalse ConditionStatus = "False" + + // ConditionUnknown represents the fact that a given condition is unknown + ConditionUnknown ConditionStatus = "Unknown" +) + +// CMPv2IssuerCondition contains condition information for the CertService issuer. +type CMPv2IssuerCondition struct { + // Type of the condition, currently ('Ready'). + Type ConditionType `json:"type"` + + // Status of the condition, one of ('True', 'False', 'Unknown'). + // +kubebuilder:validation:Enum=True;False;Unknown + Status ConditionStatus `json:"status"` + + // LastTransitionTime is the timestamp corresponding to the last status + // change of this condition. + // +optional + LastTransitionTime *metav1.Time `json:"lastTransitionTime,omitempty"` + + // Reason is a brief machine readable explanation for the condition's last + // transition. + // +optional + Reason string `json:"reason,omitempty"` + + // Message is a human readable description of the details of the last + // transition, complementing reason. + // +optional + Message string `json:"message,omitempty"` +} |