Skip to content

Commit d057db4

Browse files
committed
feat: added new mcpdailyusage resource
1 parent d8da131 commit d057db4

19 files changed

+578
-72
lines changed

.github/workflows/test-e2e.yml

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

PROJECT

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ cliVersion: 4.6.0
66
domain: openmcp.cloud
77
layout:
88
- go.kubebuilder.io/v4
9+
multigroup: true
910
projectName: usage-operator
1011
repo: github.com/openmcp-project/usage-operator
1112
resources:
@@ -16,4 +17,13 @@ resources:
1617
kind: ManagedControlPlane
1718
path: github.com/openmcp-project/mcp-operator/api/core/v1alpha1
1819
version: v1alpha1
20+
- api:
21+
crdVersion: v1
22+
namespaced: true
23+
controller: true
24+
domain: openmcp.cloud
25+
group: usage
26+
kind: MCPDaily
27+
path: github.com/openmcp-project/usage-operator/api/usage/v1
28+
version: v1
1929
version: "3"

api/usage/v1/groupversion_info.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright 2025.
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 v1 contains API Schema definitions for the usage v1 API group.
18+
// +kubebuilder:object:generate=true
19+
// +groupName=usage.openmcp.cloud
20+
package v1
21+
22+
import (
23+
"k8s.io/apimachinery/pkg/runtime/schema"
24+
"sigs.k8s.io/controller-runtime/pkg/scheme"
25+
)
26+
27+
var (
28+
// GroupVersion is group version used to register these objects.
29+
GroupVersion = schema.GroupVersion{Group: "usage.openmcp.cloud", Version: "v1"}
30+
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
32+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
33+
34+
// AddToScheme adds the types in this group-version to the given scheme.
35+
AddToScheme = SchemeBuilder.AddToScheme
36+
)

api/usage/v1/mcpdaily_types.go

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
Copyright 2025.
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 v1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
25+
26+
// MCPDailySpec defines the desired state of MCPDaily.
27+
type MCPDailySpec struct{}
28+
29+
// MCPDailyStatus defines the observed state of MCPDaily.
30+
type MCPDailyStatus struct {
31+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
32+
// Important: Run "make" to regenerate code after modifying this file
33+
ChargingTarget string `json:"charging_target"`
34+
Project string `json:"project"`
35+
Workspace string `json:"workspace"`
36+
MCP string `json:"mcp"`
37+
Usage []DailyUsage `json:"daily_usage"`
38+
}
39+
40+
type DailyUsage struct {
41+
Timestamp metav1.Time `json:"timestamp"`
42+
Hours int `json:"hours"`
43+
}
44+
45+
// +kubebuilder:object:root=true
46+
// +kubebuilder:subresource:status
47+
// +kubebuilder:resource:scope=Cluster
48+
49+
// MCPDaily is the Schema for the mcpdailies API.
50+
type MCPDaily struct {
51+
metav1.TypeMeta `json:",inline"`
52+
metav1.ObjectMeta `json:"metadata,omitempty"`
53+
54+
Spec MCPDailySpec `json:"spec,omitempty"`
55+
Status MCPDailyStatus `json:"status,omitempty"`
56+
}
57+
58+
// +kubebuilder:object:root=true
59+
60+
// MCPDailyList contains a list of MCPDaily.
61+
type MCPDailyList struct {
62+
metav1.TypeMeta `json:",inline"`
63+
metav1.ListMeta `json:"metadata,omitempty"`
64+
Items []MCPDaily `json:"items"`
65+
}
66+
67+
func init() {
68+
SchemeBuilder.Register(&MCPDaily{}, &MCPDailyList{})
69+
}

api/usage/v1/zz_generated.deepcopy.go

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

cmd/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
4040
"sigs.k8s.io/controller-runtime/pkg/webhook"
4141

42+
usagev1 "github.com/openmcp-project/usage-operator/api/usage/v1"
4243
"github.com/openmcp-project/usage-operator/internal/controller"
4344
"github.com/openmcp-project/usage-operator/internal/runnable"
4445
"github.com/openmcp-project/usage-operator/internal/usage"
@@ -54,6 +55,7 @@ func init() {
5455
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
5556

5657
utilruntime.Must(corev1alpha1.AddToScheme(scheme))
58+
utilruntime.Must(usagev1.AddToScheme(scheme))
5759
// +kubebuilder:scaffold:scheme
5860
}
5961

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.18.0
7+
name: mcpdailies.usage.openmcp.cloud
8+
spec:
9+
group: usage.openmcp.cloud
10+
names:
11+
kind: MCPDaily
12+
listKind: MCPDailyList
13+
plural: mcpdailies
14+
singular: mcpdaily
15+
scope: Cluster
16+
versions:
17+
- name: v1
18+
schema:
19+
openAPIV3Schema:
20+
description: MCPDaily is the Schema for the mcpdailies API.
21+
properties:
22+
apiVersion:
23+
description: |-
24+
APIVersion defines the versioned schema of this representation of an object.
25+
Servers should convert recognized schemas to the latest internal value, and
26+
may reject unrecognized values.
27+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
28+
type: string
29+
kind:
30+
description: |-
31+
Kind is a string value representing the REST resource this object represents.
32+
Servers may infer this from the endpoint the client submits requests to.
33+
Cannot be updated.
34+
In CamelCase.
35+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
36+
type: string
37+
metadata:
38+
type: object
39+
spec:
40+
description: MCPDailySpec defines the desired state of MCPDaily.
41+
type: object
42+
status:
43+
description: MCPDailyStatus defines the observed state of MCPDaily.
44+
properties:
45+
charging_target:
46+
description: |-
47+
INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
48+
Important: Run "make" to regenerate code after modifying this file
49+
type: string
50+
daily_usage:
51+
items:
52+
properties:
53+
hours:
54+
type: integer
55+
timestamp:
56+
format: date-time
57+
type: string
58+
required:
59+
- hours
60+
- timestamp
61+
type: object
62+
type: array
63+
mcp:
64+
type: string
65+
project:
66+
type: string
67+
workspace:
68+
type: string
69+
required:
70+
- charging_target
71+
- daily_usage
72+
- mcp
73+
- project
74+
- workspace
75+
type: object
76+
type: object
77+
served: true
78+
storage: true
79+
subresources:
80+
status: {}

0 commit comments

Comments
 (0)