|
| 1 | +/* |
| 2 | +Copyright 2026 The Crossplane Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package v1alpha1 |
| 18 | + |
| 19 | +import ( |
| 20 | + "reflect" |
| 21 | + |
| 22 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 23 | + "k8s.io/apimachinery/pkg/runtime/schema" |
| 24 | + |
| 25 | + xpv1 "github.com/crossplane/crossplane-runtime/v2/apis/common/v1" |
| 26 | + xpv2 "github.com/crossplane/crossplane-runtime/v2/apis/common/v2" |
| 27 | +) |
| 28 | + |
| 29 | +// ALMGitHubParameters are the configurable fields of a ALMGitHub. |
| 30 | +type ALMGitHubParameters struct { |
| 31 | + // URL is the GitHub API URL. |
| 32 | + // +kubebuilder:validation:Required |
| 33 | + // +kubebuilder:validation:Format=uri |
| 34 | + // +kubebuilder:validation:MinLength=1 |
| 35 | + URL string `json:"url"` |
| 36 | + // Key is the unique identifier for the ALM integration in SonarQube. |
| 37 | + // +kubebuilder:validation:Required |
| 38 | + // +kubebuilder:validation:MinLength=1 |
| 39 | + Key string `json:"key"` |
| 40 | + // AppID is the GitHub App ID. |
| 41 | + // +kubebuilder:validation:Required |
| 42 | + // +kubebuilder:validation:MinLength=1 |
| 43 | + // +kubebuilder:validation:MaxLength=80 |
| 44 | + AppID string `json:"appId"` |
| 45 | + // ClientID is the GitHub App Client ID. |
| 46 | + // +kubebuilder:validation:Required |
| 47 | + // +kubebuilder:validation:MinLength=1 |
| 48 | + // +kubebuilder:validation:MaxLength=80 |
| 49 | + ClientID string `json:"clientId"` |
| 50 | + // ClientSecretRef references a Secret containing the GitHub App Client Secret. |
| 51 | + // +kubebuilder:validation:Required |
| 52 | + ClientSecretRef *xpv1.LocalSecretKeySelector `json:"clientSecretRef"` |
| 53 | + // PrivateKeyRef references a Secret containing the GitHub App Private Key. |
| 54 | + // +kubebuilder:validation:Required |
| 55 | + PrivateKeyRef *xpv1.LocalSecretKeySelector `json:"privateKeyRef"` |
| 56 | + // WebhookSecretRef references a Secret containing the GitHub App Webhook Secret. |
| 57 | + // +optional |
| 58 | + WebhookSecretRef *xpv1.LocalSecretKeySelector `json:"webhookSecretRef,omitempty"` |
| 59 | +} |
| 60 | + |
| 61 | +// ALMGitHubObservation are the observable fields of a ALMGitHub. |
| 62 | +type ALMGitHubObservation struct { |
| 63 | + ALMCommonObservation `json:",inline"` |
| 64 | + |
| 65 | + // AppID is the GitHub App ID as observed from the SonarQube API. |
| 66 | + AppID string `json:"appId,omitempty"` |
| 67 | + // ClientID is the GitHub App Client ID as observed from the SonarQube API. |
| 68 | + ClientID string `json:"clientId,omitempty"` |
| 69 | +} |
| 70 | + |
| 71 | +// A ALMGitHubSpec defines the desired state of a ALMGitHub. |
| 72 | +// +kubebuilder:validation:XValidation:rule="has(self.writeConnectionSecretToRef) && size(self.writeConnectionSecretToRef.name) > 0",message="writeConnectionSecretToRef with a non-empty name is required" |
| 73 | +type ALMGitHubSpec struct { |
| 74 | + xpv2.ManagedResourceSpec `json:",inline"` |
| 75 | + |
| 76 | + ForProvider ALMGitHubParameters `json:"forProvider"` |
| 77 | +} |
| 78 | + |
| 79 | +// A ALMGitHubStatus represents the observed state of a ALMGitHub. |
| 80 | +type ALMGitHubStatus struct { |
| 81 | + xpv1.ResourceStatus `json:",inline"` |
| 82 | + |
| 83 | + AtProvider ALMGitHubObservation `json:"atProvider,omitempty"` |
| 84 | +} |
| 85 | + |
| 86 | +// +kubebuilder:object:root=true |
| 87 | + |
| 88 | +// A ALMGitHub is a managed resource that represents a SonarQube ALM integration for GitHub. |
| 89 | +// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" |
| 90 | +// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" |
| 91 | +// +kubebuilder:printcolumn:name="EXTERNAL-NAME",type="string",JSONPath=".metadata.annotations.crossplane\\.io/external-name" |
| 92 | +// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" |
| 93 | +// +kubebuilder:subresource:status |
| 94 | +// +kubebuilder:resource:scope=Namespaced,categories={crossplane,managed,sonarqube} |
| 95 | +type ALMGitHub struct { |
| 96 | + metav1.TypeMeta `json:",inline"` |
| 97 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 98 | + |
| 99 | + Spec ALMGitHubSpec `json:"spec"` |
| 100 | + Status ALMGitHubStatus `json:"status,omitempty"` |
| 101 | +} |
| 102 | + |
| 103 | +// +kubebuilder:object:root=true |
| 104 | + |
| 105 | +// ALMGitHubList contains a list of ALMGitHub. |
| 106 | +type ALMGitHubList struct { |
| 107 | + metav1.TypeMeta `json:",inline"` |
| 108 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 109 | + |
| 110 | + Items []ALMGitHub `json:"items"` |
| 111 | +} |
| 112 | + |
| 113 | +// ALMGitHub type metadata. |
| 114 | +var ( |
| 115 | + ALMGitHubKind = reflect.TypeFor[ALMGitHub]().Name() |
| 116 | + ALMGitHubGroupKind = schema.GroupKind{Group: Group, Kind: ALMGitHubKind}.String() |
| 117 | + ALMGitHubKindAPIVersion = ALMGitHubKind + "." + SchemeGroupVersion.String() |
| 118 | + ALMGitHubGroupVersionKind = SchemeGroupVersion.WithKind(ALMGitHubKind) |
| 119 | +) |
| 120 | + |
| 121 | +func init() { |
| 122 | + SchemeBuilder.Register(&ALMGitHub{}, &ALMGitHubList{}) |
| 123 | +} |
0 commit comments