Skip to content

Commit d5c4ae3

Browse files
authored
feat: support github alm (#76)
Signed-off-by: BoxBoxJason <contact@boxboxjason.dev>
1 parent b31696b commit d5c4ae3

20 files changed

Lines changed: 3061 additions & 37 deletions
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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+
}

apis/integration/v1alpha1/alm_gitlab_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type ALMGitLabObservation struct {
3737
}
3838

3939
// A ALMGitLabSpec defines the desired state of a ALMGitLab.
40+
// +kubebuilder:validation:XValidation:rule="has(self.writeConnectionSecretToRef) && size(self.writeConnectionSecretToRef.name) > 0",message="writeConnectionSecretToRef with a non-empty name is required"
4041
type ALMGitLabSpec struct {
4142
xpv2.ManagedResourceSpec `json:",inline"`
4243

apis/integration/v1alpha1/zz_generated.deepcopy.go

Lines changed: 139 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/integration/v1alpha1/zz_generated.managed.go

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/integration/v1alpha1/zz_generated.managedlist.go

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
namespace: default
5+
name: example-almgithub-client-secret
6+
type: Opaque
7+
stringData:
8+
clientSecret: example-client-secret
9+
10+
---
11+
apiVersion: v1
12+
kind: Secret
13+
metadata:
14+
namespace: default
15+
name: example-almgithub-private-key
16+
type: Opaque
17+
stringData:
18+
privateKey: |
19+
-----BEGIN RSA PRIVATE KEY-----
20+
...
21+
-----END RSA PRIVATE KEY-----
22+
23+
---
24+
apiVersion: integration.sonarqube.crossplane.io/v1alpha1
25+
kind: ALMGitHub
26+
metadata:
27+
namespace: default
28+
name: example-almgithub
29+
spec:
30+
forProvider:
31+
key: github-main
32+
url: https://api.github.com
33+
appId: "123456"
34+
clientId: "Iv1.abc123"
35+
clientSecretRef:
36+
name: example-almgithub-client-secret
37+
key: clientSecret
38+
privateKeyRef:
39+
name: example-almgithub-private-key
40+
key: privateKey
41+
providerConfigRef:
42+
name: example
43+
kind: ProviderConfig
44+
writeConnectionSecretToRef:
45+
name: example-almgithub-connection

internal/clients/integration/alm_bitbucket.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
//nolint:dupl // Provider-specific ALM wrappers intentionally share this structure.
1817
package integration
1918

2019
import (

0 commit comments

Comments
 (0)