We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eb26b4f commit db55261Copy full SHA for db55261
api/crds/manifests/usage.openmcp.cloud_mcpusages.yaml
@@ -13,10 +13,22 @@ spec:
13
kind: MCPUsage
14
listKind: MCPUsageList
15
plural: mcpusages
16
+ shortNames:
17
+ - mcpu
18
singular: mcpusage
- scope: Namespaced
19
+ scope: Cluster
20
versions:
- - name: v1
21
+ - additionalPrinterColumns:
22
+ - jsonPath: .spec.project
23
+ name: Project
24
+ type: string
25
+ - jsonPath: .spec.workspace
26
+ name: Workspace
27
28
+ - jsonPath: .spec.mcp
29
+ name: MCP
30
31
+ name: v1
32
schema:
33
openAPIV3Schema:
34
description: MCPUsage is the Schema for the mcpdailies API.
api/usage/v1/mcpusage_types.go
@@ -74,7 +74,11 @@ func NewDailyUsage(date time.Time, hours int) (DailyUsage, error) {
74
75
// +kubebuilder:object:root=true
76
// +kubebuilder:subresource:status
77
+// +kubebuilder:resource:scope=Cluster,shortName=mcpu
78
// +kubebuilder:metadata:labels="openmcp.cloud/cluster=onboarding"
79
+// +kubebuilder:printcolumn:name="Project",type=string,JSONPath=`.spec.project`
80
+// +kubebuilder:printcolumn:name="Workspace",type=string,JSONPath=`.spec.workspace`
81
+// +kubebuilder:printcolumn:name="MCP",type=string,JSONPath=`.spec.mcp`
82
83
// MCPUsage is the Schema for the mcpdailies API.
84
type MCPUsage struct {
go.mod
@@ -3,6 +3,7 @@ module github.com/openmcp-project/usage-operator
3
go 1.24.4
4
5
require (
6
+ github.com/google/uuid v1.6.0
7
github.com/onsi/ginkgo/v2 v2.23.4
8
github.com/onsi/gomega v1.37.0
9
github.com/openmcp-project/controller-utils v0.10.0
@@ -45,7 +46,6 @@ require (
45
46
github.com/google/gnostic-models v0.6.9 // indirect
47
github.com/google/go-cmp v0.7.0 // indirect
48
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
- github.com/google/uuid v1.6.0 // indirect
49
github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0 // indirect
50
github.com/inconshreveable/mousetrap v1.1.0 // indirect
51
github.com/josharian/intern v1.0.0 // indirect
internal/controller/managedcontrolplane_controller.go
@@ -93,18 +93,6 @@ func (r *ManagedControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.
93
return ctrl.Result{}, client.IgnoreNotFound(err)
94
}
95
96
- // if mcp.Status.ObservedGeneration == 0 {
97
- // log.Info("mcp '" + mcp.Name + "' was created.")
98
- // return ctrl.Result{}, nil
99
- // }
100
-
101
- // if mcp.Status.ObservedGeneration != mcp.Generation {
102
- // log.Info("mcp '" + mcp.Name + "' was updated.")
103
104
105
106
- // log.Info("mcp '" + mcp.Name + "' got just a status update.")
107
108
return ctrl.Result{}, nil
109
110
internal/helper/clusteraccess.go
@@ -49,14 +49,18 @@ func GetOnboardingCluster(ctx context.Context, log logging.Logger, client client
Rules: []rbacv1.PolicyRule{
{
APIGroups: []string{"core.openmcp.cloud"},
52
- Resources: []string{"managedcontrolplanes", "managedcontrolplanes/status"},
53
- Verbs: []string{"get", "list"},
+ Resources: []string{
+ "managedcontrolplanes", "managedcontrolplanes/status",
54
+ "projects", "projects/status",
55
+ "workspaces", "workspaces/status",
56
+ },
57
+ Verbs: []string{"get", "list", "watch"},
58
},
59
60
APIGroups: []string{"apiextensions.k8s.io"},
61
Resources: []string{"customresourcedefinitions"},
- Verbs: []string{"create", "update", "delete"},
- ResourceNames: []string{"mcpusage"},
62
+ Verbs: []string{"get", "patch", "create", "update", "delete"},
63
+ ResourceNames: []string{"mcpusages.usage.openmcp.cloud"},
64
65
66
APIGroups: []string{"usage.openmcp.cloud"},
internal/usage/helper.go
@@ -1,12 +1,15 @@
1
package usage
2
import (
+ "errors"
"sort"
"time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
10
11
+ "github.com/google/uuid"
12
+
v1 "github.com/openmcp-project/usage-operator/api/usage/v1"
)
@@ -52,11 +55,17 @@ func GetNamespacedName(project, workspace string) string {
return "project-" + project + "--ws-" + workspace
-func GetObjectKey(project, workspace, mcp string) client.ObjectKey {
- return client.ObjectKey{
- Name: mcp,
- Namespace: GetNamespacedName(project, workspace),
+func GetObjectKey(project, workspace, mcp string) (client.ObjectKey, error) {
+ name := GetNamespacedName(project, workspace) + "-" + mcp
+ id := uuid.NewSHA1(uuid.Nil, []byte(name))
+ if id.String() == "" {
+ return client.ObjectKey{}, errors.New("can't generate uuid from input")
+ return client.ObjectKey{
67
+ Name: id.String(),
68
+ }, nil
69
70
71
// merges two DailyUsages where no Date is double
0 commit comments