Skip to content

Commit 88376fa

Browse files
chore: simplify codebase (#23)
* docs: add comments * chore: update generated files * feat: add environment variable to properly read kubeconfig * chore: update .gitignore * chore: update build repo * feat(fixme): use openmcp-operator/api * docs: add code comments * chore: update build repo * docs: add more comments * test: add context_test.go * test: add more tests * refactor: code * test: increase coverage * test(smartrequeue): increase coverage to 90% * fix(example): typo * fix: phase declaration * chore: remove errors * chore: update PROJECT file * chore: register openmcp-operator v1alpha1 scheme * chore: update sample * docs: add todo * fix: imports
1 parent 7fdfa8c commit 88376fa

25 files changed

+756
-1285
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ go.work
2727
*~
2828

2929
*.html
30+
31+
# VS Code Go debug binaries
32+
bin/debug_bin*

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,7 @@ RUN apk add --no-cache docker-cli kind
2929
WORKDIR /
3030
COPY --from=builder /workspace/manager .
3131
USER 65532:65532
32+
# Set the default command to execute when running the container
33+
ENV KIND_IN_CONTAINER=true
3234

3335
ENTRYPOINT ["/manager"]

PROJECT

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,4 @@ resources:
1616
kind: Cluster
1717
path: github.com/openmcp-project/cluster-provider-kind/api/v1alpha1
1818
version: v1alpha1
19-
- api:
20-
crdVersion: v1
21-
namespaced: true
22-
controller: true
23-
domain: kind.clusters.openmcp.cloud
24-
kind: AccessRequest
25-
path: github.com/openmcp-project/cluster-provider-kind/api/v1alpha1
26-
version: v1alpha1
2719
version: "3"

api/v1alpha1/accessrequest_types.go

Lines changed: 0 additions & 72 deletions
This file was deleted.

api/v1alpha1/cluster_types.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package v1alpha1
1818

1919
import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
runtime "k8s.io/apimachinery/pkg/runtime"
2122
)
2223

2324
// Phase is a custom type representing the phase of a cluster.
@@ -48,10 +49,32 @@ type ClusterSpec struct{}
4849

4950
// ClusterStatus defines the observed state of Cluster.
5051
type ClusterStatus struct {
52+
// Reason is expected to contain a CamelCased string that provides further information in a machine-readable format.
53+
// +optional
54+
Reason string `json:"reason,omitempty"`
55+
56+
// Message contains further details in a human-readable format.
57+
// +optional
58+
Message string `json:"message,omitempty"`
59+
60+
// Conditions is a list of conditions that apply to the cluster.
61+
// +optional
5162
Conditions []metav1.Condition `json:"conditions,omitempty"`
5263

64+
// ObservedGeneration is the generation of this resource that was last reconciled by the controller.
65+
ObservedGeneration int64 `json:"observedGeneration"`
66+
5367
// +kubebuilder:default=Unknown
5468
Phase Phase `json:"phase"`
69+
70+
// APIServer is the API server endpoint of the cluster.
71+
// +optional
72+
APIServer string `json:"apiServer,omitempty"`
73+
74+
// ProviderStatus is the provider-specific status of the cluster.
75+
// x-kubernetes-preserve-unknown-fields: true
76+
// +optional
77+
ProviderStatus *runtime.RawExtension `json:"providerStatus,omitempty"`
5578
}
5679

5780
// Cluster is the Schema for the clusters API.
@@ -79,3 +102,12 @@ type ClusterList struct {
79102
func init() {
80103
SchemeBuilder.Register(&Cluster{}, &ClusterList{})
81104
}
105+
106+
const (
107+
// StatusPhaseReady indicates that the resource is ready. All conditions are met and are in status "True".
108+
StatusPhaseReady = "Ready"
109+
// StatusPhaseProgressing indicates that the resource is not ready and being created or updated. At least one condition is not met and is in status "False".
110+
StatusPhaseProgressing = "Progressing"
111+
// StatusPhaseTerminating indicates that the resource is not ready and in deletion. At least one condition is not met and is in status "False".
112+
StatusPhaseTerminating = "Terminating"
113+
)

api/v1alpha1/zz_generated.deepcopy.go

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

cmd/cluster-provider-kind/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import (
3838
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
3939
"sigs.k8s.io/controller-runtime/pkg/webhook"
4040

41+
openv1alpha1 "github.com/openmcp-project/openmcp-operator/api/clusters/v1alpha1"
42+
4143
kindclustersopenmcpcloudv1alpha1 "github.com/openmcp-project/cluster-provider-kind/api/v1alpha1"
4244
"github.com/openmcp-project/cluster-provider-kind/internal/controller"
4345
"github.com/openmcp-project/cluster-provider-kind/pkg/kind"
@@ -54,6 +56,8 @@ func init() {
5456
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
5557

5658
utilruntime.Must(kindclustersopenmcpcloudv1alpha1.AddToScheme(scheme))
59+
utilruntime.Must(openv1alpha1.AddToScheme(scheme))
60+
5761
// +kubebuilder:scaffold:scheme
5862
}
5963

@@ -181,7 +185,7 @@ func main() {
181185
})
182186
}
183187

184-
kindProvider := kind.NewDockerProvider()
188+
kindProvider := kind.NewKindProvider()
185189

186190
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
187191
Scheme: scheme,

0 commit comments

Comments
 (0)