Skip to content

Commit 23b29b2

Browse files
committed
feat: Add controllers for namespaced MRs
- Use copystruct to copy API types - Use generic wrapper to reuse existing cluster logic - Use goverter to convert between cluster and namespace types - Test everything by copying and minimally adapting cluster controller tests Signed-off-by: MisterMX <[email protected]>
1 parent a407a43 commit 23b29b2

File tree

104 files changed

+22560
-525
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+22560
-525
lines changed

apis/namespace/applications/v1alpha1/application_types.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,31 @@ limitations under the License.
1616

1717
package v1alpha1
1818

19+
// Copy types from cluster-scope apis replace references with namespace types:
20+
//go:generate go run -modfile ../../../../tools/go.mod -tags generate github.com/mistermx/copystruct/cmd/copystruct ../../../cluster/applications/v1alpha1 zz_generated.types.copied.go ApplicationParameters,ArgoApplicationStatus
21+
//go:generate sed -i s|github\.com/crossplane-contrib/provider-argocd/apis/cluster|github.com/crossplane-contrib/provider-argocd/apis/namespace|g zz_generated.types.copied.go
22+
//go:generate sed -i s|v1\.Reference|v1.NamespacedReference|g zz_generated.types.copied.go
23+
//go:generate sed -i s|v1\.Selector|v1.NamespacedSelector|g zz_generated.types.copied.go
24+
1925
import (
2026
"reflect"
2127

2228
xpv1 "github.com/crossplane/crossplane-runtime/v2/apis/common/v1"
29+
xpv2 "github.com/crossplane/crossplane-runtime/v2/apis/common/v2"
2330
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2431
"k8s.io/apimachinery/pkg/runtime/schema"
25-
26-
clusterapis "github.com/crossplane-contrib/provider-argocd/apis/cluster/applications/v1alpha1"
2732
)
2833

2934
// A ApplicationSpec defines the desired state of an ArgoCD Application.
3035
type ApplicationSpec struct {
31-
xpv1.ResourceSpec `json:",inline"`
32-
ForProvider clusterapis.ApplicationParameters `json:"forProvider"`
36+
xpv2.ManagedResourceSpec `json:",inline"`
37+
ForProvider ApplicationParameters `json:"forProvider"`
3338
}
3439

3540
// A ApplicationStatus represents the observed state of an ArgoCD Application.
3641
type ApplicationStatus struct {
3742
xpv1.ResourceStatus `json:",inline"`
38-
AtProvider clusterapis.ArgoApplicationStatus `json:"atProvider,omitempty"`
43+
AtProvider ArgoApplicationStatus `json:"atProvider,omitempty"`
3944
}
4045

4146
// +kubebuilder:object:root=true
@@ -45,7 +50,7 @@ type ApplicationStatus struct {
4550
// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status"
4651
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
4752
// +kubebuilder:subresource:status
48-
// +kubebuilder:resource:scope=Namespace,categories={crossplane,managed,argocd}
53+
// +kubebuilder:resource:scope=Namespaced,categories={crossplane,managed,argocd}
4954
type Application struct {
5055
metav1.TypeMeta `json:",inline"`
5156
metav1.ObjectMeta `json:"metadata,omitempty"`

0 commit comments

Comments
 (0)